Skip to content

Commit

Permalink
Merge pull request #660 from jkm/master
Browse files Browse the repository at this point in the history
Fix enforce in popBack
  • Loading branch information
andralex committed Jul 5, 2012
2 parents 8b69e3e + 3c2cbf0 commit 7d36192
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion std/range.d
Expand Up @@ -3629,7 +3629,7 @@ if(Ranges.length && allSatisfy!(isInputRange, staticMap!(Unqual, Ranges)))
case StoppingPolicy.requireSameLength:
foreach (i, Unused; R)
{
enforce(!ranges[0].empty, "Invalid Zip object");
enforce(!ranges[i].empty, "Invalid Zip object");
ranges[i].popBack();
}
break;
Expand Down Expand Up @@ -3777,6 +3777,11 @@ unittest
assert(a == [1, 2, 3]);
assert(b == [2.0, 1.0, 3.0]);

z = zip(StoppingPolicy.requireSameLength, a, b);
assertNotThrown((z.popBack(), z.popBack(), z.popBack()));
assert(z.empty);
assertThrown(z.popBack());

a = [ 1, 2, 3 ];
b = [ 1.0, 2.0, 3.0 ];
sort!("a[0] > b[0]")(zip(StoppingPolicy.requireSameLength, a, b));
Expand Down

0 comments on commit 7d36192

Please sign in to comment.