Skip to content

Instantly share code, notes, and snippets.

@kfly8
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save kfly8/beade128dce95ca68b38 to your computer and use it in GitHub Desktop.

Select an option

Save kfly8/beade128dce95ca68b38 to your computer and use it in GitHub Desktop.
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;
use strict;
use warnings;
use utf8;
use Test::More;
sub こんにちは { 'hello' }
is こんにちは(), 'hello';
done_testing;
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