Skip to content

Commit

Permalink
Add test for $goto
Browse files Browse the repository at this point in the history
  • Loading branch information
tobil4sk committed Feb 16, 2025
1 parent 81e5216 commit b28aa7d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ neko.sln
bin
/extra/chocolatey/LICENSE
/extra/chocolatey/*.zip
/extra/chocolatey/*.nupkg
/extra/chocolatey/*.nupkg

/tests/*.n
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ add_test(NAME nekotools
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)

add_subdirectory(tests)

#######################

# debian source packages
Expand Down
16 changes: 16 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
17 changes: 17 additions & 0 deletions tests/goto.neko
Original file line number Diff line number Diff line change
@@ -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");

0 comments on commit b28aa7d

Please # to comment.