Changeset 803
- Timestamp:
- 12/13/10 02:51:45 (14 years ago)
- Files:
-
- trunk/test/runnable/newdel.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/runnable/newdel.d
r575 r803 1 1 // PERMUTE_ARGS: 2 2 3 3 import std.c.stdio; 4 4 import std.c.stdlib; 5 5 6 6 /*********************************************/ 7 7 8 8 class Foo 9 9 { 10 10 static uint flags; 11 11 12 new( uint sz, int x)12 new(size_t sz, int x) 13 13 { void* p; 14 14 15 15 printf("Foo.new(sz = %d, x = %d)\n", sz, x); 16 16 assert(sz == Foo.classinfo.init.length); 17 17 assert(x == 5); 18 18 19 19 p = std.c.stdlib.malloc(sz); 20 20 flags |= 4; 21 21 return p; 22 22 } 23 23 24 24 this() 25 25 { 26 26 printf("this() %p\n", this); 27 27 a = 36; 28 28 } 29 29 30 30 ~this() 31 31 { 32 32 printf("~this() %p\n", this); … … 50 50 { 51 51 Foo f; 52 52 53 53 f = new(5) Foo; 54 54 assert(f.a == 36); 55 55 assert(f.b == 4); 56 56 assert(f.d == 56); 57 57 assert(Foo.flags == 4); 58 58 59 59 delete f; 60 60 assert(Foo.flags == 7); 61 61 } 62 62 63 63 64 64 /*********************************************/ 65 65 66 66 struct Foo2 67 67 { 68 68 static uint flags; 69 69 70 new( uint sz, int x)70 new(size_t sz, int x) 71 71 { void* p; 72 72 73 73 printf("Foo2.new(sz = %d, x = %d)\n", sz, x); 74 74 assert(sz == Foo2.sizeof); 75 75 assert(x == 5); 76 76 77 77 p = std.c.stdlib.malloc(sz); 78 78 flags |= 4; 79 79 return p; 80 80 } 81 81 82 82 delete(void *p) 83 83 { 84 84 printf("p = %p\n", p); 85 85 flags |= 2; 86 86 std.c.stdlib.free(p); 87 87 } 88 88 } 89 89 90 90 void test2()
