Don't need to loop over subranges to use equal().

I wrote it that way 'cos if the subrange is a distinct type from the
original range, equal won't compare them properly (compiler will
complain about == not being defined).

But in this case, it does work, so I rewrote it to use equal() directly.
This commit is contained in:
H. S. Teoh 2013-08-08 10:10:29 -07:00
parent cd9696a8e8
commit 78b9a6fd00

View file

@ -2614,11 +2614,7 @@ unittest
{ {
// Issue 10773 // Issue 10773
auto s = splitter("abc", ""); auto s = splitter("abc", "");
auto expected = ["a", "b", "c"]; assert(s.equal(["a", "b", "c"]));
foreach (e; s) {
assert(e.equal(expected.front));
expected.popFront();
}
} }
unittest unittest
@ -2636,12 +2632,7 @@ unittest
auto sep = new RefSep("->"); auto sep = new RefSep("->");
auto data = "i->am->pointing"; auto data = "i->am->pointing";
auto words = splitter(data, sep); auto words = splitter(data, sep);
auto expected = [ "i", "am", "pointing" ]; assert(words.equal([ "i", "am", "pointing" ]));
foreach (w; words) {
assert(w == expected.front);
expected.popFront();
}
assert(expected.empty);
} }
auto splitter(alias isTerminator, Range)(Range input) auto splitter(alias isTerminator, Range)(Range input)