mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Merge pull request #7072 from shove70/patch-4
Fix issue 19823 - std.range.dropOne doesn't drop the element when cal… merged-on-behalf-of: Jonathan M Davis <jmdavis@users.noreply.github.com>
This commit is contained in:
commit
ad540ccaa2
1 changed files with 18 additions and 1 deletions
|
@ -1358,11 +1358,11 @@ private struct FilterResult(alias pred, Range)
|
|||
|
||||
void popFront()
|
||||
{
|
||||
prime;
|
||||
do
|
||||
{
|
||||
_input.popFront();
|
||||
} while (!_input.empty && !pred(_input.front));
|
||||
_primed = true;
|
||||
}
|
||||
|
||||
@property auto ref front()
|
||||
|
@ -1480,6 +1480,23 @@ private struct FilterResult(alias pred, Range)
|
|||
assert(equal(filter!underX(list), [ 1, 2, 3, 4 ]));
|
||||
}
|
||||
|
||||
// issue 19823
|
||||
@safe unittest
|
||||
{
|
||||
import std.algorithm.comparison : equal;
|
||||
import std.range : dropOne;
|
||||
|
||||
auto a = [1, 2, 3, 4];
|
||||
assert(a.filter!(a => a != 1).dropOne.equal([3, 4]));
|
||||
assert(a.filter!(a => a != 2).dropOne.equal([3, 4]));
|
||||
assert(a.filter!(a => a != 3).dropOne.equal([2, 4]));
|
||||
assert(a.filter!(a => a != 4).dropOne.equal([2, 3]));
|
||||
assert(a.filter!(a => a == 1).dropOne.empty);
|
||||
assert(a.filter!(a => a == 2).dropOne.empty);
|
||||
assert(a.filter!(a => a == 3).dropOne.empty);
|
||||
assert(a.filter!(a => a == 4).dropOne.empty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to `filter`, except it defines a
|
||||
* $(REF_ALTTEXT bidirectional range, isBidirectionalRange, std,range,primitives).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue