Created
September 10, 2012 14:03
-
-
Save j1n3l0/3691109 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use 5.014; | |
use Test::Most; | |
{ | |
package Foo; | |
use Moose; | |
has foo => qw( is ro ); | |
sub bar { "made it to bar" } | |
sub baz { "made it to bar" } | |
before [qw(bar baz)] => sub { die "no foo" unless shift->foo } | |
} | |
note "foo is undefined"; | |
{ | |
my $foo = new_ok Foo => []; | |
dies_ok { $foo->bar } "\$foo->bar dies"; | |
dies_ok { $foo->baz } "\$foo->baz dies"; | |
} | |
note "foo is defined"; | |
{ | |
my $foo = new_ok Foo => [ foo => 1 ]; | |
lives_ok { $foo->bar } "\$foo->bar lives"; | |
lives_ok { $foo->baz } "\$foo->baz lives"; | |
} | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment