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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
use Test::More tests => 39;
use strict;
use warnings;
BEGIN { use_ok("Number::Tolerant"); }
BEGIN { use_ok("Number::Tolerant::Union"); }
{
my $alpha = Number::Tolerant->new(5 => to => 10);
my $beta = Number::Tolerant->new(7 => to => 15);
isa_ok($alpha, 'Number::Tolerant');
isa_ok($beta, 'Number::Tolerant');
my $choice = $alpha | $beta;
isa_ok($choice, 'Number::Tolerant::Union', 'union');
ok( 4 != $choice, ' ... 4 != $choice');
ok( 5 == $choice, ' ... 5 == $choice');
ok( 9 == $choice, ' ... 9 == $choice');
ok(11 == $choice, ' ... 11 == $choice');
ok(15 == $choice, ' ... 15 == $choice');
ok(16 != $choice, ' ... 16 != $choice');
my $gamma = Number::Tolerant->new(8 => to => 11);
isa_ok($gamma, 'Number::Tolerant');
my $limited = $choice & $gamma;
ok( 1, ' ... survived union');
ok( 4 != $limited, ' ... 4 != $limited');
ok( 5 != $limited, ' ... 5 != $limited');
ok( 9 == $limited, ' ... 9 == $limited');
ok(11 == $limited, ' ... 11 == $limited');
ok(15 != $limited, ' ... 15 != $limited');
ok(16 != $limited, ' ... 16 != $limited');
}
{
my $alpha = Number::Tolerant->new(5 => to => 10);
my $beta = Number::Tolerant->new(7 => to => 15);
isa_ok($alpha, 'Number::Tolerant');
isa_ok($beta, 'Number::Tolerant');
my $choice = $alpha | $beta;
isa_ok($choice, 'Number::Tolerant::Union', 'union');
ok( 4 != $choice, ' ... 4 != $choice');
ok( 5 == $choice, ' ... 5 == $choice');
ok( 9 == $choice, ' ... 9 == $choice');
ok(11 == $choice, ' ... 11 == $choice');
ok(15 == $choice, ' ... 15 == $choice');
ok(16 != $choice, ' ... 16 != $choice');
my $limited = $choice & 10;
ok( 1, ' ... survived union');
ok( 4 != $limited, ' ... 4 != $limited');
ok( 5 != $limited, ' ... 5 != $limited');
ok( 9 != $limited, ' ... 9 != $limited');
ok(10 == $limited, ' ... 10 == $limited');
ok(11 != $limited, ' ... 11 != $limited');
ok(15 != $limited, ' ... 15 != $limited');
ok(16 != $limited, ' ... 16 != $limited');
}
{
my $alpha = Number::Tolerant->new(5 => to => 10);
my $beta = Number::Tolerant->new(7 => to => 15);
isa_ok($alpha, 'Number::Tolerant');
isa_ok($beta, 'Number::Tolerant');
my $choice = $alpha | $beta;
my $limited = $choice & 100;
is($limited, undef, " ... choice and this union is undef");
}
|