blob: 2c6ac72853bf6664b70d15d50ca8c5ea5fe42054 (
plain)
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
76
77
78
79
80
|
# --version
expected="ducc v0.3.0"
if [[ "$("$ducc" --version)" != "$expected" ]]; then
echo "invalid output" >&2
exit 1
fi
# assembly output
cat > foo.c <<'EOF'
int main() {}
EOF
"$ducc" -o bar.s foo.c
if [[ $? -ne 0 ]]; then
exit 1
fi
gcc -o a.out bar.s
./a.out "$@"
exit_code=$?
if [[ $exit_code -ne 0 ]]; then
echo "invalid exit code: $exit_code" >&2
exit 1
fi
# argc/argv
cat <<'EOF' > expected
argc = 4
argv[1] = hoge
argv[2] = piyo
argv[3] = fuga
EOF
test_diff hoge piyo fuga<<'EOF'
int printf();
int main(int argc, char** argv) {
printf("argc = %d\n", argc);
int i;
for (i = 1; i < argc; ++i) {
printf("argv[%d] = %s\n", i, argv[i]);
}
return 0;
}
EOF
# compile errors
# TODO: report as "undefined function"
cat <<'EOF' > expected
main.c:2: undefined variable: f
EOF
test_compile_error <<'EOF'
int main() {
f();
}
EOF
# TODO: improve error message
# cat <<'EOF' > expected
# main.c:1: expected ';' or '{', but got '}'
# EOF
cat <<'EOF' > expected
main.c:1: expected ';', but got '}'
EOF
test_compile_error <<'EOF'
int main() }
EOF
# TODO: improve error message
# cat <<'EOF' > expected
# main.c:1: expected ';' or '{', but got '}'
# EOF
cat <<'EOF' > expected
main.c:1: expected ';', but got '123'
EOF
test_compile_error <<'EOF'
int main() 123
EOF
|