File Coverage

blib/lib/UUID/Generator/PurePerl/RNG/MRMTPP.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::MRMTPP;
2              
3 4     4   519 use strict;
  4         4  
  4         93  
4 4     4   11 use warnings;
  4         3  
  4         84  
5              
6 4     4   13 use base qw( UUID::Generator::PurePerl::RNG::Bridge );
  4         3  
  4         628  
7              
8             BEGIN {
9 4     4   232 eval q{ use Math::Random::MT::Perl };
  4     4   596  
  0            
  0            
10 4 50       14 if ($@) {
11 4     4   525 *enabled = sub { 0 };
  4         19  
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::Perl->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__