Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
a few less string evals
  • Loading branch information
kraih committed Dec 11, 2014
1 parent 51cb302 commit 4f9aaa3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/Mojo/Util.pm
Expand Up @@ -13,8 +13,8 @@ use Symbol 'delete_package';
use Time::HiRes ();

# Check for monotonic clock support
use constant MONOTONIC => eval
'!!Time::HiRes::clock_gettime(Time::HiRes::CLOCK_MONOTONIC())';
use constant MONOTONIC =>
eval { !!Time::HiRes::clock_gettime(Time::HiRes::CLOCK_MONOTONIC()) };

# Punycode bootstring parameters
use constant {
Expand All @@ -28,7 +28,8 @@ 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 { require Sub::Util; \&Sub::Util::set_subname } || sub { $_[1] };

# To generate a new HTML entity table run this command
# perl examples/entities.pl
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/util.t
Expand Up @@ -415,7 +415,7 @@ is MojoMonkeyTest::yang(), 'yang', 'right result';

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

0 comments on commit 4f9aaa3

Please sign in to comment.