annotate run/delete_01.d @ 1576:b3e16c86558e

[Issue 1398] New: GDC doesn't generate correct code <mariusmuja@gmail.com> 2007-08-04 http://d.puremagic.com/issues/show_bug.cgi?id=1398
author thomask
date Thu, 21 Feb 2008 15:20:08 +0000
parents f07f77e65213
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
379
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
1 // $HeadURL$
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
2 // $Date$
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
3 // $Author$
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
4
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
5 // @WARNING@ direct usage of Phobos's GC
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
6
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
7 module dstress.run.delete_01;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
8 import std.gc;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
9
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
10 int status;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
11
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
12 class MyClass{
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
13 ~this(){
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
14 assert(status==0);
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
15 status--;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
16 }
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
17
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
18 delete(void* p){
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
19 assert(status==-1);
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
20 status--;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
21 }
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
22 }
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
23
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
24 void test(){
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
25 MyClass c=new MyClass();
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
26 assert(status==0);
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
27 delete c;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
28 }
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
29
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
30 int main(){
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
31 test();
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
32 assert(status<=-1);
380
f07f77e65213 added std.gc.minimze call to std.gc.fullCollect
thomask
parents: 379
diff changeset
33 std.gc.fullCollect();
f07f77e65213 added std.gc.minimze call to std.gc.fullCollect
thomask
parents: 379
diff changeset
34 std.gc.minimize();
379
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
35 assert(status==-2);
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
36 return 0;
60b4ba82210e added tests for custom deallocators
thomask
parents:
diff changeset
37 }