File: 3.t

package info (click to toggle)
libmath-random-mt-perl 1.17-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: ansic: 216; perl: 63; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use strict;
use Test::More;
BEGIN {
   use_ok('Math::Random::MT', qw(srand rand irand));
}


my ($num1, $num2);

ok srand; # explicit srand, but without number

eval { $num1 = rand; };
is $@, '', '$@ should be empty after rand() but it\'s: '.$@;
isnt $num1, undef;
cmp_ok $num1, '>=', 0;
cmp_ok $num1, '<', 1; # rand without argument is like rand(1)
eval { $num2 = rand; };
is $@, '', '$@ should also be empty the second time rand() is called';
isnt $num1, $num2;

eval { $num1 = irand; };
is $@, '', '$@ should be empty after rand()';
isnt $num1, undef;
cmp_ok $num1, '>=', 0;
eval { $num2 = irand; };
is $@, '', '$@ should also be empty the second time rand() is called';
isnt $num1, $num2;

done_testing();