-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable to create a kura of your own choice.
- Loading branch information
Showing
3 changed files
with
64 additions
and
10 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
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,24 @@ | ||
use Test2::V0; | ||
use lib 't/lib'; | ||
use MyChecker; | ||
|
||
subtest 'Test `import_into` method' => sub { | ||
subtest 'Checker is imported into $target_package' => sub { | ||
package Foo {} | ||
my $target_package = 'Foo'; | ||
|
||
use kura (); | ||
kura->import_into($target_package, Hello => MyChecker->new); | ||
|
||
isa_ok Foo::Hello(), 'MyChecker'; | ||
}; | ||
|
||
subtest 'So, you can customize the import method to your taste' => sub { | ||
use MyKura Foo => MyChecker->new; | ||
|
||
# MyKura customize the name of the checker | ||
isa_ok MyFoo, 'MyChecker'; | ||
} | ||
}; | ||
|
||
done_testing; |
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,18 @@ | ||
package MyKura; | ||
use strict; | ||
use warnings; | ||
|
||
use kura (); | ||
|
||
sub import { | ||
my $class = shift; | ||
my $caller = caller; | ||
|
||
my ($name, $checker) = @_; | ||
|
||
$name = 'My' . $name; | ||
|
||
kura->import_into($caller, $name, $checker); | ||
} | ||
|
||
1; |