diff options
| author | 2026-10-14 16:49:25 +0330 | |
|---|---|---|
| committer | 2026-10-14 16:49:40 +0330 | |
| commit | aadfdb87fdb42b42434358e643da8c98dd4647b2 (patch) | |
| tree | 27b8eb749b600c44fb8f1159cfcce15cdad30c5e /tests/conformance | |
| parent | enum: a member is defined as soon as it is declared, so later values can name... (diff) | |
bool: a value stored into a bool is normalised to 0 or 1 (appendix b.2.6)
Diffstat (limited to 'tests/conformance')
| -rw-r--r-- | tests/conformance/2-types/bool_normalises.zc | 7 | ||||
| -rw-r--r-- | tests/conformance/2-types/typecheck_number_kinds_convert.zc | 3 | ||||
| -rw-r--r-- | tests/conformance/known.txt | 1 |
3 files changed, 9 insertions, 2 deletions
diff --git a/tests/conformance/2-types/bool_normalises.zc b/tests/conformance/2-types/bool_normalises.zc new file mode 100644 index 0000000..c734fc5 --- /dev/null +++ b/tests/conformance/2-types/bool_normalises.zc @@ -0,0 +1,7 @@ +// expect: 1/1/0/1/0/1/1/ +// spec 2.1: a value stored in a bool is 0 or 1; any nonzero value becomes 1 +include rt; +void pn(int x) { rt.put_n(x); rt.put_c(10); } +bool id(bool x) { return x; } +fn main() { bool b = 5; pn(b); pn(b == 1); pn(!b); b = -7; pn(b); b = 0; pn(b); pn(id(42)); bool f = 0.5; pn(f); return 0; } +// zc0: skip diff --git a/tests/conformance/2-types/typecheck_number_kinds_convert.zc b/tests/conformance/2-types/typecheck_number_kinds_convert.zc index 9c3d76e..f41b42d 100644 --- a/tests/conformance/2-types/typecheck_number_kinds_convert.zc +++ b/tests/conformance/2-types/typecheck_number_kinds_convert.zc @@ -1,4 +1,5 @@ -// expect: 44/ +// expect: 1/ +// spec 2.1, 2.9: numbers convert freely; the bool normalises 44 to 1 include rt; typecheck on; void pn(int x) { rt.put_n(x); rt.put_c(10); } diff --git a/tests/conformance/known.txt b/tests/conformance/known.txt index 723098a..8550c07 100644 --- a/tests/conformance/known.txt +++ b/tests/conformance/known.txt @@ -3,7 +3,6 @@ # appendix b.2.8 (a global named in an initializer is its address) is documented behavior per 5.3.2 and 3.14.2: no entry 4-statements/o3_outside_function_ordinary_block.zc zy c top-level o3 { } is rejected; spec 4.10.2 says it is an ordinary block 5-declarations/fn_prototype_unnamed_params_b13.zc zy c spec 5.2.1 says prototype parameter names are required, and a type name alone is read as an untyped parameter of that name (paramstart); b.2.13 is a spec choice, not fixed -9-appendix-b/b2_06_bool_normalises.zc zy c appendix b.2.6 confirmed, but spec 2.1 documents bool as a number that is not normalised 9-appendix-b/b2_10_recovery_hides_errors.zc zy c appendix b.2.10 confirmed; by design per 8.2 9-appendix-b/b2_11_unterminated_comment.zc zy c appendix b.2.11 confirmed, but spec 1.2.2 says an unclosed block comment is not an error 9-appendix-b/b2_12_as_int_star.zc zy c appendix b.2.12 confirmed, but spec 3.2.3 documents it (parenthesise) |
