From: Vincent Pit Date: Mon, 4 Aug 2008 21:33:37 +0000 (+0200) Subject: Return 'list' when we can't enter the coderef (such as calling non-overriden core... X-Git-Tag: v0.02~18 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=1f19bf4c8d416851e583ef834e7ab605c2e2af32;p=perl%2Fmodules%2FSub-Nary.git Return 'list' when we can't enter the coderef (such as calling non-overriden core functions with the CORE::GLOBAL:: prefix) --- diff --git a/lib/Sub/Nary.pm b/lib/Sub/Nary.pm index 3a0b000..f2b5343 100644 --- a/lib/Sub/Nary.pm +++ b/lib/Sub/Nary.pm @@ -207,6 +207,7 @@ $ops{$_} = 'list' for qw/padany flip match/; sub enter { my ($self, $cv) = @_; + return 'list' if class($cv) ne 'CV'; my $op = $cv->ROOT; my $tag = tag($op); diff --git a/t/22-call.t b/t/22-call.t index f7bb741..fdd3812 100644 --- a/t/22-call.t +++ b/t/22-call.t @@ -3,12 +3,16 @@ use strict; use warnings; -use Test::More tests => 39; +use Test::More tests => 41; use Sub::Nary; my $sn = Sub::Nary->new(); +sub CORE::GLOBAL::reset { + return 1, 2, 3 +} + sub zero { } sub one { 1 } sub two { 1, 2 } @@ -68,6 +72,9 @@ my @tests = ( [ sub { \&zero }, 1 ], [ sub { *zero }, 1 ], [ sub { *zero{CODE}->() }, 'list' ], + + [ sub { &CORE::GLOBAL::shift }, 'list' ], + [ sub { &CORE::GLOBAL::reset }, 3 ], ); my $i = 1;