aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/global_transfer.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/global_transfer.zc')
-rw-r--r--tests/programs/global_transfer.zc16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/programs/global_transfer.zc b/tests/programs/global_transfer.zc
new file mode 100644
index 0000000..b36ad73
--- /dev/null
+++ b/tests/programs/global_transfer.zc
@@ -0,0 +1,16 @@
+namespace;
+include rt;
+
+// an m or u owner stored into a global is handed over by an automatic u transfer
+let g;
+let h;
+int*.u make() { int* b = rt.new(int); *b = 9; return u*b; }
+fn main() {
+ let x = rt.new(1);
+ x[0] = 5;
+ g = x;
+ let y = make();
+ h = y;
+ rt.put_n(g[0]); rt.put_c(32); rt.put_n(h[0]); rt.put_c(10);
+ return 0;
+}