aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/6-ownership/drop_forms.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 23:10:49 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 23:10:49 +0330
commit8af3174b04f18d858653ad70669dced71f5eaa99 (patch)
tree741ad2afd7cf3b39be763d17eea6a8c01c9101e7 /tests/conformance/6-ownership/drop_forms.zc
parentdocs: destructors: clear drop entry and bits on free; planned reuse test (diff)
destructors: heap(v), drop(v, f) / v.drop(f) / v.drop = f, struct drop methods, collector drops after the sweep (once, resurrection), freed blocks forget their drop, temporaries drop at statement end with a hint, actor send check; o3: no collection inside a region (pending until the outermost exit), no drops set or ended inside o3; spec 3.11.6, 4.10.3-4, 6.15
Diffstat (limited to 'tests/conformance/6-ownership/drop_forms.zc')
-rw-r--r--tests/conformance/6-ownership/drop_forms.zc14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/conformance/6-ownership/drop_forms.zc b/tests/conformance/6-ownership/drop_forms.zc
new file mode 100644
index 0000000..e9e4c07
--- /dev/null
+++ b/tests/conformance/6-ownership/drop_forms.zc
@@ -0,0 +1,14 @@
+// expect: 15i'm free as a bird! 15/body y7 x g
+// destructors 2: drop(v, f) and v.drop(f) return v, v.drop = f; is a statement; this is the value. the spec example drops its temporary at the end of the statement
+include rt;
+fn main() {
+ rt.put_n(*heap(15).drop(fn() { rt.put_s("i'm free as a bird! "); rt.put_n(*this); }));
+ rt.put_c(10);
+ let g = drop(heap(1), fn() { rt.put_s("g "); });
+ let x = rt.new(int).drop(fn() { rt.put_s("x "); });
+ let y = rt.new(int); y.drop = fn() { rt.put_s("y"); rt.put_n(*this); rt.put_s(" "); };
+ *y = 7;
+ rt.put_s("body ");
+ return 0;
+}
+// zc0: skip