dmd/compiler/test/runnable/test19317.d
2022-07-09 18:53:07 +02:00

32 lines
667 B
D

// REQUIRED_ARGS: -preview=dip1008
// https://issues.dlang.org/show_bug.cgi?id=19317
class MyException: Exception {
static int numInstances;
this(string msg) {
super(msg);
++numInstances;
}
~this() {
--numInstances;
}
}
void main() {
assert(MyException.numInstances == 0);
try
throw new MyException("oops");
catch(MyException _)
assert(MyException.numInstances == 1);
assert(MyException.numInstances == 0);
try
throw new MyException("oops I did it again");
catch(MyException)
assert(MyException.numInstances == 1);
assert(MyException.numInstances == 0);
}