Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ EXTRA_MODULES_INTERNAL := $(addprefix std/, \
cstring digest/sha_SSSE3 \
$(addprefix math/, biguintcore biguintnoasm biguintx86 \
errorfunction gammafunction ) \
scopebuffer test/dummyrange \
scopebuffer test/dummyrange test/range \
$(addprefix unicode_, comp decomp grapheme norm tables) \
) \
typetuple \
Expand Down
25 changes: 25 additions & 0 deletions std/internal/test/range.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
For testing only.
Contains tests related to member privacy that cannot be verified inside
std.range itself.
*/
module std.internal.test.range;

// Note: currently can't be @safe because RefCounted, which is used by chunks,
// isn't.
@system /*@safe*/ unittest
{
import std.algorithm.comparison : equal;
import std.range : chunks;

struct R
{
int state = 0;
@property bool empty() { return state >= 5; }
@property int front() { return state; }
void popFront() { state++; }
}

auto r = R().chunks(3);
assert(r.equal!equal([[ 0, 1, 2 ], [ 3, 4 ]]));
}
3 changes: 1 addition & 2 deletions std/range/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -7229,14 +7229,13 @@ if (isInputRange!Source)
}

private RefCounted!Impl impl;
alias impl this;

private this(Source r, size_t chunkSize)
{
impl = RefCounted!Impl(r, r.empty ? 0 : chunkSize, chunkSize);
}

@property bool empty() { return chunkSize == 0; }
@property bool empty() { return impl.chunkSize == 0; }
@property Chunk front() return { return Chunk(impl); }

void popFront()
Expand Down
3 changes: 2 additions & 1 deletion win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ SRC_STD_INTERNAL= \
std\internal\unicode_grapheme.d \
std\internal\unicode_norm.d \
std\internal\scopebuffer.d \
std\internal\test\dummyrange.d
std\internal\test\dummyrange.d \
std\internal\test\range.d

SRC_STD_INTERNAL_DIGEST= \
std\internal\digest\sha_SSSE3.d
Expand Down
3 changes: 2 additions & 1 deletion win64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ SRC_STD_INTERNAL= \
std\internal\unicode_grapheme.d \
std\internal\unicode_norm.d \
std\internal\scopebuffer.d \
std\internal\test\dummyrange.d
std\internal\test\dummyrange.d \
std\internal\test\range.d

SRC_STD_INTERNAL_DIGEST= \
std\internal\digest\sha_SSSE3.d
Expand Down