aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_conditional_errors.sh
blob: 5a33e8c0a0161b68da76a1d5816c9c80d32207be (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
cat <<'EOF' > expected
main.c:2: expected '#endif', but got '<eof>'
EOF
test_compile_error <<'EOF'
#if 0
EOF

cat <<'EOF' > expected
main.c:3: expected '#endif', but got '<eof>'
EOF
test_compile_error <<'EOF'
#if 1
#else
EOF

cat <<'EOF' > expected
main.c:3: expected '#endif', but got '<eof>'
EOF
test_compile_error <<'EOF'
#if 1
#elif 1
EOF

cat <<'EOF' > expected
main.c:1: unexpected '#elif'; no corresponding '#if'*
EOF
test_compile_error <<'EOF'
#elif
#endif

int main() {}
EOF

cat <<'EOF' > expected
main.c:1: unexpected '#endif'; no corresponding '#if'*
EOF
test_compile_error <<'EOF'
#endif

int main() {}
EOF

cat <<'EOF' > expected
main.c:1: unexpected '#else'; no corresponding '#if'*
EOF
test_compile_error <<'EOF'
#else
#endif

int main() {}
EOF

cat <<'EOF' > expected
main.c:4: expected '#endif', but got '<eof>'
EOF
test_compile_error <<'EOF'
#if 1

int main() {}
EOF

cat <<'EOF' > a.h
#if 1
EOF
cat <<'EOF' > expected
./a.h:2: expected '#endif', but got '<eof>'
EOF
test_compile_error <<'EOF'
#include "a.h"
#endif

int main() {}
EOF