1 // { dg-options "-fpreview=dip1008" }
5 this(string msg = "", Throwable nextInChain = null)
7 super(msg, nextInChain);
19 alias chain = Exception.chainTogether;
21 assert(chain(null, null) is null);
29 assert(E.instances == 1);
30 assert(e.refcount == 2);
33 assert(E.instances == 0);
41 assert(chain(null, e) is e);
42 assert(e.refcount == 2); // "Owned by e" + 1
45 assert(E.instances == 0);
53 assert(chain(e, null) is e);
54 assert(e.refcount == 2); // "Owned by e" + 1
57 assert(E.instances == 0);
67 throw new E("second");
77 assert(chain(first, second) is first);
78 assert(first.next is second);
79 assert(second.next is null);
81 assert(chain(first, third) is first);
82 assert(first.next is second);
83 assert(second.next is third);
84 assert(third.next is null);
86 assert(first.refcount == 2);
87 assert(second.refcount == 3);
88 assert(third.refcount == 3);
92 assert(E.instances == 3);
95 assert(E.instances == 0);
103 assert(first.refcount == 2);
104 assert(E.instances == 1);
108 throw new E("second", first);
112 assert(first.next is null);
113 assert(second.next is first);
115 assert(first.refcount == 3);
116 assert(second.refcount == 2);
118 assert(E.instances == 2);
121 assert(first.refcount == 2);
122 assert(E.instances == 1);
125 assert(E.instances == 0);