Skip to content

Commit 586a4d0

Browse files
authored
test/compile_test: Add compliance checks for special types (#186)
Compile with -debug=check_compliance to check our progress towards supporting these unusual types.
1 parent 8e3fa3f commit 586a4d0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/compile_test.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ private void testContainerSingleVal(alias Container)()
4040
checkSliceFunctionality!(int)(im);
4141
checkSliceFunctionality!(const int)(ic);
4242
checkSliceFunctionality!(immutable int)(ii);
43+
44+
static struct NC { @disable this(this); }
45+
debug(check_compliance) static if (!is(Container!NC)) pragma(msg, __traits(identifier, Container) ~ " does not support non-copyable types");
46+
47+
static struct NI { @disable this(); }
48+
debug(check_compliance) static if (!is(Container!NI)) pragma(msg, __traits(identifier, Container) ~ " does not support non-constructable types");
49+
50+
static struct ND { @disable ~this() {} }
51+
debug(check_compliance) static if (!is(Container!ND)) pragma(msg, __traits(identifier, Container) ~ " does not support non-destructible types");
4352
}
4453

4554
private void testContainerSingleRef(alias Container)()
@@ -225,6 +234,18 @@ private void testContainerDoubleVal(alias Container)()
225234
checkSliceFunctionality!(const int)(iic);
226235
checkSliceFunctionality!(immutable int)(iii);
227236
}
237+
238+
static struct NC { @disable this(this); }
239+
debug(check_compliance) static if (!is(Container!(NC, int))) pragma(msg, __traits(identifier, Container) ~ " does not support non-copyable keys");
240+
debug(check_compliance) static if (!is(Container!(int, NC))) pragma(msg, __traits(identifier, Container) ~ " does not support non-copyable values");
241+
242+
static struct NI { @disable this(); }
243+
debug(check_compliance) static if (!is(Container!(NI, int))) pragma(msg, __traits(identifier, Container) ~ " does not support non-constructable keys");
244+
debug(check_compliance) static if (!is(Container!(int, NI))) pragma(msg, __traits(identifier, Container) ~ " does not support non-constructable values");
245+
246+
static struct ND { @disable ~this() {} }
247+
debug(check_compliance) static if (!is(Container!(ND, int))) pragma(msg, __traits(identifier, Container) ~ " does not support non-destructable keys");
248+
debug(check_compliance) static if (!is(Container!(int, ND))) pragma(msg, __traits(identifier, Container) ~ " does not support non-destructable values");
228249
}
229250

230251
private void testContainerDoubleRef(alias Container)()

0 commit comments

Comments
 (0)