Skip to content

Commit

Permalink
test monkey_patch with names
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 30, 2014
1 parent 9e62f76 commit e6466ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/Util.pm
Expand Up @@ -30,7 +30,7 @@ use constant {
};

# Will be shipping with Perl 5.22
my $NAME = eval "use Sub::Util; 1" ? \&Sub::Util::set_subname : sub { $_[1] };
my $NAME = eval 'use Sub::Util; 1' ? \&Sub::Util::set_subname : sub { $_[1] };

# To update HTML entities run this command
# perl examples/entities.pl > lib/Mojo/entities.txt
Expand Down
9 changes: 9 additions & 0 deletions t/mojo/util.t
Expand Up @@ -408,6 +408,15 @@ is MojoMonkeyTest::yin(), 'yin', 'right result';
ok !!MojoMonkeyTest->can('yang'), 'function "yang" exists';
is MojoMonkeyTest::yang(), 'yang', 'right result';

# monkey_patch (with name)
SKIP: {
skip 'Sub::Util required!', 2 unless eval 'use Sub::Util; 1';
is Sub::Util::subname(MojoMonkeyTest->can('foo')), 'MojoMonkeyTest::foo',
'right name';
is Sub::Util::subname(MojoMonkeyTest->can('bar')), 'MojoMonkeyTest::bar',
'right name';
}

# tablify
is tablify([["f\r\no o\r\n", 'bar']]), "fo o bar\n", 'right result';
is tablify([[" foo", ' b a r']]), " foo b a r\n", 'right result';
Expand Down

0 comments on commit e6466ae

Please sign in to comment.