diff options
author | Tony Cook <tony@develop-help.com> | 2013-09-09 14:44:57 +1000 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2013-09-13 11:33:57 +1000 |
commit | 3be8f09452a42b9f1bbefef19be2dd11a2ca029b (patch) | |
tree | f7e06a8545aad7e0c2e96a680cebac9c06c4ff17 /t/op/rand.t | |
parent | e3be4e3ed79b466668bc99904a680772e8f04697 (diff) | |
download | perl-3be8f09452a42b9f1bbefef19be2dd11a2ca029b.tar.gz |
[perl #115928] a consistent (public) rand() implementation
Based on Yves's random branch work.
This version makes the new random number visible to external modules,
for example, List::Util's XS shuffle() implementation.
I've also added a 64-bit implementation when HAS_QUAD is true, this
should be significantly faster, even on 32-bit CPUs. This is intended to
produce exactly the same sequence as the original implementation.
The original version of this commit retained the "freebsd" name from
Yves's original work for the function and data structure names. I've
removed "freebsd" from most function names so the name isn't an issue
if we choose to replace the implementation,
Diffstat (limited to 't/op/rand.t')
-rw-r--r-- | t/op/rand.t | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/t/op/rand.t b/t/op/rand.t index 24b2bf9baf..90d1c375d1 100644 --- a/t/op/rand.t +++ b/t/op/rand.t @@ -24,7 +24,7 @@ use strict; use Config; require "test.pl"; -plan(tests => 8); +plan(tests => 10); my $reps = 15000; # How many times to try rand each time. @@ -242,3 +242,8 @@ DIAG ok($r < 1, 'rand() without args is under 1'); } +{ # [perl #115928] use a standard rand() implementation + srand(1); + is(int rand(1000), 41, "our own implementation behaves consistently"); + is(int rand(1000), 454, "and still consistently"); +} |