Skip to content

Commit 73e262a

Browse files
committed
Add test of range-based seeding of Mt19937 random generator
This is added purely in order to verify that generator behaviour will not change with upcoming code changes. It does not appear to match the behaviour of the superficially similar sequence-based seeding available for the C++11 <random> implementation of the Mersenne Twister.
1 parent 7c11313 commit 73e262a

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
@@ -756,6 +756,10 @@ alias Mt19937 = MersenneTwisterEngine!(uint, 32, 624, 397, 31,
756756
assert(gen.front == 3499211612);
757757
popFrontN(gen, 9999);
758758
assert(gen.front == 4123659995);
759+
try { gen.seed(iota(624u)); } catch (Exception) { assert(false); }
760+
assert(gen.front == 3708921088u);
761+
popFrontN(gen, 9999);
762+
assert(gen.front == 165737292u);
759763
}
760764

761765
@safe unittest

0 commit comments

Comments
 (0)