Rewrite dubious refRange() shortcuts in unittests

As preparation for dlang/dmd#10124, which makes elements of array
literals rvalues.
This commit is contained in:
Martin Kinkelin 2019-08-15 18:53:58 +02:00
parent 5949c58bbd
commit 7653e97a32
3 changed files with 16 additions and 8 deletions

View file

@ -1831,7 +1831,8 @@ pure @safe unittest // issue 18657
{
import std.algorithm.comparison : equal;
import std.range : refRange;
auto r = refRange(&["foo"][0]).group;
string s = "foo";
auto r = refRange(&s).group;
assert(equal(r.save, "foo".group));
assert(equal(r, "foo".group));
}
@ -5376,7 +5377,8 @@ pure @safe unittest // issue 18657
{
import std.algorithm.comparison : equal;
import std.range : refRange;
auto r = refRange(&["foobar"][0]).splitter!(c => c == 'b');
string s = "foobar";
auto r = refRange(&s).splitter!(c => c == 'b');
assert(equal!equal(r.save, ["foo", "ar"]));
assert(equal!equal(r.save, ["foo", "ar"]));
}

View file

@ -5099,12 +5099,14 @@ pure @safe unittest // issue 18657
import std.algorithm.comparison : equal;
import std.range : refRange;
{
auto r = refRange(&["foobar"][0]).until("bar");
string s = "foobar";
auto r = refRange(&s).until("bar");
assert(equal(r.save, "foo"));
assert(equal(r.save, "foo"));
}
{
auto r = refRange(&["foobar"][0]).until!(e => e == 'b');
string s = "foobar";
auto r = refRange(&s).until!(e => e == 'b');
assert(equal(r.save, "foo"));
assert(equal(r.save, "foo"));
}