aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/methodown.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/methodown.zc')
-rw-r--r--tests/programs/methodown.zc15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/programs/methodown.zc b/tests/programs/methodown.zc
new file mode 100644
index 0000000..98ba146
--- /dev/null
+++ b/tests/programs/methodown.zc
@@ -0,0 +1,15 @@
+// a struct method can return an owned object: its header declares the .u return
+struct Node { int v; }
+struct Maker {
+ static Node*.u make(int n) { Node* p = new(Node); p.v = n; return u*p; }
+}
+Node*.u mk(int n) { Node* p = new(Node); p.v = n; return u*p; }
+int main() {
+ Node*.u a = Maker.make(7);
+ put_n(a.v); put_c(32);
+ free(d*a);
+ Node*.u b = mk(9);
+ put_n(b.v); put_c(10);
+ free(d*b);
+ return 0;
+}