# two test executable
add_library(asebavmdummycallbacks STATIC
	asebavmdummycallbacks.cpp
)

# If the asebavm is built as a shared lib, it must not be a dependency of
# asebavmdummycallbacks because if it is, it will not be able to resolve refs
# using asebavmdummycallbacks. On the other hand, if asabavm is not built as a
# shared lib, it must be a dependency so that it can be used to resolve refs 
# in asebavmdummycallbacks.
target_link_libraries(asebavmdummycallbacks asebavm asebacommon)
add_executable(asebatest asebatest.cpp)
target_link_libraries(asebatest asebacompiler asebavm asebavmdummycallbacks asebacommon)

# the following tests should succeed
add_test(NAME basic-arithmetic COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/basic-arithmetic.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/basic-arithmetic.txt)
add_test(NAME basic-arithmetic-vector COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/basic-arithmetic-vector.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/basic-arithmetic-vector.txt)
add_test(NAME advanced-arithmetic COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/advanced-arithmetic.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/advanced-arithmetic.txt)
add_test(NAME advanced-arithmetic-vector COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/advanced-arithmetic-vector.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/advanced-arithmetic-vector.txt)
add_test(NAME binary-op COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-op.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-op.txt)
add_test(NAME shift-op COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-op.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-op.txt)
add_test(NAME compound-assignment COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/compound-assignments.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/compound-assignments.txt)
add_test(NAME compound-assignment-vector COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/compound-assignments-vector.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/compound-assignments-vector.txt)
add_test(NAME binary-assignment COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-assignments.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-assignments.txt)
add_test(NAME shift-assignment COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-assignments.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-assignments.txt)
add_test(NAME shift-assignment-vector COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-assignments-vector.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-assignments-vector.txt)
add_test(NAME multiple-logic-op COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/multiple-logic-op.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/multiple-logic-op.txt)
add_test(NAME unicode COMMAND asebatest -d -s ${CMAKE_CURRENT_SOURCE_DIR}/data/unicode.txt)
add_test(NAME optimisation-binary-not COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-binary-not.txt)
add_test(NAME optimisation-bit-to-bit COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-bit-to-bit.txt)
add_test(NAME optimisation-neutral-element COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-neutral-element.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-neutral-element.txt)
add_test(NAME optimisation-absorbing-element COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-absorbing-element.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-absorbing-element.txt)
add_test(NAME optimisation-demorgan COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-demorgan.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-demorgan.txt)
add_test(NAME for-loop COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop.txt)
add_test(NAME for-loop-vector COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-vector.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-vector.txt)
add_test(NAME for-loop-single-inc COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-single-inc.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-single-inc.txt)
add_test(NAME for-loop-single-dec COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-single-dec.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-single-dec.txt)
add_test(NAME while-loop COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/while-loop.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/while-loop.txt)
add_test(NAME while-loop-vector COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/while-loop-vector.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/while-loop-vector.txt)
add_test(NAME when-conditional COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/when-conditional.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/when-conditional.txt)
add_test(NAME comments COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/comments.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/comments.txt)
add_test(NAME subroutine COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/subroutine.txt)
add_test(NAME array-post-increment COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/array-post-increment.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/array-post-increment.txt)
add_test(NAME array-constant-access COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/array-constant-access.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/array-constant-access.txt)
add_test(NAME vardef COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef.txt)
add_test(NAME vardef-compat COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-compat.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-compat.txt)
add_test(NAME vardef-constant-size COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-constant-size.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-constant-size.txt)
add_test(NAME general-tuple COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/general-tuple.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/general-tuple.txt)
add_test(NAME assignments COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/assignments.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/assignments.txt)
add_test(NAME events COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/events.txt)
add_test(NAME general-tuple-events COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/general-tuple-events.txt)
add_test(NAME native-function COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/native-function.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/native-function.txt)
add_test(NAME native-function-indirect COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/native-function-indirect.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/native-function-indirect.txt)
add_test(NAME general-tuple-native-function COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/general-tuple-native-function.txt)
add_test(NAME var-def-compat-issue135 COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/var-def-compat-issue135.txt)
add_test(NAME array-indirect-access-issue134 COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/array-indirect-access-issue134.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/array-indirect-access-issue134.txt)
add_test(NAME constdef COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/constdef.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/constdef.txt)
add_test(NAME literal-overflow-check1 COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-overflow-check-ok1.txt)
add_test(NAME literal-overflow-check2 COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-overflow-check-ok2.txt)
add_test(NAME literal-hex1 COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-hex1.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-hex1.txt)
add_test(NAME literal-hex2 COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-hex2.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-hex2.txt)
add_test(NAME literal-bin1 COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-bin1.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-bin1.txt)
add_test(NAME literal-bin2 COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-bin2.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-bin2.txt)
add_test(NAME array-overwrite1 COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/array-overwrite.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/array-overwrite.txt)
add_test(NAME negation-optimisation COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/negation-optimisation.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/negation-optimisation.txt)
add_test(NAME division-optimisation COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/division-optimisation.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/division-optimisation.txt)
add_test(NAME if-not-optimisation COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/if-not-optimisation.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/if-not-optimisation.txt)
add_test(NAME callsub-before-sub-decl COMMAND asebatest ${CMAKE_CURRENT_SOURCE_DIR}/data/callsub-before-sub-decl.txt)
add_test(NAME return-in-if COMMAND asebatest --event --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/return-in-if.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/return-in-if.txt)
add_test(NAME sort-basic COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/sort-basic.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/sort-basic.txt)
add_test(NAME sort-duplicates COMMAND asebatest --memcmp ${CMAKE_CURRENT_SOURCE_DIR}/data/sort-duplicates.dump ${CMAKE_CURRENT_SOURCE_DIR}/data/sort-duplicates.txt)

# the following tests should fail
add_test(NAME division-by-zero-dyn COMMAND asebatest --exec_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/division-by-zero-dyn.txt)
add_test(NAME division-by-zero-static COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/division-by-zero-static.txt)
add_test(NAME chained-conditional COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/chained-conditional.txt)
add_test(NAME implicit-conditional COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/implicit-conditional.txt)
add_test(NAME array-access-out-of-bounds-dyn-over COMMAND asebatest --exec_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-dyn-over.txt)
add_test(NAME array-access-out-of-bounds-dyn-under COMMAND asebatest --exec_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-dyn-under.txt)
add_test(NAME array-access-out-of-bounds-static-over COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-static-over.txt)
add_test(NAME array-access-out-of-bounds-static-under COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-static-under.txt)
add_test(NAME vector-access-out-of-bounds-static-over COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vector-access-out-of-bounds-static-over.txt)
add_test(NAME vector-access-out-of-bounds-static-under COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vector-access-out-of-bounds-static-under.txt)
add_test(NAME vector-access-two-expr COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vector-access-two-expr.txt)
add_test(NAME assigning-bool COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/assigning-bool.txt)
add_test(NAME inconsistent-input1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input1.txt)
add_test(NAME inconsistent-input2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input2.txt)
add_test(NAME inconsistent-input3 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input3.txt)
add_test(NAME inconsistent-input4 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input4.txt)
add_test(NAME assignments-fail1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/assignments-fail1.txt)
add_test(NAME assignments-fail2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/assignments-fail2.txt)
add_test(NAME assignments-fail3 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/assignments-fail3.txt)
add_test(NAME assignments-fail4 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/assignments-fail4.txt)
add_test(NAME vardef-fail1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-fail1.txt)
add_test(NAME vardef-fail2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-fail2.txt)
add_test(NAME vardef-fail3 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-fail3.txt)
add_test(NAME vardef-compat-fail1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-compat-fail1.txt)
add_test(NAME vardef-not-constant-size COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/vardef-not-constant-size.txt)
add_test(NAME out-of-memory1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/out-of-memory1.txt)
add_test(NAME out-of-memory2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/out-of-memory2.txt)
add_test(NAME out-of-memory-temp1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/out-of-memory-temp1.txt)
add_test(NAME out-of-memory-temp2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/out-of-memory-temp2.txt)
add_test(NAME if-condition-vector COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/if-condition-vector.txt)
add_test(NAME for-loop-condition-vector COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-condition-vector.txt)
add_test(NAME for-loop-bounds COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop-bounds.txt)
add_test(NAME constant-namespace-collision COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/constant-namespace-collision.txt)
add_test(NAME array-constant-access-fail COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/array-constant-access-fail.txt)
add_test(NAME constdef-collision-1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/constdef-collision-1.txt)
add_test(NAME constdef-collision-2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/constdef-collision-2.txt)
add_test(NAME constdef-overriding COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/constdef-overriding.txt)
add_test(NAME constdef-collision-var COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/constdef-collision-var.txt)
add_test(NAME literal-overflow-fail1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-overflow-check-fail1.txt)
add_test(NAME literal-overflow-fail2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-overflow-check-fail2.txt)
add_test(NAME literal-hex-overflow-fail1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-hex-overflow1.txt)
add_test(NAME literal-hex-overflow-fail2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-hex-overflow2.txt)
add_test(NAME literal-bin-overflow-fail1 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-bin-overflow1.txt)
add_test(NAME literal-bin-overflow-fail2 COMMAND asebatest --comp_fail ${CMAKE_CURRENT_SOURCE_DIR}/data/literal-bin-overflow2.txt)

# check whether we have Python interpreter to run tests that require scripts
find_package(PythonInterp)
if (PYTHONINTERP_FOUND)
	# stress test the compiler, by simulating user's input
	# compiler should not crash. Exiting with an exception is OK
	# The script should always succeed (otherwise the compiler caught a signal)
	add_test(NAME simulate-basic-arithmetic COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/basic-arithmetic.txt)
	add_test(NAME simulate-advanced-arithmetic COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/advanced-arithmetic.txt)
	add_test(NAME simulate-binary-op COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-op.txt)
	add_test(NAME simulate-shift-op COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-op.txt)
	add_test(NAME simulate-compound-assignment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/compound-assignments.txt)
	add_test(NAME simulate-binary-assignment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-assignments.txt)
	add_test(NAME simulate-shift-assignment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-assignments.txt)
	add_test(NAME simulate-multiple-logic-op COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/multiple-logic-op.txt)
	add_test(NAME simulate-unicode COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/unicode.txt)
	add_test(NAME simulate-optimisation-binary-not COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-binary-not.txt)
	add_test(NAME simulate-optimisation-bit-to-bit COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-bit-to-bit.txt)
	add_test(NAME simulate-for-loop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop.txt)
	add_test(NAME simulate-while-loop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/while-loop.txt)
	add_test(NAME simulate-when-conditional COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/when-conditional.txt)
	add_test(NAME simulate-comments COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/comments.txt)
	add_test(NAME simulate-subroutine COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/subroutine.txt)

	add_test(NAME simulate-division-by-zero-dyn COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/division-by-zero-dyn.txt)
	add_test(NAME simulate-division-by-zero-static COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/division-by-zero-static.txt)
	add_test(NAME simulate-chained-conditional COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/chained-conditional.txt)
	add_test(NAME simulate-implicit-conditional COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/implicit-conditional.txt)
	add_test(NAME simulate-array-access-out-of-bounds-dyn-over COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-dyn-over.txt)
	add_test(NAME simulate-array-access-out-of-bounds-dyn-under COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-dyn-under.txt)
	add_test(NAME simulate-array-access-out-of-bounds-static-over COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-static-over.txt)
	add_test(NAME simulate-array-access-out-of-bounds-static-under COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/array-access-out-of-bounds-static-under.txt)
	add_test(NAME simulate-assigning-bool COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/assigning-bool.txt)
	add_test(NAME simulate-inconsistent-input1 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input1.txt)
	add_test(NAME simulate-inconsistent-input2 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input2.txt)
	add_test(NAME simulate-inconsistent-input3 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input3.txt)
	add_test(NAME simulate-inconsistent-input4 COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/simulateuser.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/inconsistent-input4.txt)

	# use zzuf to fuzzy the input script deterministically
	# compiler should not crash
	find_program(zzuf_FOUND zzuf)
	if (zzuf_FOUND)
		message(STATUS "zzuf executable found: " ${zzuf_FOUND})
		# set the number of test loops for the fuzzy test
		set(fuzzy_loop "500")
		# add tests
		add_test(NAME fuzzy-basic-arithmetic COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/basic-arithmetic.txt ${fuzzy_loop})
		add_test(NAME fuzzy-advanced-arithmetic COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/advanced-arithmetic.txt ${fuzzy_loop})
		add_test(NAME fuzzy-binary-op COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-op.txt ${fuzzy_loop})
		add_test(NAME fuzzy-shift-op COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-op.txt ${fuzzy_loop})
		add_test(NAME fuzzy-compound-assignment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/compound-assignments.txt ${fuzzy_loop})
		add_test(NAME fuzzy-binary-assignment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/binary-assignments.txt ${fuzzy_loop})
		add_test(NAME fuzzy-shift-assignment COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/shift-assignments.txt ${fuzzy_loop})
		add_test(NAME fuzzy-multiple-logic-op COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/multiple-logic-op.txt ${fuzzy_loop})
		add_test(NAME fuzzy-unicode COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/unicode.txt ${fuzzy_loop})
		add_test(NAME fuzzy-optimisation-binary-not COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/optimisation-binary-not.txt ${fuzzy_loop})
		add_test(NAME fuzzy-for-loop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/for-loop.txt ${fuzzy_loop})
		add_test(NAME fuzzy-while-loop COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/while-loop.txt ${fuzzy_loop})
		add_test(NAME fuzzy-when-conditional COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/when-conditional.txt ${fuzzy_loop})
		add_test(NAME fuzzy-comments COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/comments.txt ${fuzzy_loop})
		add_test(NAME fuzzy-subroutine COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fuzzyinput.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/subroutine.txt ${fuzzy_loop})
	else (zzuf_FOUND)
		message(WARNING "zzuf executable not found! Disabling fuzzy tests")
	endif (zzuf_FOUND)

	# use valgrind to test memory leaks inside the compiler
	if (valgrind_FOUND)
		# test all the .txt files inside the data directory
		add_test(NAME valgrind-compiler-all COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/valgrind.py "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/asebatest" ${CMAKE_CURRENT_SOURCE_DIR}/data/ )
	endif (valgrind_FOUND)
else (PYTHONINTERP_FOUND)
	message(WARNING "Python interpreter not found! Disabling advanced compiler tests")
endif (PYTHONINTERP_FOUND)
