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
13 changes: 9 additions & 4 deletions std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -975,10 +975,15 @@ unittest
assert(arr == [0, 1, 2, 3, 4]);

// opApply iterators work as well
static assert(is(typeof({
import std.parallelism;
arr.parallel.each!"a++";
})));
static class S
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's disturbing how many tests in Phobos don't actually test anything

{
int x;
int opApply(int delegate(ref int _x) dg) { return dg(x); }
}

auto s = new S;
s.each!"a++";
assert(s.x == 1);
}

// binary foreach with two ref args
Expand Down
17 changes: 17 additions & 0 deletions std/bigint.d
Original file line number Diff line number Diff line change
Expand Up @@ -1670,3 +1670,20 @@ unittest
assertThrown!ConvException(BigInt("0x1234BARF"));
assertThrown!ConvException(BigInt("1234PUKE"));
}

// Issue 6447
unittest
{
import std.algorithm.comparison : equal;
import std.range : iota;

auto s = BigInt(1_000_000_000_000);
auto e = BigInt(1_000_000_000_003);
auto r = iota(s, e);
assert(r.equal([
BigInt(1_000_000_000_000),
BigInt(1_000_000_000_001),
BigInt(1_000_000_000_002)
]));
}

8 changes: 8 additions & 0 deletions std/parallelism.d
Original file line number Diff line number Diff line change
Expand Up @@ -4567,3 +4567,11 @@ unittest
// this test was in std.range, but caused cycles.
assert(__traits(compiles, { foreach (i; iota(0, 100UL).parallel) {} }));
}

unittest
{
long[] arr;
static assert(is(typeof({
arr.parallel.each!"a++";
})));
}
23 changes: 3 additions & 20 deletions std/range/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -5576,6 +5576,9 @@ unittest

/* Generic overload that handles arbitrary types that support arithmetic
* operations.
*
* User-defined types such as $(REF BigInt, std,bigint) are also supported, as long
* as they can be incremented with $(D ++) and compared with $(D <) or $(D ==).
*/
/// ditto
auto iota(B, E)(B begin, E end)
Expand Down Expand Up @@ -5609,26 +5612,6 @@ auto iota(B, E)(B begin, E end)
return Result(begin, end);
}

/**
User-defined types such as $(REF BigInt, std,bigint) are also supported, as long
as they can be incremented with $(D ++) and compared with $(D <) or $(D ==).
*/
// Issue 6447
unittest
{
import std.algorithm.comparison : equal;
import std.bigint : BigInt;

auto s = BigInt(1_000_000_000_000);
auto e = BigInt(1_000_000_000_003);
auto r = iota(s, e);
assert(r.equal([
BigInt(1_000_000_000_000),
BigInt(1_000_000_000_001),
BigInt(1_000_000_000_002)
]));
}

unittest
{
import std.algorithm.comparison : equal;
Expand Down