whoot
[gitmo/Moose.git] / t / 013_inner_and_augment.t
index 15a73a5..c1bcaf3 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 16;
 
 BEGIN {
     use_ok('Moose');           
@@ -15,9 +15,9 @@ BEGIN {
     use warnings;
     use Moose;
     
-    sub foo { 'Foo::foo(' . inner() . ')' }
-    sub bar { 'Foo::bar(' . inner() . ')' }    
-    sub baz { 'Foo::baz(' . inner() . ')' }        
+    sub foo { 'Foo::foo(' . (inner() || '') . ')' }
+    sub bar { 'Foo::bar(' . (inner() || '') . ')' }    
+    sub baz { 'Foo::baz(' . (inner() || '') . ')' }        
     
     package Bar;
     use strict;
@@ -26,7 +26,7 @@ BEGIN {
     
     extends 'Foo';
     
-    augment foo => sub { 'Bar::foo(' . inner() . ')' };   
+    augment foo => sub { 'Bar::foo(' . (inner() || '') . ')' };   
     augment bar => sub { 'Bar::bar' };       
     
     package Baz;
@@ -38,6 +38,10 @@ BEGIN {
     
     augment foo => sub { 'Baz::foo' }; 
     augment baz => sub { 'Baz::baz' };       
+
+    # this will actually never run, 
+    # because Bar::bar does not call inner()
+    augment bar => sub { 'Baz::bar' };  
 }
 
 my $baz = Baz->new();
@@ -49,3 +53,17 @@ is($baz->foo(), 'Foo::foo(Bar::foo(Baz::foo))', '... got the right value from &f
 is($baz->bar(), 'Foo::bar(Bar::bar)', '... got the right value from &bar');
 is($baz->baz(), 'Foo::baz(Baz::baz)', '... got the right value from &baz');
 
+my $bar = Bar->new();
+isa_ok($bar, 'Bar');
+isa_ok($bar, 'Foo');
+
+is($bar->foo(), 'Foo::foo(Bar::foo())', '... got the right value from &foo');
+is($bar->bar(), 'Foo::bar(Bar::bar)', '... got the right value from &bar');
+is($bar->baz(), 'Foo::baz()', '... got the right value from &baz');
+
+my $foo = Foo->new();
+isa_ok($foo, 'Foo');
+
+is($foo->foo(), 'Foo::foo()', '... got the right value from &foo');
+is($foo->bar(), 'Foo::bar()', '... got the right value from &bar');
+is($foo->baz(), 'Foo::baz()', '... got the right value from &baz');