1 // Test datatype inheritance
4 #include <AD/gc/gcobject.h>
10 class C1 : public GCObject
14 ~C1() { ++destroyed; }
15 virtual void trace(GC *) { ++traced; }
26 datatype TYPE1 : collectable public C1 :: collectable rewrite printable =
29 datatype TYPE2 : collectable public C1 :: collectable rewrite printable =
34 datatype TYPE3<T> : collectable public C1 :: collectable rewrite printable =
38 datatype TYPE4<T> : collectable public C1 :: collectable rewrite printable =
43 datatype TYPE5<T> : collectable public C2<T> :: collectable rewrite printable =
47 datatype TYPE6<T> : collectable public C2<T> :: collectable rewrite printable =
52 instantiate datatype TYPE1, TYPE2, TYPE3<int>,
53 TYPE4<int>, TYPE5<int>, TYPE6<int>,
54 TYPE5<TYPE1>, TYPE6<TYPE1>,
55 TYPE5<TYPE5<TYPE1> >, TYPE6<TYPE6<TYPE1> >
59 { GC::get_default_gc().set_finalization(true);
60 for (int i = 0; i < 10000; i++)
63 TYPE3<int> t3 = CON3a(1);
64 TYPE4<int> t4 = CON4a(0);
65 TYPE5<int> t5 = CON5a(1,t1);
66 TYPE6<int> t6 = CON6a(1,t1);
67 TYPE5<TYPE1> t7 = CON5a(t1,t1);
68 TYPE6<TYPE1> t8 = CON6a(t1,t1);
71 cout << t1 << t2 << t3 << t4 << t5 << t6 << t7 << t8 << '\n';
73 cout << "Created = " << created << endl
74 << "Destroyed = " << destroyed << endl
75 << "Traced = " << traced << endl