Skip to content

Commit

Permalink
Test for std.range.Zip.save
Browse files Browse the repository at this point in the history
  • Loading branch information
ErinaceusEuropaeus committed Dec 20, 2016
1 parent 3ae3991 commit a9a0bce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions std/range/package.d
Expand Up @@ -4423,6 +4423,27 @@ pure unittest
auto zz = z.save;
}

@safe pure unittest
{
import std.typecons : tuple;

static class RefRange
{
@safe: pure:
this(int front){ this.front = front; }
int front;
enum empty = false;
void popFront(){ front++; }
RefRange save(){ return new RefRange(front); }
}

auto z1 = zip(new RefRange(0), new RefRange(1));
auto z2 = z1.save;
z1.popFront();
assert(z1.front == tuple(1,2));
assert(z2.front == tuple(0,1));
}

/*
Generate lockstep's opApply function as a mixin string.
If withIndex is true prepend a size_t index to the delegate.
Expand Down

0 comments on commit a9a0bce

Please sign in to comment.