Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/compile_test: Add compliance checks for special types #186

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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