-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.jl
53 lines (49 loc) · 1.27 KB
/
test.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# test.jl: Used to run integration tests on jlox
struct IntegTest
path::String
expected_res::String
end
integration_tests = [
IntegTest("empty_file.lox", ""),
IntegTest("precedence.lox", """14
8
4
0
true
true
true
true
0
0
0
0
4
"""),
IntegTest("unexpected_character.lox", "[line 3] Error: Unexpected character '|'\n"),
IntegTest("assignment/associativity.lox","""c
c
c
"""),
IntegTest("assignment/global.lox", """before
after
arg
arg
"""),
IntegTest("assignment/grouping.lox", "[line 2] Error: Error at '=': Invalid assignment target.\n"),
IntegTest("assignment/infix_operator.lox", "[line 3] Error: Error at '=': Invalid assignment target."),
IntegTest("assignment/prefix_operator.lox", "[line 2] Error: Error at '=': Invalid assignment target."),
IntegTest("assignment/syntax.lox", "var\nvar\n")
]
if size(ARGS)[1] != 1
println("Usage: test.jl <test folder>")
else
test_folder = ARGS[1]
for test in integration_tests
result = read(ignorestatus(`julia jlox.jl $test_folder/$(test.path)`), String)
if result == test.expected_res
println("$(test.path): OK")
else
println("$(test.path): KO")
end
end
end