diff options
| author | franck cuny <franck@lumberjaph.net> | 2009-06-30 11:24:57 +0200 |
|---|---|---|
| committer | franck cuny <franck@lumberjaph.net> | 2009-06-30 11:24:57 +0200 |
| commit | 2cbd7056206d1c0f5b8f9f0ded4cda65ed784cb8 (patch) | |
| tree | 9dc03b8a57a6dee24629866de30c7cd572087072 /t/11_method_protected.t | |
| parent | initial commit (diff) | |
| download | moosex-methodprivate-2cbd7056206d1c0f5b8f9f0ded4cda65ed784cb8.tar.gz | |
private and protectd methods and basic tests
Diffstat (limited to 't/11_method_protected.t')
| -rw-r--r-- | t/11_method_protected.t | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/11_method_protected.t b/t/11_method_protected.t new file mode 100644 index 0000000..3b3d35d --- /dev/null +++ b/t/11_method_protected.t @@ -0,0 +1,39 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 4; +use Test::Exception; + +{ + + package Foo; + use Moose; + use MooseX::MethodPrivate; + + 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"; |
