Fix dxml regression in multiple arguments skipOver

This commit is contained in:
Sebastian Wilzbach 2018-08-16 00:47:32 +02:00
parent 3aeec9b3e1
commit eb6d449aa4

View file

@ -4073,8 +4073,9 @@ template skipOver(alias pred = (a, b) => a == b)
{
import std.algorithm.iteration : map;
import std.algorithm.searching : minElement;
import std.range : only;
// Shortcut opportunity!
if (needles.map!(a => a.length).minElement > haystack.length)
if (needles.only.map!(a => a.length).minElement > haystack.length)
return false;
}
@ -4353,6 +4354,21 @@ template skipOver(alias pred = (a, b) => a == b)
assert(s2.skipOver("", "foo"));
}
// dxml regression
@safe unittest
{
import std.utf : byCodeUnit;
import std.algorithm.comparison : equal;
bool stripStartsWith(Text)(ref Text text, string needle)
{
return text.skipOver(needle.byCodeUnit());
}
auto text = "<xml></xml>"d.byCodeUnit;
assert(stripStartsWith(text, "<xml>"));
assert(text.equal("</xml>"));
}
/**
Checks whether the given
$(REF_ALTTEXT input range, isInputRange, std,range,primitives) starts with (one