From 2d3f2c09c44f85a899b84706d0fdb6f84c4646d7 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Wed, 22 Sep 2021 17:27:46 +0000 Subject: [PATCH] test/compile_test: Add compliance checks for special types Compile with -debug=check_compliance to check our progress towards supporting these unusual types. --- test/compile_test.d | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/compile_test.d b/test/compile_test.d index ef170c1..b5b5297 100644 --- a/test/compile_test.d +++ b/test/compile_test.d @@ -40,6 +40,15 @@ private void testContainerSingleVal(alias Container)() checkSliceFunctionality!(int)(im); checkSliceFunctionality!(const int)(ic); checkSliceFunctionality!(immutable int)(ii); + + static struct NC { @disable this(this); } + debug(check_compliance) static if (!is(Container!NC)) pragma(msg, __traits(identifier, Container) ~ " does not support non-copyable types"); + + static struct NI { @disable this(); } + debug(check_compliance) static if (!is(Container!NI)) pragma(msg, __traits(identifier, Container) ~ " does not support non-constructable types"); + + static struct ND { @disable ~this() {} } + debug(check_compliance) static if (!is(Container!ND)) pragma(msg, __traits(identifier, Container) ~ " does not support non-destructible types"); } private void testContainerSingleRef(alias Container)() @@ -225,6 +234,18 @@ private void testContainerDoubleVal(alias Container)() checkSliceFunctionality!(const int)(iic); checkSliceFunctionality!(immutable int)(iii); } + + static struct NC { @disable this(this); } + debug(check_compliance) static if (!is(Container!(NC, int))) pragma(msg, __traits(identifier, Container) ~ " does not support non-copyable keys"); + debug(check_compliance) static if (!is(Container!(int, NC))) pragma(msg, __traits(identifier, Container) ~ " does not support non-copyable values"); + + static struct NI { @disable this(); } + debug(check_compliance) static if (!is(Container!(NI, int))) pragma(msg, __traits(identifier, Container) ~ " does not support non-constructable keys"); + debug(check_compliance) static if (!is(Container!(int, NI))) pragma(msg, __traits(identifier, Container) ~ " does not support non-constructable values"); + + static struct ND { @disable ~this() {} } + debug(check_compliance) static if (!is(Container!(ND, int))) pragma(msg, __traits(identifier, Container) ~ " does not support non-destructable keys"); + debug(check_compliance) static if (!is(Container!(int, ND))) pragma(msg, __traits(identifier, Container) ~ " does not support non-destructable values"); } private void testContainerDoubleRef(alias Container)()