File: 01_basic.t

package info (click to toggle)
libmath-random-free-perl 0.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 88 kB
  • sloc: perl: 110; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 754 bytes parent folder | download
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
30
#!/usr/bin/perl

use strict;
use warnings;

use Math::Random::Free qw( random_exponential
                           random_normal
                           random_permutation
                           random_set_seed_from_phrase
                           random_uniform_integer );
use Test::More;

my @tested = (
    sub { return random_uniform_integer( 1, 1, 123 ) },
    sub { return join ',', random_permutation( 0..9 ) },
    sub { return join ',', random_normal( 5 ) },
    sub { return random_exponential },
);
plan tests => scalar @tested;

sub seed_and_test
{
    my( $function ) = @_;
    random_set_seed_from_phrase( 'Math::Random::Free' );
    return $function->();
}

for (@tested) {
    is( seed_and_test( $_ ), seed_and_test( $_ ) );
}