srand.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl -w
BEGIN {
chdir "t" if -d "t";
}
# Test srand.
use strict;
require "test.pl";
# Generate a load of random numbers.
# int() avoids possible floating point error.
# Check that rand() is deterministic.
srand(1138);
srand(1138);
my @second_run = mk_rand;
# Check that different seeds provide different random numbers
srand(31337);
srand(1138);
@second_run = mk_rand;
'srand(), different arg, different rands' );
# Check that srand() isn't affected by $_
{
local $_ = 42;
@second_run = mk_rand;
'srand(), no arg, not affected by $_');
}
# This test checks whether Perl called srand for you.