use strict;
use Test::More tests => 62;
-use Test::Exception;
+use Test::Fatal;
use FindBin;
use lib "$FindBin::Bin/lib";
is_deeply $type->arrayrefint01, [qw(7 8)],
=> 'Assignment and coercion is correct';
-throws_ok sub {
+like exception {
$type->arrayrefint01([qw(a b c)])
}, qr/Attribute \(arrayrefint01\) does not pass the type constraint/ => 'Dies when values are strings';
is_deeply $type->arrayrefint03, [qw(11 12 13)],
=> 'Assignment is correct';
-throws_ok sub {
+like exception {
$type->arrayrefint03([qw(a b c)])
}, qr/Attribute \(arrayrefint03\) does not pass the type constraint/ => 'Dies when values are strings';
ok $type->StrOrArrayRef_attr([1,2,3])
=> 'arrayref part of union is good';
-throws_ok sub {
+like exception {
$type->StrOrArrayRef_attr({a=>111});
}, qr/Attribute \(StrOrArrayRef_attr\) does not pass the type constraint/ => 'Correctly failed to use a hashref';
is_deeply $type->AtLeastOneInt_attr, [1,2]
=> "Got expected values.";
-throws_ok sub {
+like exception {
$type->AtLeastOneInt_attr([]);
}, qr/Attribute \(AtLeastOneInt_attr\) does not pass the type constraint/ => 'properly fails to assign as []';
-throws_ok sub {
+like exception {
$type->AtLeastOneInt_attr(['a','b']);
}, qr/Attribute \(AtLeastOneInt_attr\) does not pass the type constraint/ => 'properly fails arrayref of strings';
ok $type->pipeoverloading('a')
=> 'String for union test accepted';
-throws_ok sub {
+like exception {
$type->pipeoverloading({a=>1,b=>2});
}, qr/Validation failed for 'Int|Str'/ => 'Union test corrected fails a HashRef';
is_deeply $type->deep, [[{a=>1,b=>2},{c=>3,d=>4}],[{e=>5}]],
=> 'Assignment is correct';
-throws_ok sub {
+like exception {
$type->deep({a=>1,b=>2});
}, qr/Attribute \(deep\) does not pass the type constraint/ => 'Deep Constraints properly fail';
is_deeply $type->deep2, [[{a=>1,b=>2},{c=>3,d=>4}],[{e=>5}]],
=> 'Assignment is correct';
-throws_ok sub {
+like exception {
$type->deep2({a=>1,b=>2});
}, qr/Attribute \(deep2\) does not pass the type constraint/ => 'Deep Constraints properly fail';
-throws_ok sub {
+like exception {
$type->deep2([[{a=>1,b=>2},{c=>3,d=>'noway'}],[{e=>5}]]);
}, qr/Attribute \(deep2\) does not pass the type constraint/ => 'Deep Constraints properly fail';
=> 'Good Assignment of Programming to Enum';
-throws_ok sub {
+like exception {
$type->enum('ddddd');
}, qr/Attribute \(enum\) does not pass the type constraint/ => 'Enum properly fails';
is_deeply $type->SubOfMyArrayRefInt01_attr, [15,20,25],
=> 'Assignment is correct';
-throws_ok sub {
+like exception {
$type->SubOfMyArrayRefInt01_attr([15,5,20]);
}, qr/Attribute \(SubOfMyArrayRefInt01_attr\) does not pass the type constraint/
=> 'SubOfMyArrayRefInt01 Constraints properly fail';
is_deeply $type->WierdIntergersArrayRef1_attr, [5,10,1000],
=> 'Assignment is correct';
-throws_ok sub {
+like exception {
$type->WierdIntergersArrayRef1_attr({a=>1,b=>2});
}, qr/Attribute \(WierdIntergersArrayRef1_attr\) does not pass the type constraint/
=> 'Constraints properly fail';
-throws_ok sub {
+like exception {
$type->WierdIntergersArrayRef1_attr([5,10,1]);
}, qr/Attribute \(WierdIntergersArrayRef1_attr\) does not pass the type constraint/
=> 'Constraints properly fail';
-throws_ok sub {
+like exception {
$type->WierdIntergersArrayRef1_attr([1]);
}, qr/Attribute \(WierdIntergersArrayRef1_attr\) does not pass the type constraint/
=> 'Constraints properly fail';
is_deeply $type->WierdIntergersArrayRef2_attr, [5,10,$type],
=> 'Assignment is correct';
-throws_ok sub {
+like exception {
$type->WierdIntergersArrayRef2_attr({a=>1,b=>2});
}, qr/Attribute \(WierdIntergersArrayRef2_attr\) does not pass the type constraint/
=> 'Constraints properly fail';
-throws_ok sub {
+like exception {
$type->WierdIntergersArrayRef2_attr([5,10,1]);
}, qr/Attribute \(WierdIntergersArrayRef2_attr\) does not pass the type constraint/
=> 'Constraints properly fail';
-throws_ok sub {
+like exception {
$type->WierdIntergersArrayRef2_attr([1]);
}, qr/Attribute \(WierdIntergersArrayRef2_attr\) does not pass the type constraint/
=> 'Constraints properly fail';