aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 17:00:26 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 17:00:26 +0330
commitff16b77d03c997ac4214b5a440c83cd849be7a2d (patch)
tree159dd6fc86dbb3dfc0381f109681751085011c77 /tests
parentlen: len on a char* is an error with typecheck off too (appendix b.2.14) (diff)
parentmerge work/xref: zc0 u*d redo and follow-ups (diff)
Merge branch 'main' into work/spec
Diffstat (limited to 'tests')
-rw-r--r--tests/conformance/known.txt1
-rw-r--r--tests/programs/zc0embed_write.zc9
-rwxr-xr-xtests/test.sh1
3 files changed, 10 insertions, 1 deletions
diff --git a/tests/conformance/known.txt b/tests/conformance/known.txt
index 8e6ea97..8eeb0d3 100644
--- a/tests/conformance/known.txt
+++ b/tests/conformance/known.txt
@@ -5,7 +5,6 @@
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_15_duplicate_case.zc zy c appendix b.2.15 confirmed; 4.7.2 says duplicates are allowed
9-appendix-b/b2_16_local_const_in_const_expr.zc zy c appendix b.2.16 confirmed; 3.14.2 documents it
-1-source/ident_tags_as_variables_glued_star.zc zc0 b u*d with visible u and d is read as a recast (no code); zy follows 1.6.3
2-types/conv_argument_and_return.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a)
2-types/conv_assignment_to_float.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a)
2-types/conv_f32_rounds.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a)
diff --git a/tests/programs/zc0embed_write.zc b/tests/programs/zc0embed_write.zc
new file mode 100644
index 0000000..09686b5
--- /dev/null
+++ b/tests/programs/zc0embed_write.zc
@@ -0,0 +1,9 @@
+include rt;
+// zc0 keeps a local embed array in the code, so it refuses a store into one; the
+// resident compiler accepts it (prints 9). tests/test.sh checks zc0's message.
+fn main() {
+ embed "tests/data/embed/bytes.bin" as u8[] b;
+ b[1] = 9;
+ rt.put_n(b[1]); rt.put_c(10);
+ return 0;
+}
diff --git a/tests/test.sh b/tests/test.sh
index cdce083..bc199e1 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -82,6 +82,7 @@ GI="-Isrc/core -I$MAP --embed-dir=$T/s1"
# it, and the run-only and bare-metal sections read it as the reference.
$CC -pthread -O2 -w -fwrapv -DJTYPE=int src/core/core.c src/core/io_linux.c $GI -o $T/zy || exit 1
chk "$($T/zc0 < tests/programs/zc0typed.zc | md5sum)" "$($T/zc0 < tests/programs/zc0plain.zc | md5sum)" "zc0 reads types and throws them away: typed and plain sources give one image"
+case "$($T/zc0 < tests/programs/zc0embed_write.zc 2>&1 >/dev/null)" in *"line 6: a local embed array is part of the code"*) chk 1 1 "zc0 refuses a store into a local embed array";; *) chk 0 1 "zc0 refuses a store into a local embed array";; esac
for n in $SECS; do
mkdir -p $ROOT/$n