From 956ef765c6b840f5358b51d3702a73b9b16d95b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Nordl=C3=B6w?= Date: Wed, 25 Jan 2017 19:20:00 +0100 Subject: [PATCH] More alias-this tests and move some of the other-alias tests to undocumented unittests --- std/traits.d | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/std/traits.d b/std/traits.d index e83db2c41..d51f3a683 100644 --- a/std/traits.d +++ b/std/traits.d @@ -5290,7 +5290,10 @@ enum bool isBoolean(T) = is(BooleanTypeOf!T) && !isAggregateType!T; enum EB : bool { a = true } static assert( isBoolean!EB); static assert(!isBoolean!(SubTypeOf!bool)); +} +@safe unittest +{ static struct S(T) { T t; @@ -5415,7 +5418,10 @@ enum bool isScalarType(T) = is(T : real) && !isAggregateType!T; static assert( isScalarType!(const(dchar))); static assert( isScalarType!(const(double))); static assert( isScalarType!(const(real))); +} +@safe unittest +{ static struct S(T) { T t; @@ -5464,6 +5470,13 @@ enum bool isUnsigned(T) = __traits(isUnsigned, T) && !(is(Unqual!T == char) || static assert(!isUnsigned!(SubTypeOf!(Q!T))); } } + + static struct S(T) + { + T t; + alias t this; + } + static assert(!isUnsigned!(S!uint)); } /** @@ -5487,6 +5500,13 @@ enum bool isSigned(T) = __traits(isArithmetic, T) && !__traits(isUnsigned, T); static assert(!isSigned!(SubTypeOf!(Q!T))); } } + + static struct S(T) + { + T t; + alias t this; + } + static assert(!isSigned!(S!uint)); } /** @@ -5529,6 +5549,14 @@ enum bool isSomeChar(T) = is(CharTypeOf!T) && !isAggregateType!T; static assert(!isSomeChar!( SubTypeOf!(Q!T) )); } } + + // alias-this types are not allowed + static struct S(T) + { + T t; + alias t this; + } + static assert(!isSomeChar!(S!char)); } /**