From 3cf29ca9877089a8a26dcf16a9d757f681a42eba Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 10 Feb 2010 14:11:47 +0100 Subject: add basic tests --- t/11_protected_method.t | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 t/11_protected_method.t (limited to 't/11_protected_method.t') diff --git a/t/11_protected_method.t b/t/11_protected_method.t new file mode 100644 index 0000000..2d86605 --- /dev/null +++ b/t/11_protected_method.t @@ -0,0 +1,40 @@ +use strict; +use warnings; + +use Test::More tests => 5; +use Test::Exception; + +{ + + package Foo; + use Moose; + use MooseX::Privacy; + + protected 'bar' => sub { + my $self = shift; + return 'baz'; + }; +} + +{ + + package Bar; + use Moose; + extends 'Foo'; + + sub baz { + my $self = shift; + return $self->bar; + } +} + +my $foo = Foo->new(); +isa_ok( $foo, 'Foo' ); +dies_ok { $foo->bar } "... can't call bar, method is protected"; + +my $bar = Bar->new(); +isa_ok( $bar, 'Bar' ); +is $bar->baz(), 'baz', "... got the good value from &bar"; + +is scalar @{ $foo->meta->local_protected_methods }, 1, + '... got one protected method'; -- cgit v1.2.3