convert all uses of Test::Exception to Test::Fatal.
[gitmo/Moose.git] / t / 020_attributes / 004_attribute_triggers.t
index baa2a2a..803cc63 100644 (file)
@@ -5,9 +5,8 @@ use warnings;
 
 use Scalar::Util 'isweak';
 
-use Test::More tests => 42;
-use Test::Exception;
-
+use Test::More;
+use Test::Fatal;
 
 
 {
@@ -51,27 +50,27 @@ use Test::Exception;
     my $baz = Baz->new;
     isa_ok($baz, 'Baz');
 
-    lives_ok {
+    ok ! exception {
         $foo->bar($bar);
-    } '... did not die setting bar';
+    }, '... did not die setting bar';
 
     is($foo->bar, $bar, '... set the value foo.bar correctly');
     is($bar->foo, $foo, '... which in turn set the value bar.foo correctly');
 
     ok(isweak($bar->{foo}), '... bar.foo is a weak reference');
 
-    lives_ok {
+    ok ! exception {
         $foo->bar(undef);
-    } '... did not die un-setting bar';
+    }, '... did not die un-setting bar';
 
     is($foo->bar, undef, '... set the value foo.bar correctly');
     is($bar->foo, $foo, '... which in turn set the value bar.foo correctly');
 
     # test the writer
 
-    lives_ok {
+    ok ! exception {
         $foo->set_baz($baz);
-    } '... did not die setting baz';
+    }, '... did not die setting baz';
 
     is($foo->get_baz, $baz, '... set the value foo.baz correctly');
     is($baz->foo, $foo, '... which in turn set the value baz.foo correctly');
@@ -106,13 +105,13 @@ use Test::Exception;
     package Bling;
     use Moose;
 
-    ::dies_ok {
+    ::ok ::exception {
         has('bling' => (is => 'rw', trigger => 'Fail'));
-    } '... a trigger must be a CODE ref';
+    }, '... a trigger must be a CODE ref';
 
-    ::dies_ok {
+    ::ok ::exception {
         has('bling' => (is => 'rw', trigger => []));
-    } '... a trigger must be a CODE ref';
+    }, '... a trigger must be a CODE ref';
 }
 
 # Triggers do not fire on built values
@@ -141,7 +140,7 @@ use Test::Exception;
 
 {
     my $blarg;
-    lives_ok { $blarg = Blarg->new; } 'Blarg->new() lives';
+    ok ! exception { $blarg = Blarg->new; }, 'Blarg->new() lives';
     ok($blarg, 'Have a $blarg');
     foreach my $attr (qw/foo bar baz/) {
         is($blarg->$attr(), "default $attr value", "$attr has default value");
@@ -153,7 +152,7 @@ use Test::Exception;
     is_deeply(\%Blarg::trigger_calls, { map { $_ => 1 } qw/foo bar baz/ }, 'All triggers fired once on assign');
     is_deeply(\%Blarg::trigger_vals, { map { $_ => "Different $_ value" } qw/foo bar baz/ }, 'All triggers given assigned values');
 
-    lives_ok { $blarg => Blarg->new( map { $_ => "Yet another $_ value" } qw/foo bar baz/ ) } '->new() with parameters';
+    ok ! exception { $blarg => Blarg->new( map { $_ => "Yet another $_ value" } qw/foo bar baz/ ) }, '->new() with parameters';
     is_deeply(\%Blarg::trigger_calls, { map { $_ => 2 } qw/foo bar baz/ }, 'All triggers fired once on construct');
     is_deeply(\%Blarg::trigger_vals, { map { $_ => "Yet another $_ value" } qw/foo bar baz/ }, 'All triggers given assigned values');
 }
@@ -189,6 +188,15 @@ use Test::Exception;
         'trigger called correctly on second set via meta-API',
     );
     @Foo::calls = ();
+
+    $attr->set_raw_value( $foo, 4 );
+
+    is_deeply(
+        \@Foo::calls,
+        [ ],
+        'trigger not called using set_raw_value method',
+    );
+    @Foo::calls = ();
 }
 
 {
@@ -210,4 +218,4 @@ use Test::Exception;
     Foo->meta->make_immutable, redo if Foo->meta->is_mutable;
 }
 
-
+done_testing;