Skip to content

Commit b28aa7d

Browse files
committed
Add test for $goto
1 parent 81e5216 commit b28aa7d

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ neko.sln
3434
bin
3535
/extra/chocolatey/LICENSE
3636
/extra/chocolatey/*.zip
37-
/extra/chocolatey/*.nupkg
37+
/extra/chocolatey/*.nupkg
38+
39+
/tests/*.n

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,8 @@ add_test(NAME nekotools
782782
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
783783
)
784784

785+
add_subdirectory(tests)
786+
785787
#######################
786788

787789
# debian source packages

tests/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/)
2+
3+
add_test(NAME build_goto.n
4+
COMMAND nekoc -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/tests/ ${CMAKE_SOURCE_DIR}/tests/goto.neko
5+
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
6+
)
7+
8+
add_test(NAME run_goto.n
9+
COMMAND nekovm tests/goto.n
10+
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
11+
)
12+
13+
set_tests_properties(run_goto.n PROPERTIES
14+
PASS_REGULAR_EXPRESSION "startcontinue1continue2end"
15+
FIXTURES_SETUP build_goto.n
16+
)

tests/goto.neko

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$print("start");
2+
$goto(forward);
3+
4+
$print("skip");
5+
6+
backward:
7+
$print("continue2");
8+
$goto(end);
9+
10+
forward:
11+
$print("continue1");
12+
$goto(backward);
13+
14+
$print("skip");
15+
16+
end:
17+
$print("end");

0 commit comments

Comments
 (0)