File Coverage

blib/lib/Test/RandomCheck/Generator.pm
Criterion Covered Total %
statement 32 32 100.0
branch 4 6 66.6
condition n/a
subroutine 15 15 100.0
pod 2 9 22.2
total 53 62 85.4


line stmt bran cond sub pod time code
1             package Test::RandomCheck::Generator;
2 4     4   13 use strict;
  4         4  
  4         89  
3 4     4   12 use warnings;
  4         4  
  4         81  
4 4     4   12 use Exporter qw(import);
  4         3  
  4         79  
5 4     4   1186 use Test::RandomCheck::ProbMonad;
  4         5  
  4         209  
6 4     4   883 use Test::RandomCheck::Types;
  4         6  
  4         18  
7              
8             our @EXPORT = qw(
9             enum list integer char string concat hash_ref array_ref function
10             );
11              
12             sub enum (@) {
13 6     6 0 371 Test::RandomCheck::Types::Enum->new(
14             items => [@_]
15             );
16             }
17              
18             sub list {
19 4     4 0 34 goto &Test::RandomCheck::Types::List::list;
20             }
21              
22             sub _all_integer () {
23 28     28   96 Test::RandomCheck::Types::AllInteger->new;
24             }
25              
26             sub integer (;$$) {
27 33 100   33 1 3389 goto &_all_integer if @_ == 0;
28              
29 5 50       20 my ($min, $max) = @_ >= 2 ? @_ : (0, @_);
30 5 50       9 ($min, $max) = ($max, $min) if $min > $max;
31 5         28 Test::RandomCheck::Types::Integer->new(
32             min => $min, max => $max
33             );
34             }
35              
36             sub char {
37 15     15 1 1124 goto &Test::RandomCheck::Types::Char::char;
38             }
39              
40             sub string (;$$) {
41 6     6 0 542 my ($min, $max) = @_;
42 6         31 Test::RandomCheck::Types::String->new(
43             min => $min, max => $max
44             );
45             }
46              
47             sub concat (@) {
48 16     16 0 53 goto &Test::RandomCheck::Types::Product::product;
49             }
50              
51             sub hash_ref ($$;$$) {
52 5     5 0 22 my ($key_type, $value_type, $min, $max) = @_;
53 5         29 Test::RandomCheck::Types::HashRef->new(
54             key_type => $key_type, value_type => $value_type,
55             min => $min, max => $max,
56             );
57             }
58              
59             sub array_ref ($;$$) {
60 6     6 0 35 my ($type, $min, $max) = @_;
61 6         24 Test::RandomCheck::Types::ArrayRef->new(
62             min => $min, max => $max, type => $type
63             );
64             }
65              
66             sub function ($$) {
67 15     15 0 60 my ($dom, $cod) = @_;
68 15         34 Test::RandomCheck::Types::Function->new(
69             dom => $dom, cod => $cod
70             );
71             }
72              
73             1;
74             __END__