File: 1.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-- 752 bytes parent folder | download | duplicates (2)
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;
use Test::Number::Delta within => 1e-14;
BEGIN {
   use_ok('Math::Random::MT');
}


# Test that the OO interface works

ok my $gen = Math::Random::MT->new(5489);
isa_ok $gen, 'Math::Random::MT';

delta_ok $gen->rand(),   0.814723691903055;
delta_ok $gen->rand(),   0.135477004107088;

delta_ok $gen->irand(), 3890346734;
delta_ok $gen->irand(), 3586334585;

delta_ok $gen->rand(10), 1.269868118688464, 'rand() takes a multiplier as argument';
delta_ok $gen->rand(10), 9.688677710946649;

delta_ok $gen->irand(123), 3922919429, 'irand() takes no argument'; # given argument does nothing
delta_ok $gen->irand(123),  949333985;

ok $gen = Math::Random::MT->new(0), '0 is a valid seed';
is $gen->get_seed(), 0;

done_testing();