Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better logic for coderef detection - no more evals
- Loading branch information
1 parent
95572cd
commit b9ec5de
Showing
3 changed files
with
48 additions
and
7 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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
use strict; | |||
use warnings FATAL => 'all'; | |||
|
|||
use Test::More tests => 7; | |||
use Test::NoWarnings 1.04 ':early'; | |||
|
|||
use Test::LWP::UserAgent; | |||
|
|||
{ | |||
package CodeRefOverload; | |||
use overload '&{}' => sub { sub { ::fail 'sub should not be called' } }; | |||
sub new { bless {}, 'CodeRefOverload' } | |||
} | |||
|
|||
my $string = 'ohhai'; | |||
my $scalarref = \$string; | |||
my $coderef = sub { fail 'sub should not be called' }; | |||
my $nota_coderef = bless {}, 'NotaCodeRef'; | |||
my $isa_coderef = bless sub { fail 'sub should not be called' }, 'IsaCodeRef'; | |||
|
|||
ok(!Test::LWP::UserAgent::__isa_coderef($string), 'string is not callable as a coderef'); | |||
ok(!Test::LWP::UserAgent::__isa_coderef($scalarref), 'scalarref is not callable as a coderef'); | |||
ok(Test::LWP::UserAgent::__isa_coderef($coderef), 'coderef is callable as a coderef'); | |||
ok(!Test::LWP::UserAgent::__isa_coderef($nota_coderef), 'blessed hash is not callable as a coderef'); | |||
ok(Test::LWP::UserAgent::__isa_coderef($isa_coderef), 'blessed coderef is callable as a coderef'); | |||
ok(Test::LWP::UserAgent::__isa_coderef(CodeRefOverload->new), 'object with code overload is callable as a coderef'); | |||
|