X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F020_attributes%2F004_attribute_triggers.t;h=7fb4b31ae5256fdc4e967690af9b113865c7f023;hb=b10dde3a27c11623547417c599ccbd4f92e42651;hp=b8ec58039458293ea6a4584b1f97ca0e667f2849;hpb=d4e538d9bf46d1c14d2ecfd36ac35ed541ae7ee6;p=gitmo%2FMoose.git diff --git a/t/020_attributes/004_attribute_triggers.t b/t/020_attributes/004_attribute_triggers.t index b8ec580..7fb4b31 100644 --- a/t/020_attributes/004_attribute_triggers.t +++ b/t/020_attributes/004_attribute_triggers.t @@ -6,7 +6,7 @@ use warnings; use Scalar::Util 'isweak'; use Test::More; -use Test::Exception; +use Test::Fatal; { @@ -50,27 +50,27 @@ use Test::Exception; my $baz = Baz->new; isa_ok($baz, 'Baz'); - lives_ok { + is( exception { $foo->bar($bar); - } '... did not die setting bar'; + }, undef, '... 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 { + is( exception { $foo->bar(undef); - } '... did not die un-setting bar'; + }, undef, '... 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 { + is( exception { $foo->set_baz($baz); - } '... did not die setting baz'; + }, undef, '... 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'); @@ -105,13 +105,13 @@ use Test::Exception; package Bling; use Moose; - ::dies_ok { + ::isnt( ::exception { has('bling' => (is => 'rw', trigger => 'Fail')); - } '... a trigger must be a CODE ref'; + }, undef, '... a trigger must be a CODE ref' ); - ::dies_ok { + ::isnt( ::exception { has('bling' => (is => 'rw', trigger => [])); - } '... a trigger must be a CODE ref'; + }, undef, '... a trigger must be a CODE ref' ); } # Triggers do not fire on built values @@ -140,7 +140,7 @@ use Test::Exception; { my $blarg; - lives_ok { $blarg = Blarg->new; } 'Blarg->new() lives'; + is( exception { $blarg = Blarg->new; }, undef, '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"); @@ -152,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'; + is( exception { $blarg => Blarg->new( map { $_ => "Yet another $_ value" } qw/foo bar baz/ ) }, undef, '->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'); }