summaryrefslogtreecommitdiff
path: root/Examples/test-suite/d/default_constructor_runme.2.d
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/d/default_constructor_runme.2.d')
-rw-r--r--Examples/test-suite/d/default_constructor_runme.2.d25
1 files changed, 25 insertions, 0 deletions
diff --git a/Examples/test-suite/d/default_constructor_runme.2.d b/Examples/test-suite/d/default_constructor_runme.2.d
new file mode 100644
index 000000000..22f5bffd2
--- /dev/null
+++ b/Examples/test-suite/d/default_constructor_runme.2.d
@@ -0,0 +1,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);
+ }
+ }
+}