]> git.vpit.fr Git - perl/modules/Sub-Prototype-Util.git/blobdiff - t/11-wrap.t
Don't import Scalar::Util::set_prototype()
[perl/modules/Sub-Prototype-Util.git] / t / 11-wrap.t
index 4f88d76ac982cb986c37bc20bc0e063ce6238a71..d24e3204d82066f62710cb6deb995b77b256e2a0 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use Test::More tests => 7 + 6 + 3 + 1 + 6 + 1 + (("$]" >= 5.010) ? 2 : 0) + 1;
 
-use Scalar::Util         qw<set_prototype>;
+use Scalar::Util;
 use Sub::Prototype::Util qw<wrap>;
 
 sub exception {
@@ -31,7 +31,8 @@ eval { wrap 'hlagh', qw<a b c> };
 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;
@@ -129,7 +130,7 @@ is($noproto, $noproto_exp, 'no prototype');
 
 sub myit { my $ar = shift; push @$ar, @_; };
 if ("$]" >= 5.010) {
set_prototype \&myit, '\@$_';
Scalar::Util::set_prototype(\&myit, '\@$_');
  my $it = wrap 'main::myit';
  my @a = qw<u v w>;
  local $_ = 7;
@@ -139,7 +140,8 @@ if ("$]" >= 5.010) {
  is_deeply(\@a, [ qw<u v w>, 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';