mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
cmp apparently broken for non-strings
This commit is contained in:
parent
ca379e5993
commit
37f224f86f
1 changed files with 12 additions and 2 deletions
|
@ -4630,8 +4630,8 @@ if (isInputRange!R1 && isInputRange!R2 && !(isSomeString!R1 && isSomeString!R2))
|
|||
{
|
||||
for (;; r1.popFront(), r2.popFront())
|
||||
{
|
||||
if (r1.empty) return -cast(int)r2.empty;
|
||||
if (r2.empty) return r1.empty;
|
||||
if (r1.empty) return -cast(int)!r2.empty;
|
||||
if (r2.empty) return !r1.empty;
|
||||
auto a = r1.front, b = r2.front;
|
||||
if (binaryFun!pred(a, b)) return -1;
|
||||
if (binaryFun!pred(b, a)) return 1;
|
||||
|
@ -4721,6 +4721,16 @@ unittest
|
|||
assert(result > 0);
|
||||
result = cmp("aaa", "aaa"d);
|
||||
assert(result == 0);
|
||||
result = cmp(cast(int[])[], cast(int[])[]);
|
||||
assert(result == 0);
|
||||
result = cmp([1, 2, 3], [1, 2, 3]);
|
||||
assert(result == 0);
|
||||
result = cmp([1, 3, 2], [1, 2, 3]);
|
||||
assert(result > 0);
|
||||
result = cmp([1, 2, 3], [1L, 2, 3, 4]);
|
||||
assert(result < 0);
|
||||
result = cmp([1L, 2, 3], [1, 2]);
|
||||
assert(result > 0);
|
||||
}
|
||||
|
||||
// MinType
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue