From b28aa7d66e59127132709960702c410ea59f9531 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 16 Feb 2025 03:04:43 +0000 Subject: [PATCH] Add test for $goto --- .gitignore | 4 +++- CMakeLists.txt | 2 ++ tests/CMakeLists.txt | 16 ++++++++++++++++ tests/goto.neko | 17 +++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/goto.neko diff --git a/.gitignore b/.gitignore index 87dc01bf..911f0acc 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,6 @@ neko.sln bin /extra/chocolatey/LICENSE /extra/chocolatey/*.zip -/extra/chocolatey/*.nupkg \ No newline at end of file +/extra/chocolatey/*.nupkg + +/tests/*.n diff --git a/CMakeLists.txt b/CMakeLists.txt index 48cdc812..29db11a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -782,6 +782,8 @@ add_test(NAME nekotools WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) +add_subdirectory(tests) + ####################### # debian source packages diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..ae988bc5 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,16 @@ +file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/) + +add_test(NAME build_goto.n + COMMAND nekoc -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/ ${CMAKE_SOURCE_DIR}/tests/goto.neko + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} +) + +add_test(NAME run_goto.n + COMMAND nekovm tests/goto.n + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} +) + +set_tests_properties(run_goto.n PROPERTIES + PASS_REGULAR_EXPRESSION "startcontinue1continue2end" + FIXTURES_SETUP build_goto.n +) diff --git a/tests/goto.neko b/tests/goto.neko new file mode 100644 index 00000000..2fb41c78 --- /dev/null +++ b/tests/goto.neko @@ -0,0 +1,17 @@ +$print("start"); +$goto(forward); + +$print("skip"); + +backward: +$print("continue2"); +$goto(end); + +forward: +$print("continue1"); +$goto(backward); + +$print("skip"); + +end: +$print("end");