forked from moose/Moose
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
todo test for replacing superclass versions of override methods (ether)
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env perl | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
|
||
my ($super_called, $sub_called, $new_super_called) = (0, 0, 0); | ||
{ | ||
package Foo; | ||
use Moose; | ||
|
||
sub foo { $super_called++ } | ||
} | ||
|
||
{ | ||
package Foo::Sub; | ||
use Moose; | ||
extends 'Foo'; | ||
|
||
override foo => sub { | ||
$sub_called++; | ||
super(); | ||
}; | ||
} | ||
|
||
Foo::Sub->new->foo; | ||
is($super_called, 1, "super called"); | ||
is($new_super_called, 0, "new super not called"); | ||
is($sub_called, 1, "sub called"); | ||
|
||
($super_called, $sub_called, $new_super_called) = (0, 0, 0); | ||
|
||
Foo->meta->add_method(foo => sub { | ||
$new_super_called++; | ||
}); | ||
|
||
Foo::Sub->new->foo; | ||
{ local $TODO = "super doesn't get replaced"; | ||
is($super_called, 0, "super not called"); | ||
is($new_super_called, 1, "new super called"); | ||
} | ||
is($sub_called, 1, "sub called"); | ||
|
||
done_testing; |