Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Binary file modified boot/nekoc.n
Binary file not shown.
Binary file modified boot/nekoml.n
Binary file not shown.
2 changes: 1 addition & 1 deletion src/neko/Compile.nml
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ function rec compile_builtin(ctx,tail,b,el,p) {
ctx.stack := os;
match l.lpos {
| None -> l.lwait := jmp ctx :: l.lwait
| Some p -> write ctx (Jump p)
| Some p -> goto ctx p
};
List.iter (function(t) {
t();
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");