aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/genmeth.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/genmeth.zc')
-rw-r--r--tests/programs/genmeth.zc17
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/programs/genmeth.zc b/tests/programs/genmeth.zc
index 305c55c..73f0ced 100644
--- a/tests/programs/genmeth.zc
+++ b/tests/programs/genmeth.zc
@@ -1,11 +1,14 @@
+namespace;
+include rt;
+
// methods on generic structs: each set of type arguments gets its own copy
struct pt { int x, y; };
struct table<K, V> {
int n; K* keys; V* vals;
fn init(int cap) {
this.n = 0;
- this.keys = new(K, cap) as K*;
- this.vals = new(V, cap) as V*;
+ this.keys = rt.new(K, cap) as K*;
+ this.vals = rt.new(V, cap) as V*;
return 0;
}
fn put(K k, V v) {
@@ -25,12 +28,12 @@ int main() {
table<int, int> a;
a.init(8);
a.put(1, 10); a.put(2, 20); a.put(3, 30);
- put_n(a.n); put_c(' '); put_n(a.total()); put_c(' '); put_n(a.width()); put_c(' ');
- table<pt, int>* b = new(table<pt, int>);
+ rt.put_n(a.n); rt.put_c(' '); rt.put_n(a.total()); rt.put_c(' '); rt.put_n(a.width()); rt.put_c(' ');
+ table<pt, int>* b = rt.new(table<pt, int>);
b.init(4);
- put_n(b.width()); put_c(' ');
- table<int, pt>* c = new(table<int, pt>);
+ rt.put_n(b.width()); rt.put_c(' ');
+ table<int, pt>* c = rt.new(table<int, pt>);
c.init(4);
- put_n(c.width()); put_c(10);
+ rt.put_n(c.width()); rt.put_c(10);
return 0;
}