Skip to content

Commit

Permalink
test/compile_test: Add compliance checks for special types (#186)
Browse files Browse the repository at this point in the history
Compile with -debug=check_compliance to check our progress towards
supporting these unusual types.
  • Loading branch information
CyberShadow authored Apr 27, 2022
1 parent 8e3fa3f commit 586a4d0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/compile_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)()
Expand Down Expand Up @@ -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)()
Expand Down

0 comments on commit 586a4d0

Please sign in to comment.