-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtests.sh
More file actions
executable file
·75 lines (63 loc) · 1.69 KB
/
Copy pathtests.sh
File metadata and controls
executable file
·75 lines (63 loc) · 1.69 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Build the project
make
lex_test_cases=(
"("
")"
"()"
"hello"
"123"
'"hello world"'
"(+ 1 2)"
"(define x 10)"
'("hello" "world")'
" ( ) "
" ("
)
# Expected outputs for each test case.
# Please fill these in with the correct expected output for each test case.
# For multi-line output, use newline characters (
lex_expected_outputs=(
'TOKEN_LPAREN ( '
'TOKEN_RPAREN ) '
'TOKEN_LPAREN ( TOKEN_RPAREN ) '
'TOKEN_SYMBOL hello '
'TOKEN_NUMBER 123 '
"TOKEN_STRING hello world "
'TOKEN_LPAREN ( TOKEN_SYMBOL + TOKEN_NUMBER 1 TOKEN_NUMBER 2 TOKEN_RPAREN ) '
'TOKEN_LPAREN ( TOKEN_SYMBOL define TOKEN_SYMBOL x TOKEN_NUMBER 10 TOKEN_RPAREN ) '
'TOKEN_LPAREN ( TOKEN_STRING hello TOKEN_STRING world TOKEN_RPAREN ) '
'TOKEN_LPAREN ( TOKEN_RPAREN ) '
'TOKEN_LPAREN ( '
)
# Run tests
i=0
total_tests=${#lex_test_cases[@]}
passed_tests=0
failed_tests=()
for test_case in "${lex_test_cases[@]}"; do
output=$(./build/pnd -c "$test_case")
expected_output="${lex_expected_outputs[$i]}"
if [ "$output" == "$expected_output" ]; then
passed_tests=$((passed_tests + 1))
else
failed_tests+=($((i+1)))
fi
i=$((i+1))
done
echo "Summary: $passed_tests / $total_tests tests passed."
if [ ${#failed_tests[@]} -ne 0 ]; then
echo "Failed tests: ${failed_tests[*]}"
echo "Details of failed tests:"
for test_num in "${failed_tests[@]}"; do
index=$((test_num - 1))
echo "------------------------"
echo "Test $test_num: ${lex_test_cases[$index]}"
echo "Expected:"
echo -e "${lex_expected_outputs[$index]}"
echo "Got:"
echo -e "$(./build/pnd -c "${lex_test_cases[$index]}")"
done
exit 1
fi
exit 0