X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F11-wrap.t;h=d24e3204d82066f62710cb6deb995b77b256e2a0;hb=4a302d06092850955b3c6de15940b89b207f1c54;hp=88ee5c6563034295b4b75f24d38270e07c0c708e;hpb=ea95d5eb42f17626bfca0f26e58a7d6c28e74d47;p=perl%2Fmodules%2FSub-Prototype-Util.git diff --git a/t/11-wrap.t b/t/11-wrap.t index 88ee5c6..d24e320 100644 --- a/t/11-wrap.t +++ b/t/11-wrap.t @@ -3,9 +3,9 @@ use strict; use warnings; -use Test::More tests => 7 + 6 + 3 + 1 + 6 + 1 + (($^V ge v5.10.0) ? 2 : 0) + 1; +use Test::More tests => 7 + 6 + 3 + 1 + 6 + 1 + (("$]" >= 5.010) ? 2 : 0) + 1; -use Scalar::Util qw; +use Scalar::Util; use Sub::Prototype::Util qw; sub exception { @@ -31,7 +31,8 @@ eval { wrap 'hlagh', qw }; like $@, exception('Optional arguments'), 'recall takes options in a key => value list'; -my $push_exp = '{ CORE::push(@{$_[0]}, @_[1..$#_]) }'; +my $push_exp = "$]" >= 5.013007 ? '{ CORE::push($_[0], @_[1..$#_]) }' + : '{ CORE::push(@{$_[0]}, @_[1..$#_]) }'; my $push = wrap 'CORE::push', compile => 0; is($push, 'sub ' . $push_exp, 'wrap push as a sub (default)'); $push = wrap 'CORE::push', sub => 1, compile => 0; @@ -101,7 +102,7 @@ sub cat (\[$@]\[$@]) { SKIP: { skip 'perl 5.8.x is needed to test execution of \[$@] prototypes' => 6 - if $^V lt v5.8.0; + if "$]" < 5.008; my $cat = wrap 'main::cat', ref => 'main::myref', sub => 1, @@ -128,8 +129,8 @@ my $noproto = wrap 'main::noproto', sub => 0; is($noproto, $noproto_exp, 'no prototype'); sub myit { my $ar = shift; push @$ar, @_; }; -if ($^V ge v5.10.0) { - set_prototype \&myit, '\@$_'; +if ("$]" >= 5.010) { + Scalar::Util::set_prototype(\&myit, '\@$_'); my $it = wrap 'main::myit'; my @a = qw; local $_ = 7; @@ -139,7 +140,8 @@ if ($^V ge v5.10.0) { is_deeply(\@a, [ qw, 3, 4, 6, 7 ], '_ without arguments'); } -eval { wrap { 'main::dummy' => '\[@%]' }, ref => 'shift' }; -like $@, - qr/to\s+shift\s+must\s+be\s+array +\([\w ]+\) +at\s+\Q$0\E\s+line\s+\d+/, +sub myshift (;\@) { shift @{$_[0]} } + +eval { wrap { 'main::dummy' => '\[@%]' }, ref => 'main::myshift' }; +like $@, qr/to main::myshift must be array \([\w ]+\) at \Q$0\E line \d+/, 'invalid eval code croaks';