mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Check for sortedness must not use ==
(#7928)
Check for sortedness must not use `==` merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
This commit is contained in:
parent
64398c058f
commit
8c42ec9d8a
1 changed files with 33 additions and 4 deletions
|
@ -1171,8 +1171,7 @@ if (Rs.length >= 2 &&
|
||||||
{
|
{
|
||||||
if (!source[i].empty)
|
if (!source[i].empty)
|
||||||
{
|
{
|
||||||
assert(previousFront == source[i].front ||
|
assert(!comp(source[i].front, previousFront),
|
||||||
comp(previousFront, source[i].front),
|
|
||||||
"Input " ~ i.stringof ~ " is unsorted"); // @nogc
|
"Input " ~ i.stringof ~ " is unsorted"); // @nogc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1238,8 +1237,7 @@ if (Rs.length >= 2 &&
|
||||||
{
|
{
|
||||||
if (!source[i].empty)
|
if (!source[i].empty)
|
||||||
{
|
{
|
||||||
assert(previousBack == source[i].back ||
|
assert(!comp(previousBack, source[i].back),
|
||||||
comp(source[i].back, previousBack),
|
|
||||||
"Input " ~ i.stringof ~ " is unsorted"); // @nogc
|
"Input " ~ i.stringof ~ " is unsorted"); // @nogc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1445,6 +1443,37 @@ if (Rs.length >= 2 &&
|
||||||
assert(m.empty);
|
assert(m.empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 21810: Check for sortedness must not use `==`
|
||||||
|
@nogc @safe pure nothrow unittest
|
||||||
|
{
|
||||||
|
import std.algorithm.comparison : equal;
|
||||||
|
import std.typecons : tuple;
|
||||||
|
|
||||||
|
static immutable a = [
|
||||||
|
tuple(1, 1),
|
||||||
|
tuple(3, 1),
|
||||||
|
tuple(3, 2),
|
||||||
|
tuple(5, 1),
|
||||||
|
];
|
||||||
|
static immutable b = [
|
||||||
|
tuple(2, 1),
|
||||||
|
tuple(3, 1),
|
||||||
|
tuple(4, 1),
|
||||||
|
tuple(4, 2),
|
||||||
|
];
|
||||||
|
static immutable r = [
|
||||||
|
tuple(1, 1),
|
||||||
|
tuple(2, 1),
|
||||||
|
tuple(3, 1),
|
||||||
|
tuple(3, 2),
|
||||||
|
tuple(3, 1),
|
||||||
|
tuple(4, 1),
|
||||||
|
tuple(4, 2),
|
||||||
|
tuple(5, 1),
|
||||||
|
];
|
||||||
|
assert(merge!"a[0] < b[0]"(a, b).equal(r));
|
||||||
|
}
|
||||||
|
|
||||||
private template validPredicates(E, less...)
|
private template validPredicates(E, less...)
|
||||||
{
|
{
|
||||||
static if (less.length == 0)
|
static if (less.length == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue