Merge pull request #6667 from wilzbach/fix-dxml

Fix dxml regression in multiple arguments skipOver
merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2018-08-21 06:58:41 +02:00 committed by GitHub
commit 70348a152c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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