diff options
author | Michael G. Schwern <schwern@pobox.com> | 2001-09-03 14:08:15 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-04 12:44:29 +0000 |
commit | 97458a6ff67bc5a554449c1abcbdf1ad7278b72f (patch) | |
tree | cb108cf04faacb4593f9aed15825ee4372ee4cbf /t | |
parent | a10553775db253e3f9d2e89456a9e00b631e6d13 (diff) | |
download | perl-97458a6ff67bc5a554449c1abcbdf1ad7278b72f.tar.gz |
Re: A slightly better default seed?
Message-ID: <20010903180815.W9233@blackrider>
p4raw-id: //depot/perl@11859
Diffstat (limited to 't')
-rw-r--r-- | t/op/srand.t | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/t/op/srand.t b/t/op/srand.t index 5aadaa8940..bbd0e54845 100644 --- a/t/op/srand.t +++ b/t/op/srand.t @@ -3,7 +3,7 @@ # Test srand. use strict; -use Test::More tests => 3; +use Test::More tests => 4; # Generate a load of random numbers. # int() avoids possible floating point error. @@ -31,6 +31,19 @@ ok( !eq_array(\@first_run, \@second_run), 'srand(), different arg, different rands' ); +# Check that srand() isn't affected by $_ +{ + local $_ = 42; + srand(); + @first_run = mk_rand; + + srand(42); + @second_run = mk_rand; + + ok( !eq_array(\@first_run, \@second_run), + 'srand(), no arg, not affected by $_'); +} + # This test checks whether Perl called srand for you. @first_run = `$^X -le "print int rand 100 for 1..100"`; @second_run = `$^X -le "print int rand 100 for 1..100"`; |