diff --git a/.gitignore b/.gitignore index 87dc01bf9..911f0acc7 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 48cdc8122..29db11a50 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/boot/nekoc.n b/boot/nekoc.n index 6bc00b5c0..2a75a9f62 100644 Binary files a/boot/nekoc.n and b/boot/nekoc.n differ diff --git a/boot/nekoml.n b/boot/nekoml.n index 7579df68f..42a465c57 100644 Binary files a/boot/nekoml.n and b/boot/nekoml.n differ diff --git a/src/neko/Compile.nml b/src/neko/Compile.nml index ecba7150f..722e3a77e 100644 --- a/src/neko/Compile.nml +++ b/src/neko/Compile.nml @@ -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(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..ae988bc5f --- /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 000000000..2fb41c78e --- /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");