summaryrefslogtreecommitdiff
path: root/Examples/test-suite/d/default_constructor_runme.2.d
blob: 22f5bffd2f3fa712902087a82f7465394fbc6bf4 (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
module default_constructor_runme;

import default_constructor.FFF;
import default_constructor.G;

void main() {
  // D2 does not support something akin to D1/Tango dispose() for deterministic
  // destruction yet.

  // enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
  // enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
}

private void enforceThrows(void delegate() dg, string errorMessage) {
  bool hasThrown;
  try {
    dg();
  } catch (Exception) {
    hasThrown = true;
  } finally {
    if (!hasThrown) {
      throw new Exception(errorMessage);
    }
  }
}