Mercurial > projects > dstress
diff run/d/delete_12_D.d @ 834:4a37bb21b9a1
Nick <Nick_member@pathlink.com>
2006-02-15
news:dsv036$qlt$1@digitaldaemon.com
author | thomask |
---|---|
date | Thu, 16 Feb 2006 11:41:35 +0000 |
parents | |
children | b3da1b510a19 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/d/delete_12_D.d Thu Feb 16 11:41:35 2006 +0000 @@ -0,0 +1,62 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nick <Nick_member@pathlink.com> +// @date@ 2006-02-15 +// @uri@ news:dsv036$qlt$1@digitaldaemon.com + +// @WARNING@ direct use of Phobos + +module dstress.run.d.delete_12_D; + +import std.c.stdlib; +import std.outofmemory; +import std.gc; + +int status; + +class Foo{ + int i; + + new(size_t sz){ + void* p; + + p = malloc(sz); + + if (!p){ + throw new OutOfMemoryException(); + } + + if(status++ != 1){ + assert(0); + } + + return p; + } + + delete(void* p){ + if(status++ != 2){ + assert(0); + } + } +} + +void test(){ + auto Foo f = new Foo(); + delete f; +} + +int main(){ + if(status++ != 0){ + assert(0); + } + + test(); + + if(status++ != 3){ + assert(0); + } + + return 0; +}