handling consistent with core Moose. Also changed ->equals and
->is_a_type_of to be consistent.
- Added test case for above
+ - The test suite now uses Test::Fatal instead of Test::Exception (Karen
+ Etheridge).
0.24 16 November 2010
- Added some performance enhancing caching code (phaeton)
[Prereqs / BuildRequires]
Test::More = 0.94
-Test::Exception = 0.27
+Test::Fatal = 0.003
use strict;
use warnings;
use Test::More tests=>32;
- use Test::Exception;
+ use Test::Fatal;
}
{
## Test Tuple type constraint
-lives_ok sub {
+is( exception {
$record->tuple([1,'hello', 'test.abc.test']);
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
is $record->tuple->[0], 1
=> 'correct set the tuple attribute index 0';
is $record->tuple->[2], 'test.abc.test'
=> 'correct set the tuple attribute index 2';
-throws_ok sub {
+like( exception {
$record->tuple([1,'hello', 'test.xxx.test']);
}, qr/Attribute \(tuple\) does not pass the type constraint/
- => 'Properly failed for bad value in custom type constraint';
+ => 'Properly failed for bad value in custom type constraint');
-throws_ok sub {
+like( exception {
$record->tuple(['asdasd',2, 'test.abc.test']);
}, qr/Attribute \(tuple\) does not pass the type constraint/
- => 'Got Expected Error for violating constraints';
+ => 'Got Expected Error for violating constraints');
## Test tuple_with_maybe
-lives_ok sub {
+is( exception {
$record->tuple_with_maybe([1,'hello', 1, $record]);
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->tuple_with_maybe([1,'hello', 'a', $record]);
}, qr/Attribute \(tuple_with_maybe\) does not pass the type constraint/
- => 'Properly failed for bad value parameterized constraint';
+ => 'Properly failed for bad value parameterized constraint');
-lives_ok sub {
+is( exception {
$record->tuple_with_maybe([1,'hello',undef, $record]);
-} => 'Set tuple attribute without error skipping optional parameter';
+} => undef, 'Set tuple attribute without error skipping optional parameter');
## Test tuple_with_maybe2
-lives_ok sub {
+is( exception {
$record->tuple_with_maybe2([1,'hello', 1]);
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->tuple_with_maybe2([1,'hello', 'a']);
}, qr/Attribute \(tuple_with_maybe2\) does not pass the type constraint/
- => 'Properly failed for bad value parameterized constraint';
+ => 'Properly failed for bad value parameterized constraint');
-lives_ok sub {
+is( exception {
$record->tuple_with_maybe2([1,'hello',undef]);
-} => 'Set tuple attribute without error skipping optional parameter';
+} => undef, 'Set tuple attribute without error skipping optional parameter');
SKIP: {
skip 'Core Maybe incorrectly allows null.', 1, 1;
- throws_ok sub {
+ like( exception {
$record->tuple_with_maybe2([1,'hello']);
}, qr/Attribute \(tuple_with_maybe2\) does not pass the type constraint/
- => 'Properly fails for missing maybe (needs to be at least undef)';
+ => 'Properly fails for missing maybe (needs to be at least undef)');
}
## Test Tuple with parameterized type
-lives_ok sub {
+is( exception {
$record->tuple_with_param([1,'hello', [1,2,3]]);
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->tuple_with_param([1,'hello', [qw/a b c/]]);
}, qr/Attribute \(tuple_with_param\) does not pass the type constraint/
- => 'Properly failed for bad value parameterized constraint';
+ => 'Properly failed for bad value parameterized constraint');
## Test tuple2 (Tuple[Int,Str,Int])
ok $record->tuple2([1,'hello',3])
=> "[1,'hello',3] properly suceeds";
-throws_ok sub {
+like( exception {
$record->tuple2([1,2,'world']);
-}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "[1,2,'world'] properly fails";
+}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "[1,2,'world'] properly fails");
-throws_ok sub {
+like( exception {
$record->tuple2(['hello1',2,3]);
-}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,3] properly fails";
+}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,3] properly fails");
-throws_ok sub {
+like( exception {
$record->tuple2(['hello2',2,'world']);
-}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,'world'] properly fails";
+}, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,'world'] properly fails");
## Test tuple_with_parameterized (Tuple[Int,Str,Int,ArrayRef[Int]])
ok $record->tuple_with_parameterized([1,'hello',3,[1,2,3]])
=> "[1,'hello',3,[1,2,3]] properly suceeds";
-throws_ok sub {
+like( exception {
$record->tuple_with_parameterized([1,2,'world']);
}, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/
- => "[1,2,'world'] properly fails";
+ => "[1,2,'world'] properly fails");
-throws_ok sub {
+like( exception {
$record->tuple_with_parameterized(['hello1',2,3]);
}, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/
- => "['hello',2,3] properly fails";
+ => "['hello',2,3] properly fails");
-throws_ok sub {
+like( exception {
$record->tuple_with_parameterized(['hello2',2,'world']);
}, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/
- => "['hello',2,'world'] properly fails";
+ => "['hello',2,'world'] properly fails");
-throws_ok sub {
+like( exception {
$record->tuple_with_parameterized([1,'hello',3,[1,2,'world']]);
}, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/
- => "[1,'hello',3,[1,2,'world']] properly fails";
+ => "[1,'hello',3,[1,2,'world']] properly fails");
## Test FiveByFiveAttr
-lives_ok sub {
+is( exception {
$record->FiveByFiveAttr([6,[7,8,9]]);
-} => 'Set FiveByFiveAttr correctly';
+} => undef, 'Set FiveByFiveAttr correctly');
-throws_ok sub {
+like( exception {
$record->FiveByFiveAttr([1,'hello', 'test']);
}, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/
- => q{Properly failed for bad value in FiveByFiveAttr [1,'hello', 'test']};
+ => q{Properly failed for bad value in FiveByFiveAttr [1,'hello', 'test']});
-throws_ok sub {
+like( exception {
$record->FiveByFiveAttr([1,[8,9,10]]);
}, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/
- => q{Properly failed for bad value in FiveByFiveAttr [1,[8,9,10]]};
+ => q{Properly failed for bad value in FiveByFiveAttr [1,[8,9,10]]});
-throws_ok sub {
+like( exception {
$record->FiveByFiveAttr([10,[11,12,0]]);
}, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/
- => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12,0]]};
+ => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12,0]]});
-throws_ok sub {
+like( exception {
$record->FiveByFiveAttr([1,[1,1,0]]);
}, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/
- => q{Properly failed for bad value in FiveByFiveAttr [1,[1,1,0]]};
+ => q{Properly failed for bad value in FiveByFiveAttr [1,[1,1,0]]});
-throws_ok sub {
+like( exception {
$record->FiveByFiveAttr([10,[11,12]]);
}, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/
- => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12]};
+ => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12]});
use strict;
use warnings;
use Test::More tests=>17;
- use Test::Exception;
+ use Test::Fatal;
}
{
# Test dict Dict[name=>Str, age=>Int]
-lives_ok sub {
+is( exception {
$record->dict({name=>'frith', age=>23});
-} => 'Set dict attribute without error';
+} => undef, 'Set dict attribute without error');
is $record->dict->{name}, 'frith'
=> 'correct set the dict attribute name';
is $record->dict->{age}, 23
=> 'correct set the dict attribute age';
-throws_ok sub {
+like( exception {
$record->dict({name=>[1,2,3], age=>'sdfsdfsd'});
}, qr/Attribute \(dict\) does not pass the type constraint/
- => 'Got Expected Error for bad value in dict';
+ => 'Got Expected Error for bad value in dict');
## Test dict_with_maybe
-lives_ok sub {
+is( exception {
$record->dict_with_maybe({name=>'frith', age=>23});
-} => 'Set dict attribute without error';
+} => undef, 'Set dict attribute without error');
is $record->dict_with_maybe->{name}, 'frith'
=> 'correct set the dict attribute name';
is $record->dict_with_maybe->{age}, 23
=> 'correct set the dict attribute age';
-throws_ok sub {
+like( exception {
$record->dict_with_maybe({name=>[1,2,3], age=>'sdfsdfsd'});
}, qr/Attribute \(dict_with_maybe\) does not pass the type constraint/
- => 'Got Expected Error for bad value in dict';
+ => 'Got Expected Error for bad value in dict');
-throws_ok sub {
+like( exception {
$record->dict_with_maybe({age=>30});
}, qr/Attribute \(dict_with_maybe\) does not pass the type constraint/
- => 'Got Expected Error for missing named parameter';
+ => 'Got Expected Error for missing named parameter');
-lives_ok sub {
+is( exception {
$record->dict_with_maybe({name=>'usal', age=>undef});
-} => 'Set dict attribute without error, skipping maybe';
+} => undef, 'Set dict attribute without error, skipping maybe');
## Test dict_with_tuple_with_union: Dict[key1=>'Str|Object', key2=>Tuple['Int','Str|Object']]
-lives_ok sub {
+is( exception {
$record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,'World']});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->dict_with_tuple_with_union({key1=>'Hello', key2=>['World',2]});
}, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/
- => 'Threw error on bad constraint';
+ => 'Threw error on bad constraint');
-lives_ok sub {
+is( exception {
$record->dict_with_tuple_with_union({key1=>$record, key2=>[1,'World']});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-lives_ok sub {
+is( exception {
$record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,$record]});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->dict_with_tuple_with_union({key1=>1, key2=>['World',2]});
}, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/
- => 'Threw error on bad constraint';
+ => 'Threw error on bad constraint');
use strict;
use warnings;
use Test::More tests=>9;
- use Test::Exception;
+ use Test::Fatal;
}
{
## Test dict_with_tuple
-lives_ok sub {
+is( exception {
$record->dict_with_tuple({key1=>'Hello', key2=>[1,'World']});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->dict_with_tuple({key1=>'Hello', key2=>['World',2]});
}, qr/Attribute \(dict_with_tuple\) does not pass the type constraint/
- => 'Threw error on bad constraint';
+ => 'Threw error on bad constraint');
## Test dict_with_tuple_with_union: Dict[key1=>'Str|Object', key2=>Tuple['Int','Str|Object']]
-lives_ok sub {
+is( exception {
$record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,'World']});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->dict_with_tuple_with_union({key1=>'Hello', key2=>['World',2]});
}, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/
- => 'Threw error on bad constraint';
+ => 'Threw error on bad constraint');
-lives_ok sub {
+is( exception {
$record->dict_with_tuple_with_union({key1=>$record, key2=>[1,'World']});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-lives_ok sub {
+is( exception {
$record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,$record]});
-} => 'Set tuple attribute without error';
+} => undef, 'Set tuple attribute without error');
-throws_ok sub {
+like( exception {
$record->dict_with_tuple_with_union({key1=>1, key2=>['World',2]});
}, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/
- => 'Threw error on bad constraint';
+ => 'Threw error on bad constraint');
use strict;
use warnings;
use Test::More;
+use Test::Fatal;
use MooseX::Types::Moose qw(Int Num);
use MooseX::Types::Structured qw(Map);
ok($type->assert_valid({ 10 => 10.5 }), "simple Int -> Num mapping");
-eval { $type->assert_valid({ 10.5 => 10.5 }) };
-like($@, qr{value 10\.5}, "non-Int causes rejection on key");
+like( exception { $type->assert_valid({ 10.5 => 10.5 }) },
+ qr{value 10\.5}, "non-Int causes rejection on key");
-eval { $type->assert_valid({ 10 => "ten and a half" }) };
-like("$@", qr{value ten and a half}, "non-Num value causes rejection on value");
+like( exception { $type->assert_valid({ 10 => "ten and a half" }) },
+ qr{value ten and a half}, "non-Num value causes rejection on value");
ok($type->assert_valid({ }), "empty hashref is a valid mapping of any sort");
use strict;
use warnings;
use Test::More tests=>16;
- use Test::Exception;
+ use Test::Fatal;
}
{
## Test EqualLengthAttr
-lives_ok sub {
+is( exception {
$obj->EqualLengthAttr([[6,7,8],[9,10,11]]);
-} => 'Set EqualLengthAttr attribute without error';
+} => undef, 'Set EqualLengthAttr attribute without error');
-throws_ok sub {
+like( exception {
$obj->EqualLengthAttr([1,'hello', 'test.xxx.test']);
}, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/
- => q{EqualLengthAttr correctly fails [1,'hello', 'test.xxx.test']};
+ => q{EqualLengthAttr correctly fails [1,'hello', 'test.xxx.test']});
-throws_ok sub {
+like( exception {
$obj->EqualLengthAttr([[6,7],[9,10,11]]);
}, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/
- => q{EqualLengthAttr correctly fails [[6,7],[9,10,11]]};
+ => q{EqualLengthAttr correctly fails [[6,7],[9,10,11]]});
-throws_ok sub {
+like( exception {
$obj->EqualLengthAttr([[6,7,1],[9,10,11]]);
}, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/
- => q{EqualLengthAttr correctly fails [[6,7,1],[9,10,11]]};
+ => q{EqualLengthAttr correctly fails [[6,7,1],[9,10,11]]});
## Test MoreLengthPleaseAttr
-lives_ok sub {
+is( exception {
$obj->MoreLengthPleaseAttr([[6,7,8,9,10],[11,12,13,14,15]]);
-} => 'Set MoreLengthPleaseAttr attribute without error';
+} => undef, 'Set MoreLengthPleaseAttr attribute without error');
-throws_ok sub {
+like( exception {
$obj->MoreLengthPleaseAttr([[6,7,8,9],[11,12,13,14]]);
}, qr/Attribute \(MoreLengthPleaseAttr\) does not pass the type constraint/
- => q{MoreLengthPleaseAttr correctly fails [[6,7,8,9],[11,12,13,14]]};
+ => q{MoreLengthPleaseAttr correctly fails [[6,7,8,9],[11,12,13,14]]});
## Test PersonalInfoAttr
-lives_ok sub {
+is( exception {
$obj->PersonalInfoAttr({name=>'John', stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
-} => 'Set PersonalInfoAttr attribute without error 1';
+} => undef, 'Set PersonalInfoAttr attribute without error 1');
-lives_ok sub {
+is( exception {
$obj->PersonalInfoAttr({name=>'John', stats=>$obj});
-} => 'Set PersonalInfoAttr attribute without error 2';
+} => undef, 'Set PersonalInfoAttr attribute without error 2');
-throws_ok sub {
+like( exception {
$obj->PersonalInfoAttr({name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]});
}, qr/Attribute \(PersonalInfoAttr\) does not pass the type constraint/
- => q{PersonalInfoAttr correctly fails name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]};
+ => q{PersonalInfoAttr correctly fails name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]});
-throws_ok sub {
+like( exception {
$obj->PersonalInfoAttr({name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
}, qr/Attribute \(PersonalInfoAttr\) does not pass the type constraint/
- => q{PersonalInfoAttr correctly fails name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]};
+ => q{PersonalInfoAttr correctly fails name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
## Test MorePersonalInfoAttr
-lives_ok sub {
+is( exception {
$obj->MorePersonalInfoAttr({name=>'Johnnap', stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
-} => 'Set MorePersonalInfoAttr attribute without error 1';
+} => undef, 'Set MorePersonalInfoAttr attribute without error 1');
-throws_ok sub {
+like( exception {
$obj->MorePersonalInfoAttr({name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]});
}, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/
- => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]};
+ => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]});
-throws_ok sub {
+like( exception {
$obj->MorePersonalInfoAttr({name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
}, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/
- => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]};
+ => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
-throws_ok sub {
+like( exception {
$obj->MorePersonalInfoAttr({name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
}, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/
- => q{MorePersonalInfoAttr correctly fails name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]};
+ => q{MorePersonalInfoAttr correctly fails name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]});
use strict;
use warnings;
use Test::More tests=>16;
- use Test::Exception;
}
{
use warnings;
use Test::More tests=>46;
-use Test::Exception;
+use Test::Fatal;
use Moose::Util::TypeConstraints;
use MooseX::Types::Structured qw(Optional);
# Test Insane
-lives_ok sub {
+is( exception {
$obj->InsaneAttr([1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]);
-} => 'Set InsaneAttr attribute without error [1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]';
+} => undef, 'Set InsaneAttr attribute without error [1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]');
-lives_ok sub {
+is( exception {
$obj->InsaneAttr([1,$obj,{name=>"John",age=>39},[1,2,3]]);
-} => 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39},[1,2,3]]';
+} => undef, 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39},[1,2,3]]');
-lives_ok sub {
+is( exception {
$obj->InsaneAttr([1,$obj,{name=>"John",age=>39}]);
-} => 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39}]';
+} => undef, 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39}]');
-throws_ok sub {
+like( exception {
$obj->InsaneAttr([1,$obj,{name=>"John",age=>39},[qw/a b c/]]);
}, qr/Attribute \(InsaneAttr\) does not pass the type constraint/
- => q{InsaneAttr correctly fails [1,$obj,{name=>"John",age=>39},[qw/a b c/]]};
+ => q{InsaneAttr correctly fails [1,$obj,{name=>"John",age=>39},[qw/a b c/]]});
-throws_ok sub {
+like( exception {
$obj->InsaneAttr([1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]);
}, qr/Attribute \(InsaneAttr\) does not pass the type constraint/
- => q{InsaneAttr correctly fails [1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]};
+ => q{InsaneAttr correctly fails [1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]});
# Test TupleOptional1Attr
-lives_ok sub {
+is( exception {
$obj->TupleOptional1Attr([1,10,"hello"]);
-} => 'Set TupleOptional1Attr attribute without error [1,10,"hello"]';
+} => undef, 'Set TupleOptional1Attr attribute without error [1,10,"hello"]');
-lives_ok sub {
+is( exception {
$obj->TupleOptional1Attr([1,10,$obj]);
-} => 'Set TupleOptional1Attr attribute without error [1,10,$obj]';
+} => undef, 'Set TupleOptional1Attr attribute without error [1,10,$obj]');
-lives_ok sub {
+is( exception {
$obj->TupleOptional1Attr([1,10]);
-} => 'Set TupleOptional1Attr attribute without error [1,10]';
+} => undef, 'Set TupleOptional1Attr attribute without error [1,10]');
-throws_ok sub {
+like( exception {
$obj->TupleOptional1Attr([1,10,[1,2,3]]);
}, qr/Attribute \(TupleOptional1Attr\) does not pass the type constraint/
- => q{TupleOptional1Attr correctly fails [1,10,[1,2,3]]};
+ => q{TupleOptional1Attr correctly fails [1,10,[1,2,3]]});
-throws_ok sub {
+like( exception {
$obj->TupleOptional1Attr([1,10,undef]);
}, qr/Attribute \(TupleOptional1Attr\) does not pass the type constraint/
- => q{TupleOptional1Attr correctly fails [1,10,undef]};
+ => q{TupleOptional1Attr correctly fails [1,10,undef]});
# Test TupleOptional2Attr
-lives_ok sub {
+is( exception {
$obj->TupleOptional2Attr([1,10,{key1=>1,key2=>$obj}]);
-} => 'Set TupleOptional2Attr attribute without error [1,10,{key1=>1,key2=>$obj}]';
+} => undef, 'Set TupleOptional2Attr attribute without error [1,10,{key1=>1,key2=>$obj}]');
-lives_ok sub {
+is( exception {
$obj->TupleOptional2Attr([1,10]);
-} => 'Set TupleOptional2Attr attribute without error [1,10]';
+} => undef, 'Set TupleOptional2Attr attribute without error [1,10]');
-throws_ok sub {
+like( exception {
$obj->TupleOptional2Attr([1,10,[1,2,3]]);
}, qr/Attribute \(TupleOptional2Attr\) does not pass the type constraint/
- => q{TupleOptional2Attr correctly fails [1,10,[1,2,3]]};
+ => q{TupleOptional2Attr correctly fails [1,10,[1,2,3]]});
-throws_ok sub {
+like( exception {
$obj->TupleOptional2Attr([1,10,undef]);
}, qr/Attribute \(TupleOptional2Attr\) does not pass the type constraint/
- => q{TupleOptional2Attr correctly fails [1,10,undef]};
+ => q{TupleOptional2Attr correctly fails [1,10,undef]});
# Test DictOptional1Attr: Dict[name=>Str, age=>Int, gender=>Optional[Gender]];
-lives_ok sub {
+is( exception {
$obj->DictOptional1Attr({name=>"John",age=>39,gender=>"male"});
-} => 'Set DictOptional1Attr attribute without error {name=>"John",age=>39,gender=>"male"}';
+} => undef, 'Set DictOptional1Attr attribute without error {name=>"John",age=>39,gender=>"male"}');
-lives_ok sub {
+is( exception {
$obj->DictOptional1Attr({name=>"Vanessa",age=>34});
-} => 'Set DictOptional1Attr attribute without error {name=>"Vanessa",age=>34}';
+} => undef, 'Set DictOptional1Attr attribute without error {name=>"Vanessa",age=>34}');
-throws_ok sub {
+like( exception {
$obj->DictOptional1Attr({name=>"John",age=>39,gender=>undef});
}, qr/Attribute \(DictOptional1Attr\) does not pass the type constraint/
- => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>undef}};
+ => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>undef}});
-throws_ok sub {
+like( exception {
$obj->DictOptional1Attr({name=>"John",age=>39,gender=>"aaa"});
}, qr/Attribute \(DictOptional1Attr\) does not pass the type constraint/
- => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>"aaa"}};
+ => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>"aaa"}});