File Coverage

blib/lib/UUID/Generator/PurePerl/RNG/MRMT.pm
Criterion Covered Total %
statement 14 32 43.7
branch 1 8 12.5
condition n/a
subroutine 6 8 75.0
pod 0 2 0.0
total 21 50 42.0


line stmt bran cond sub pod time code
1             package UUID::Generator::PurePerl::RNG::MRMT;
2              
3 4     4   550 use strict;
  4         5  
  4         112  
4 4     4   16 use warnings;
  4         7  
  4         137  
5              
6 4     4   28 use base qw( UUID::Generator::PurePerl::RNG::Bridge );
  4         6  
  4         1677  
7              
8             BEGIN {
9 4     4   238 eval q{ use Math::Random::MT };
  4     4   865  
  0            
  0            
10 4 50       16 if ($@) {
11 4     4   500 *enabled = sub { 0 };
  4         22  
12             }
13             else {
14 0         0 *enabled = sub { 1 };
  0         0  
15             }
16             }
17              
18             sub new {
19 0     0 0   my $class = shift;
20 0           my $seed = shift;
21              
22 0 0         $seed = $class->gen_seed_32bit() if ! defined $seed;
23              
24 0 0         if ($class->enabled) {
25 0           my $mt = Math::Random::MT->new($seed);
26 0           my $self = \$mt;
27 0           return bless $self, $class;
28             }
29             else {
30 0           my $u = undef;
31 0           my $self = \$u;
32 0           return bless $self, $class;
33             }
34             }
35              
36             sub rand_32bit {
37 0     0 0   my $self = shift;
38 0           my $mt = $$self;
39 0 0         return 0 if ! $mt;
40              
41 0           return int($mt->rand() * 65536.0 * 65536);
42             }
43              
44             1;
45             __END__