-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug when a child class imported
t()
and the parent already had …
…a `t()` We were checking `$child->can('t')` to determine whether to install a `t()` in the child class, but we need to check if the `$child` package itself has a `t()` sub. Patch from Kerin Millar.
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
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
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
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,35 @@ | ||
## no critic (Modules::ProhibitMultiplePackages) | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More 0.96; | ||
|
||
use Specio::Library::Builtins; | ||
|
||
# This test is about a bug where a parent class with a t() sub causes the t() | ||
# sub to not be added in a child class that uses a type-exporter. | ||
{ | ||
package Parent; | ||
|
||
use Specio::Library::Builtins; | ||
|
||
sub type { | ||
t('Int'); | ||
} | ||
} | ||
|
||
{ | ||
package Child; | ||
|
||
use parent -norequire => 'Parent'; | ||
|
||
use Specio::Library::Builtins; | ||
|
||
sub type { | ||
t('Str'); | ||
} | ||
} | ||
|
||
is( Child::type(), t('Str'), 'Child class has a t() sub' ); | ||
|
||
done_testing(); |