Last active
August 29, 2015 14:10
-
-
Save kfly8/beade128dce95ca68b38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Test::More; | |
| { | |
| no strict qw/refs/; | |
| *{'world!'} = sub { 'world' }; | |
| is *{'world!'}{CODE}->(), 'world', 'symbol table call'; | |
| } | |
| done_testing; |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Test::More; | |
| sub こんにちは { 'hello' } | |
| is こんにちは(), 'hello'; | |
| done_testing; |
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use utf8; | |
| use Test::More; | |
| use Package::Stash; | |
| my $stash = Package::Stash->new('Foo'); | |
| $stash->add_symbol('&hello world!', sub { 'hello' }); | |
| subtest 'by get_symbol' => sub { | |
| my $code = $stash->get_symbol('&hello world!'); | |
| is $code->(), 'hello' | |
| }; | |
| subtest 'by pkg' => sub { | |
| ok Foo->can('hello world!'), 'can?'; | |
| my $code = Foo->can('hello world!'); | |
| is $code->(), 'hello'; | |
| my $method = 'hello world!'; | |
| is Foo->$method(), 'hello'; | |
| }; | |
| done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment