Debian Codegraph @

gcc/testsuite/gdc.test/runnable/newdel.d

raw
1 // PERMUTE_ARGS:
2
3 import core.stdc.stdio;
4 import core.stdc.stdlib;
5
6 /*********************************************/
7
8 class Foo
9 {
10 static uint flags;
11
12 this()
13 {
14 printf("this() %p\n", this);
15 a = 36;
16 }
17
18 ~this()
19 {
20 printf("~this() %p\n", this);
21 a = -5;
22 flags |= 1;
23 }
24
25 int a = 3;
26 int b = 4;
27 int d = 56;
28 }
29
30 void test1()
31 {
32 Foo f;
33
34 f = new Foo();
35 assert(f.a == 36);
36 assert(f.b == 4);
37 assert(f.d == 56);
38 assert(Foo.flags == 0);
39
40 destroy(f);
41 assert(Foo.flags == 1);
42 }
43
44 /*********************************************/
45 // delete is no longer a keyword and can be used as an identifier
46
47 enum E
48 {
49 add, delete
50 }
51
52 E delete()
53 {
54 return E.delete;
55 }
56
57 void test2()
58 {
59 assert(delete() == E.delete);
60 }
61
62 /*********************************************/
63
64 int main()
65 {
66 test1();
67 test2();
68
69 printf("Success\n");
70 return 0;
71 }