diff options
Diffstat (limited to 'tests/conformance/3-expressions')
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_array_length.zc | 2 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_case_label.zc | 6 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_division.zc | 7 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_division_by_zero.zc | 4 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_division_rejected.zc | 4 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_local_const.zc | 11 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_local_const_rejected.zc | 7 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_modulo.zc | 6 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_modulo_rejected.zc | 4 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_neg_not_parens.zc | 2 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_precedence.zc (renamed from tests/conformance/3-expressions/const_expr_left_to_right.zc) | 5 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_xor.zc | 6 | ||||
| -rw-r--r-- | tests/conformance/3-expressions/const_expr_xor_rejected.zc | 4 |
13 files changed, 42 insertions, 26 deletions
diff --git a/tests/conformance/3-expressions/const_expr_array_length.zc b/tests/conformance/3-expressions/const_expr_array_length.zc index 07434a9..c6f11e3 100644 --- a/tests/conformance/3-expressions/const_expr_array_length.zc +++ b/tests/conformance/3-expressions/const_expr_array_length.zc @@ -1,4 +1,4 @@ -// expect: 10/ +// expect: 8/ include rt; void pn(int x) { rt.put_n(x); rt.put_c(10); } fn main() { diff --git a/tests/conformance/3-expressions/const_expr_case_label.zc b/tests/conformance/3-expressions/const_expr_case_label.zc index 3f1e781..0c76d4b 100644 --- a/tests/conformance/3-expressions/const_expr_case_label.zc +++ b/tests/conformance/3-expressions/const_expr_case_label.zc @@ -1,9 +1,9 @@ -// expect: nine/ +// expect: seven/ include rt; fn main() { - int k = 9; + int k = 7; switch (k) { - case 1 + 2 * 3: rt.put_s("nine"); + case 1 + 2 * 3: rt.put_s("seven"); default: rt.put_s("other"); } rt.put_c(10); diff --git a/tests/conformance/3-expressions/const_expr_division.zc b/tests/conformance/3-expressions/const_expr_division.zc new file mode 100644 index 0000000..90db20c --- /dev/null +++ b/tests/conformance/3-expressions/const_expr_division.zc @@ -0,0 +1,7 @@ +// expect: 3/-3/2/ +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +const Z = 6 / 2; +const N = -7 / 2; +const P = 1 + 6 / 3 * 2 - 3; +fn main() { pn(Z); pn(N + 0); pn(P); return 0; } diff --git a/tests/conformance/3-expressions/const_expr_division_by_zero.zc b/tests/conformance/3-expressions/const_expr_division_by_zero.zc new file mode 100644 index 0000000..f1011ff --- /dev/null +++ b/tests/conformance/3-expressions/const_expr_division_by_zero.zc @@ -0,0 +1,4 @@ +// expect error: division by zero in a constant expression +include rt; +const Z = 1 / (2 - 2); +fn main() { return 0; } diff --git a/tests/conformance/3-expressions/const_expr_division_rejected.zc b/tests/conformance/3-expressions/const_expr_division_rejected.zc deleted file mode 100644 index f095247..0000000 --- a/tests/conformance/3-expressions/const_expr_division_rejected.zc +++ /dev/null @@ -1,4 +0,0 @@ -// expect error: expected ';', found '/' -include rt; -const Z = 6 / 2; -fn main() { return 0; } diff --git a/tests/conformance/3-expressions/const_expr_local_const.zc b/tests/conformance/3-expressions/const_expr_local_const.zc new file mode 100644 index 0000000..46a8d55 --- /dev/null +++ b/tests/conformance/3-expressions/const_expr_local_const.zc @@ -0,0 +1,11 @@ +// expect: 5/11/7/ +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +fn main() { + const n = 5; + const m = n * 2 + 1; + int[m] a; + const int k = 7; + pn(n); pn(len(a)); switch (7) { case k: pn(k); } + return 0; +} diff --git a/tests/conformance/3-expressions/const_expr_local_const_rejected.zc b/tests/conformance/3-expressions/const_expr_local_const_rejected.zc deleted file mode 100644 index edab64e..0000000 --- a/tests/conformance/3-expressions/const_expr_local_const_rejected.zc +++ /dev/null @@ -1,7 +0,0 @@ -// expect error: expected a constant -include rt; -fn main() { - const n = 5; - int[n] a; - return 0; -} diff --git a/tests/conformance/3-expressions/const_expr_modulo.zc b/tests/conformance/3-expressions/const_expr_modulo.zc new file mode 100644 index 0000000..3f32f46 --- /dev/null +++ b/tests/conformance/3-expressions/const_expr_modulo.zc @@ -0,0 +1,6 @@ +// expect: 1/10/ +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +const Z = 7 % 2; +const Q = 1 + 20 % 7 * 3; +fn main() { pn(Z); pn(Q - 9); return 0; } diff --git a/tests/conformance/3-expressions/const_expr_modulo_rejected.zc b/tests/conformance/3-expressions/const_expr_modulo_rejected.zc deleted file mode 100644 index 4c54ffe..0000000 --- a/tests/conformance/3-expressions/const_expr_modulo_rejected.zc +++ /dev/null @@ -1,4 +0,0 @@ -// expect error: zc: line 3: -include rt; -const Z = 7 % 2; -fn main() { return 0; } diff --git a/tests/conformance/3-expressions/const_expr_neg_not_parens.zc b/tests/conformance/3-expressions/const_expr_neg_not_parens.zc index 6e96bdc..714990a 100644 --- a/tests/conformance/3-expressions/const_expr_neg_not_parens.zc +++ b/tests/conformance/3-expressions/const_expr_neg_not_parens.zc @@ -1,4 +1,4 @@ -// expect: -3/-6/-1/24/ +// expect: -3/-4/-1/24/ include rt; void pn(int x) { rt.put_n(x); rt.put_c(10); } const A = -3; diff --git a/tests/conformance/3-expressions/const_expr_left_to_right.zc b/tests/conformance/3-expressions/const_expr_precedence.zc index 68e26ab..c173959 100644 --- a/tests/conformance/3-expressions/const_expr_left_to_right.zc +++ b/tests/conformance/3-expressions/const_expr_precedence.zc @@ -1,8 +1,9 @@ -// expect: 9/5/7/255/ +// expect: 7/5/7/255/16/ include rt; void pn(int x) { rt.put_n(x); rt.put_c(10); } const X = 1 + 2 * 3; const Y = 10 - 2 - 3; const V = 1 | 2 + 4; const W = ~0 & 255; -fn main() { pn(X); pn(Y); pn(V); pn(W); return 0; } +const S = 1 + 3 << 1 + 1 >> 1 - 1 | 6 & 2; +fn main() { pn(X); pn(Y); pn(V); pn(W); pn(S - 2); return 0; } diff --git a/tests/conformance/3-expressions/const_expr_xor.zc b/tests/conformance/3-expressions/const_expr_xor.zc new file mode 100644 index 0000000..30ca0a7 --- /dev/null +++ b/tests/conformance/3-expressions/const_expr_xor.zc @@ -0,0 +1,6 @@ +// expect: 5/7/ +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +const Z = 7 ^ 2; +const Q = 1 ^ 2 | 4 & 4; +fn main() { pn(Z); pn(Q); return 0; } diff --git a/tests/conformance/3-expressions/const_expr_xor_rejected.zc b/tests/conformance/3-expressions/const_expr_xor_rejected.zc deleted file mode 100644 index eb1ad25..0000000 --- a/tests/conformance/3-expressions/const_expr_xor_rejected.zc +++ /dev/null @@ -1,4 +0,0 @@ -// expect error: zc: line 3: -include rt; -const Z = 7 ^ 2; -fn main() { return 0; } |
