diff options
Diffstat (limited to 'Examples/test-suite/d')
-rw-r--r-- | Examples/test-suite/d/Makefile.in | 6 | ||||
-rw-r--r-- | Examples/test-suite/d/director_classes_runme.1.d | 13 | ||||
-rw-r--r-- | Examples/test-suite/d/director_classes_runme.2.d | 13 | ||||
-rw-r--r-- | Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d | 114 | ||||
-rw-r--r-- | Examples/test-suite/d/preproc_constants_c_runme.1.d | 5 | ||||
-rw-r--r-- | Examples/test-suite/d/preproc_constants_c_runme.2.d | 5 | ||||
-rw-r--r-- | Examples/test-suite/d/preproc_constants_runme.1.d | 5 | ||||
-rw-r--r-- | Examples/test-suite/d/preproc_constants_runme.2.d | 5 |
8 files changed, 158 insertions, 8 deletions
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in index 3333df110..a20cfb4e3 100644 --- a/Examples/test-suite/d/Makefile.in +++ b/Examples/test-suite/d/Makefile.in @@ -24,6 +24,12 @@ CPP_TEST_CASES = \ d_nativepointers \ exception_partial_info +CPP11_TEST_CASES = \ + cpp11_shared_ptr_const \ + cpp11_shared_ptr_nullptr_in_containers \ + cpp11_shared_ptr_overload \ + cpp11_shared_ptr_upcast \ + include $(srcdir)/../common.mk # Overridden variables here diff --git a/Examples/test-suite/d/director_classes_runme.1.d b/Examples/test-suite/d/director_classes_runme.1.d index 9c34db82a..e753f5f6d 100644 --- a/Examples/test-suite/d/director_classes_runme.1.d +++ b/Examples/test-suite/d/director_classes_runme.1.d @@ -18,6 +18,7 @@ * Base - Val(444.555) * Base - Ref(444.555) * Base - Ptr(444.555) + * Base - ConstPtrRef(444.555) * Base - FullyOverloaded(int 10) * Base - FullyOverloaded(bool 1) * Base - SemiOverloaded(int -678) @@ -28,6 +29,7 @@ * Derived - Val(444.555) * Derived - Ref(444.555) * Derived - Ptr(444.555) + * Derived - ConstPtrRef(444.555) * Derived - FullyOverloaded(int 10) * Derived - FullyOverloaded(bool 1) * Derived - SemiOverloaded(int -678) @@ -38,6 +40,7 @@ * DDerived - Val(444.555) * DDerived - Ref(444.555) * DDerived - Ptr(444.555) + * DDerived - ConstPtrRef(444.555) * DDerived - FullyOverloaded(int 10) * DDerived - FullyOverloaded(bool True) * DDerived - SemiOverloaded(-678) @@ -57,7 +60,7 @@ import director_classes.Derived; import director_classes.DoubleHolder; void main() { - if (PrintDebug) Stdout.formatln("------------ Start ------------ "); + if (PrintDebug) Stdout.formatln("------------ Start ------------"); auto myCaller = new Caller(); @@ -83,7 +86,7 @@ void main() { makeCalls(myCaller, myBase); } - if (PrintDebug) Stdout.formatln("------------ Finish ------------ "); + if (PrintDebug) Stdout.formatln("------------ Finish ------------"); } void makeCalls(Caller myCaller, Base myBase) { @@ -96,6 +99,7 @@ void makeCalls(Caller myCaller, Base myBase) { if (myCaller.ValCall(dh).val != dh.val) throw new Exception("[1] failed"); if (myCaller.RefCall(dh).val != dh.val) throw new Exception("[2] failed"); if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("[3] failed"); + if (myCaller.ConstPtrRefCall(dh).val != dh.val) throw new Exception("[3] failed"); // Fully overloaded method test (all methods in base class are overloaded) if (myCaller.FullyOverloadedCall(10) != myBaseType ~ "::FullyOverloaded(int)") throw new Exception("[4] failed"); @@ -136,6 +140,11 @@ public class DDerived : Base { return x; } + public override DoubleHolder ConstPtrRef(DoubleHolder x) { + if (PrintDebug) Stdout.formatln("DDerived - ConstPtrRef({0:d3})", x.val); + return x; + } + public override char[] FullyOverloaded(int x) { if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(int {0})", x); return "DDerived::FullyOverloaded(int)"; diff --git a/Examples/test-suite/d/director_classes_runme.2.d b/Examples/test-suite/d/director_classes_runme.2.d index 98e27b3cd..b16fa5461 100644 --- a/Examples/test-suite/d/director_classes_runme.2.d +++ b/Examples/test-suite/d/director_classes_runme.2.d @@ -18,6 +18,7 @@ * Base - Val(444.555) * Base - Ref(444.555) * Base - Ptr(444.555) + * Base - ConstPtrRef(444.555) * Base - FullyOverloaded(int 10) * Base - FullyOverloaded(bool 1) * Base - SemiOverloaded(int -678) @@ -28,6 +29,7 @@ * Derived - Val(444.555) * Derived - Ref(444.555) * Derived - Ptr(444.555) + * Derived - ConstPtrRef(444.555) * Derived - FullyOverloaded(int 10) * Derived - FullyOverloaded(bool 1) * Derived - SemiOverloaded(int -678) @@ -38,6 +40,7 @@ * DDerived - Val(444.555) * DDerived - Ref(444.555) * DDerived - Ptr(444.555) + * DDerived - ConstPtrRef(444.555) * DDerived - FullyOverloaded(int 10) * DDerived - FullyOverloaded(bool true) * DDerived - SemiOverloaded(-678) @@ -58,7 +61,7 @@ import director_classes.Derived; import director_classes.DoubleHolder; void main() { - if (PrintDebug) writeln("------------ Start ------------ "); + if (PrintDebug) writeln("------------ Start ------------"); auto myCaller = new Caller(); @@ -84,7 +87,7 @@ void main() { makeCalls(myCaller, myBase); } - if (PrintDebug) writeln("------------ Finish ------------ "); + if (PrintDebug) writeln("------------ Finish ------------"); } void makeCalls(Caller myCaller, Base myBase) { @@ -97,6 +100,7 @@ void makeCalls(Caller myCaller, Base myBase) { enforce(myCaller.ValCall(dh).val == dh.val, "[1] failed"); enforce(myCaller.RefCall(dh).val == dh.val, "[2] failed"); enforce(myCaller.PtrCall(dh).val == dh.val, "[3] failed"); + enforce(myCaller.ConstPtrRefCall(dh).val == dh.val, "[3] failed"); // Fully overloaded method test (all methods in base class are overloaded) enforce(myCaller.FullyOverloadedCall(10) == myBaseType ~ "::FullyOverloaded(int)", "[4] failed"); @@ -137,6 +141,11 @@ public class DDerived : Base { return x; } + public override DoubleHolder ConstPtrRef(DoubleHolder x) { + if (PrintDebug) writefln("DDerived - ConstPtrRef(%s)", x.val); + return x; + } + public override string FullyOverloaded(int x) { if (PrintDebug) writefln("DDerived - FullyOverloaded(int %s)", x); return "DDerived::FullyOverloaded(int)"; diff --git a/Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d new file mode 100644 index 000000000..fbcb03fa6 --- /dev/null +++ b/Examples/test-suite/d/li_boost_shared_ptr_director_runme.2.d @@ -0,0 +1,114 @@ +module li_boost_shared_ptr_director_runme; + +import std.conv; +import std.exception; +import std.stdio; +import std.string; +import li_boost_shared_ptr_director.li_boost_shared_ptr_director; +import li_boost_shared_ptr_director.Base; +import li_boost_shared_ptr_director.C; + +void check(int got, int expected) { + enforce(got == expected, "Failed. got: " ~ to!string(got) ~ " Expected: " ~ to!string(expected)); +} + +void main() { + Derived a = new Derived(false); + Derived b = new Derived(true); + + check(call_ret_c_shared_ptr(a), 1); + check(call_ret_c_shared_ptr(b), -1); + check(call_ret_c_by_value(a), 1); + + check(call_ret_c_shared_ptr(a), 1); + check(call_ret_c_shared_ptr(b), -1); + check(call_ret_c_by_value(a), 1); + + check(call_take_c_by_value(a), 5); + check(call_take_c_by_ref(a), 6); + check(call_take_c_by_pointer(a), 7); + check(call_take_c_by_pointer_ref(a), 8); + check(call_take_c_shared_ptr_by_value(a), 9); + check(call_take_c_shared_ptr_by_ref(a), 10); + check(call_take_c_shared_ptr_by_pointer(a), 11); + check(call_take_c_shared_ptr_by_pointer_ref(a), 12); + + check(call_take_c_by_pointer_with_null(a), -2); + check(call_take_c_by_pointer_ref_with_null(a), -3); + check(call_take_c_shared_ptr_by_value_with_null(a), -4); + check(call_take_c_shared_ptr_by_ref_with_null(a), -5); + check(call_take_c_shared_ptr_by_pointer_with_null(a), -6); + check(call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7); +} + +public class Derived : Base { + + private bool return_none; + + public this(bool flag) { + super(); + this.return_none = flag; + } + + public override C ret_c_shared_ptr() { + if (this.return_none) + return null; + else + return new C(); + } + + public override C ret_c_by_value() { + return new C(); + } + + public override int take_c_by_value(C c) { + return c.get_m(); + } + + public override int take_c_by_ref(C c) { + return c.get_m(); + } + + public override int take_c_by_pointer(C c) { + if (c !is null) + return c.get_m(); + else + return -2; + } + + public override int take_c_by_pointer_ref(C c) { + if (c !is null) + return c.get_m(); + else + return -3; + } + + public override int take_c_shared_ptr_by_value(C c) { + if (c !is null) + return c.get_m(); + else + return -4; + } + + public override int take_c_shared_ptr_by_ref(C c) { + if (c !is null) + return c.get_m(); + else + return -5; + } + + public override int take_c_shared_ptr_by_pointer(C c) { + if (c !is null) + return c.get_m(); + else + return -6; + } + + public override int take_c_shared_ptr_by_pointer_ref(C c) { + if (c !is null) + return c.get_m(); + else + return -7; + } + +} diff --git a/Examples/test-suite/d/preproc_constants_c_runme.1.d b/Examples/test-suite/d/preproc_constants_c_runme.1.d index d846c71ac..a6c2f3d10 100644 --- a/Examples/test-suite/d/preproc_constants_c_runme.1.d +++ b/Examples/test-suite/d/preproc_constants_c_runme.1.d @@ -36,7 +36,7 @@ void main() { static assert(is(char[] == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); -// static assert(is(int == typeof(INT_AND_CHAR()))); + static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); @@ -61,4 +61,7 @@ void main() { static assert(is(int == typeof(EXPR_LAND()))); static assert(is(int == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); + static assert(is(double == typeof(EXPR_MIXED1()))); + static assert(is(int == typeof(EXPR_WCHAR_MAX()))); + static assert(is(int == typeof(EXPR_WCHAR_MIN()))); } diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d index 9bdbb9372..786cb48cc 100644 --- a/Examples/test-suite/d/preproc_constants_c_runme.2.d +++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d @@ -36,7 +36,7 @@ void main() { static assert(is(string == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); -// static assert(is(int == typeof(INT_AND_CHAR()))); + static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); @@ -61,4 +61,7 @@ void main() { static assert(is(int == typeof(EXPR_LAND()))); static assert(is(int == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); + static assert(is(double == typeof(EXPR_MIXED1()))); + static assert(is(int == typeof(EXPR_WCHAR_MAX()))); + static assert(is(int == typeof(EXPR_WCHAR_MIN()))); } diff --git a/Examples/test-suite/d/preproc_constants_runme.1.d b/Examples/test-suite/d/preproc_constants_runme.1.d index 009405fc7..85fa918e4 100644 --- a/Examples/test-suite/d/preproc_constants_runme.1.d +++ b/Examples/test-suite/d/preproc_constants_runme.1.d @@ -35,7 +35,7 @@ void main() { static assert(is(char[] == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); -// static assert(is(int == typeof(INT_AND_CHAR()))); + static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); @@ -60,4 +60,7 @@ void main() { static assert(is(bool == typeof(EXPR_LAND()))); static assert(is(bool == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); + static assert(is(double == typeof(EXPR_MIXED1()))); + static assert(is(int == typeof(EXPR_WCHAR_MAX()))); + static assert(is(int == typeof(EXPR_WCHAR_MIN()))); } diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d index 2d92ef052..c81e53160 100644 --- a/Examples/test-suite/d/preproc_constants_runme.2.d +++ b/Examples/test-suite/d/preproc_constants_runme.2.d @@ -35,7 +35,7 @@ void main() { static assert(is(string == typeof(CONST_STRING2()))); static assert(is(int == typeof(INT_AND_BOOL()))); -// static assert(is(int == typeof(INT_AND_CHAR()))); + static assert(is(int == typeof(INT_AND_CHAR()))); static assert(is(int == typeof(INT_AND_INT()))); static assert(is(uint == typeof(INT_AND_UINT()))); static assert(is(c_long == typeof(INT_AND_LONG()))); @@ -60,4 +60,7 @@ void main() { static assert(is(bool == typeof(EXPR_LAND()))); static assert(is(bool == typeof(EXPR_LOR()))); static assert(is(double == typeof(EXPR_CONDITIONAL()))); + static assert(is(double == typeof(EXPR_MIXED1()))); + static assert(is(int == typeof(EXPR_WCHAR_MAX()))); + static assert(is(int == typeof(EXPR_WCHAR_MIN()))); } |