-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·71 lines (60 loc) · 2.24 KB
/
test.sh
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
#!/bin/bash
# Reference interpreter path
wspace=wspace
make all || exit
function compare() {
binary="$1"
program="$2"
echo "$binary:"
diff <("build/$binary") <("$wspace" "programs/$program")
}
function compare_arg() {
binary="$1"
program="$2"
args="$3"
echo "$binary $args:"
diff <(echo "$args" | "build/$binary") <(echo "$args" | "$wspace" "programs/$program")
}
function compare_file() {
binary="$1"
program="$2"
file="$3"
echo "$binary $file:"
diff <("build/$binary" < "$file") <("$wspace" "programs/$program" < "$file")
}
function compare_head() {
binary="$1"
program="$2"
n="$3"
echo "$binary $n:"
diff <("build/$binary" | head -n "$n") <("$wspace" "programs/$program" | head -n "$n")
}
compare 99_bottles 99_bottles.out.ws
compare ascii ascii.out.ws
compare ascii4 ascii4.out.ws
compare_arg collatz collatz.out.ws 5
compare_arg collatz collatz.out.ws 10
compare_arg collatz collatz.out.ws 100
compare_arg factorial factorial.out.ws 10
compare fizz_buzz fizz_buzz.out.ws
compare hello_world hello_world.ws
compare_arg pi pi.out.ws 5
compare_arg rosetta/add rosetta/add.ws "42
314"
compare_head rosetta/binary rosetta/binary.ws 100
compare_head rosetta/fib rosetta/fib.ws 47
compare_arg rosetta/fibrec rosetta/fibrec.ws 20
compare rosetta/fizz_buzz rosetta/fizz_buzz.ws
compare rosetta/harshad rosetta/harshad.ws
compare_head rosetta/octal rosetta/octal.ws 100
compare_file rosetta/shell_sort rosetta/shell_sort.ws programs/rosetta/shell_sort.in
compare rosetta/term_cursor rosetta/term_cursor.ws
compare rosetta/while rosetta/while.ws
compare rosetta/langstons_ant rosetta/langstons_ant.ws
compare_file rosetta/freq rosetta/freq.ws programs/rosetta/freq.ws
printf '\0' > nul
cat programs/interpret.out.ws nul programs/hello_world.ws nul > tmp.ws
echo "hello_world:"
time build/interpret < tmp.ws &&
time "$wspace" programs/interpret.out.ws < tmp.ws
rm tmp.ws nul