blob: a5633b8c13bbeecd5058939b98d513383b152296 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// 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);
}
|