Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions std/range.d
Original file line number Diff line number Diff line change
Expand Up @@ -2873,7 +2873,7 @@ stopping policy.
{
if (!ranges[i].empty) return false;
}
break;
return true;
case StoppingPolicy.requireSameLength:
foreach (i, Unused; R[1 .. $])
{
Expand Down Expand Up @@ -3218,15 +3218,15 @@ unittest
assert(a == [1, 2, 3]);
assert(b == [2., 1, 3]);

// Test infiniteness propagation.
static assert(isInfinite!(typeof(zip(repeat(1), repeat(1)))));

// Test stopping policies with both value and reference.
auto a1 = [1, 2];
auto a2 = [1, 2, 3];
auto stuff = tuple(tuple(a1, a2),
tuple(filter!"a"(a1), filter!"a"(a2)));

// Test infiniteness propagation.
static assert(isInfinite!(typeof(zip(repeat(1), repeat(1)))));

alias Zip!(immutable int[], immutable float[]) FOO;

foreach(t; stuff.expand) {
Expand All @@ -3242,14 +3242,18 @@ unittest
assert(0);
} catch { /* It's supposed to throw.*/ }

auto zLongest = zip(StoppingPolicy.requireSameLength, arr1, arr2);
auto zLongest = zip(StoppingPolicy.longest, arr1, arr2);
assert(!zLongest.ranges[0].empty);
assert(!zLongest.ranges[1].empty);

zLongest.popFront();
zLongest.popFront();
assert(!zLongest.empty);
assert(zLongest.ranges[0].empty);
assert(!zLongest.ranges[1].empty);

zLongest.popFront();
assert(zLongest.empty);
}

// Doesn't work yet. Issues w/ emplace.
Expand Down