use warnings;
use Test::More;
-use Test::Exception;
+use Test::Fatal;
{
package FooRole;
extends 'BarClass';
- ::throws_ok { with 'FooRole' => { -version => 42 } }
+ ::like ::exception { with 'FooRole' => { -version => 42 } },
qr/FooRole version 42 required--this is only version 23/,
'applying role with unsatisfied version requirement';
- ::lives_ok { with 'FooRole' => { -version => 13 } }
+ ::ok ! ::exception { with 'FooRole' => { -version => 13 } },
'applying role with satisfied version requirement';
sub blau {'FooClass::blau'} # << the role wraps this ...
my $foobar_class_meta = FooBarClass->meta;
isa_ok( $foobar_class_meta, 'Moose::Meta::Class' );
-dies_ok {
+ok exception {
$foo_class_meta->does_role();
-}
+},
'... does_role requires a role name';
-dies_ok {
+ok exception {
$foo_class_meta->add_role();
-}
+},
'... apply_role requires a role';
-dies_ok {
+ok exception {
$foo_class_meta->add_role( bless( {} => 'Fail' ) );
-}
+},
'... apply_role requires a role';
ok( $foo_class_meta->does_role('FooRole'),
ok( !defined( $foo->baz ), '... $foo->baz is undefined' );
ok( !defined( $foo->bar ), '... $foo->bar is undefined' );
- dies_ok {
+ ok exception {
$foo->baz(1);
- }
+ },
'... baz is a read-only accessor';
- dies_ok {
+ ok exception {
$foo->bar(1);
- }
+ },
'... bar is a read-write accessor with a type constraint';
my $foo2 = FooClass->new();
isa_ok( $foo2, 'FooClass' );
- lives_ok {
+ ok ! exception {
$foo->bar($foo2);
- }
+ },
'... bar is a read-write accessor with a type constraint';
is( $foo->bar, $foo2, '... got the right value for bar now' );