aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/6-ownership/drop_forms.zc
diff options
context:
space:
mode:
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