mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
Add asserts for the "compiles" tests
This commit is contained in:
parent
c17a621bf2
commit
75cbbef0ab
9 changed files with 52 additions and 17 deletions
|
@ -765,14 +765,14 @@ unittest
|
|||
|
||||
// Issue #10130 - map of iota with const step.
|
||||
const step = 2;
|
||||
map!(i => i)(iota(0, 10, step));
|
||||
assert(map!(i => i)(iota(0, 10, step)).walkLength == 5);
|
||||
|
||||
// Need these to all by const to repro the float case, due to the
|
||||
// CommonType template used in the float specialization of iota.
|
||||
const floatBegin = 0.0;
|
||||
const floatEnd = 1.0;
|
||||
const floatStep = 0.02;
|
||||
map!(i => i)(iota(floatBegin, floatEnd, floatStep));
|
||||
assert(map!(i => i)(iota(floatBegin, floatEnd, floatStep)).walkLength == 50);
|
||||
}
|
||||
|
||||
@safe unittest
|
||||
|
|
|
@ -574,11 +574,13 @@ void fill(Range, Value)(Range range, Value value)
|
|||
int[] a = [1, 2, 3];
|
||||
immutable(int) b = 0;
|
||||
a.fill(b);
|
||||
assert(a == [0, 0, 0]);
|
||||
}
|
||||
{
|
||||
double[] a = [1, 2, 3];
|
||||
immutable(int) b = 0;
|
||||
a.fill(b);
|
||||
assert(a == [0, 0, 0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -982,7 +984,10 @@ unittest
|
|||
class S5;
|
||||
|
||||
S5 s51;
|
||||
move(s51, s51);
|
||||
S5 s52 = s51;
|
||||
S5 s53;
|
||||
move(s52, s53);
|
||||
assert(s53 is s51);
|
||||
}
|
||||
|
||||
/// Ditto
|
||||
|
@ -1092,17 +1097,24 @@ unittest
|
|||
class S5;
|
||||
|
||||
S5 s51;
|
||||
s51 = move(s51);
|
||||
S5 s52 = s51;
|
||||
S5 s53;
|
||||
s53 = move(s52);
|
||||
assert(s53 is s51);
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
static struct S { ~this() @system { } }
|
||||
static struct S { int n = 0; ~this() @system { n = 0; } }
|
||||
S a, b;
|
||||
static assert(!__traits(compiles, () @safe { move(a, b); }));
|
||||
static assert(!__traits(compiles, () @safe { move(a); }));
|
||||
a.n = 1;
|
||||
() @trusted { move(a, b); }();
|
||||
assert(a.n == 0);
|
||||
a.n = 1;
|
||||
() @trusted { move(a); }();
|
||||
assert(a.n == 0);
|
||||
}
|
||||
|
||||
unittest//Issue 6217
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue