aboutsummaryrefslogtreecommitdiff
path: root/tests/programs
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 09:33:46 +0000
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 09:33:46 +0000
commit04a92de49a40f4d3e58b39d3ad4549184afbeebc (patch)
treee37da74b5ccec23c6792a1c2eb230812ee42c307 /tests/programs
parentMerge std library docs (diff)
parentconstants inside structs, and typo suggestions for fields and static members (diff)
Merge branch 'worktree-agent-a96a10dc1489688ea' into ccr-0054c02e-dfdvnd
Diffstat (limited to 'tests/programs')
-rw-r--r--tests/programs/struct_const.zc28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/programs/struct_const.zc b/tests/programs/struct_const.zc
new file mode 100644
index 0000000..59af8fd
--- /dev/null
+++ b/tests/programs/struct_const.zc
@@ -0,0 +1,28 @@
+namespace;
+include rt;
+
+struct Text {
+ const MAX = 24, MIN = 1;
+ const int WIDE = MAX * 2;
+ int len, tag;
+ static int top() { return MAX; }
+ static int span() { return MAX - MIN; }
+ int room() { return MAX - this.len; }
+ int total() { int[MIN + 2] a; a[2] = WIDE; return a[2] + this.tag; }
+}
+
+const MAX = 99;
+
+int main() {
+ Text t;
+ t.len = 5; t.tag = 7;
+ rt.put_n(Text.MAX); rt.put_c(32);
+ rt.put_n(Text.MIN + Text.WIDE); rt.put_c(32);
+ rt.put_n(Text.top()); rt.put_c(32);
+ rt.put_n(Text.span()); rt.put_c(32);
+ rt.put_n(t.room()); rt.put_c(32);
+ rt.put_n(t.total()); rt.put_c(32);
+ rt.put_n(t.len + t.tag); rt.put_c(32);
+ rt.put_n(MAX); rt.put_c(10);
+ return 0;
+}