-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
72 lines (63 loc) · 1.99 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
72
# we now run all programs of main.ext in sequence and test
# testing general runner ./x <file> args
expected=("-1" "4" "1" "2" "295.33612" "158" "1.5849625007212" "0.9160792412167597" "52" "103" "1" "-13.6434*" "1.618034" "55" "3.14*" "0.098*" "5" "0.8346" "39.85" "6.31" "6.6947" "69" "0.6620042" "0" "40.00" "-74" "9" "0.567143*" "42.9387*")
# py, f90
exts=("c" "rb" "js" "ts" "hs" "rs" "php" "go" "sc" "lua" "f90" "py" "ml" "kt" "cpp" "exs" "swift" "java" "jl" "cob" "scpt" "sh" "r" "m" "dart" "zig" "mojo" "lisp" "groovy")
current="15"
iter=0
# current="40.00"
# skip=dart
skip=false
for file in ${exts[@]}; do
# # if skip is not = false, set to false
if [ "$skip" != false ]; then
if [ "$file" == "$skip" ]; then
skip=false
continue
fi
continue;
fi
filename="test/main.$file"
printf "\033[K$file $current\r"
current=$(./x $filename $current)
if [ $? -ne 0 ]; then
echo "Error: $filename"
exit 1
fi
current=$(echo $current | xargs)
# if expected has a * it's gonna be a regex match
if [[ ${expected[$iter]} == *"*"* ]]; then
if [[ ! $current =~ ${expected[$iter]} ]]; then
echo "$file failed with $filename"
echo "Approx: ${expected[$iter]}"
echo "Actual: $current"
exit 1
fi
else
if [ "$current" != "${expected[$iter]}" ]; then
echo "$file failed with $filename"
echo "Expect: ${expected[$iter]}"
echo "Actual: $current"
exit 1
fi
fi
iter=$((iter+1))
done
echo "\033[32m Compile tests passed \033[0m"
# converage
implemented=($(grep "==\ \*" ./x | grep if | awk '{print $5}' | sed 's/\*\.//' |grep -vE '\*|\$'))
# check if all implemented are in exts
for ext in ${exts[@]}; do
if [[ ! " ${implemented[@]} " =~ " $ext " ]]; then
echo "Not implemented: $ext"
exit 1
fi
done
implemented=(${implemented[@]/applescript/})
for ext in ${implemented[@]}; do
if [[ ! " ${exts[@]} " =~ " $ext " ]]; then
echo "Not in exts: $ext"
exit 1
fi
done
echo "\033[32m Coverage tests passed \033[0m"