Skip to content

Commit 187bfa2

Browse files
committed
Add test of range-based seeding for Mt19937_64
As with the earlier test of range-based seeding for the 32-bit Mt19937, this test is added purely in order to ensure consistency of behaviour in future. It does not appear to match the behaviour of the superficially similar sequence-based seeding available in the C++11 <random> version of the Mersenne Twister. It does however match the behaviour of the `MersenneTwisterEngine` implementation available in `hap.random`, which was derived from the `Boost.Random` implementation, but whose range-based seeding was copied from Phobos. This would suggest that any divergence with C++11 is down entirely to the seeding mechanism.
1 parent 59f1a3d commit 187bfa2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

std/random.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,10 @@ alias Mt19937_64 = MersenneTwisterEngine!(ulong, 64, 312, 156, 31,
901901
assert(gen.front == 14514284786278117030uL);
902902
popFrontN(gen, 9999);
903903
assert(gen.front == 9981545732273789042uL);
904+
try { gen.seed(iota(312uL)); } catch (Exception) { assert(false); }
905+
assert(gen.front == 14660652410669508483uL);
906+
popFrontN(gen, 9999);
907+
assert(gen.front == 15956361063660440239uL);
904908
}
905909

906910
@safe unittest

0 commit comments

Comments
 (0)