diff -rup Hook-LexWrap-0.24-IVpg0D-orig/lib/Hook/LexWrap.pm Hook-LexWrap-0.24-IVpg0D/lib/Hook/LexWrap.pm
--- Hook-LexWrap-0.24-IVpg0D-orig/lib/Hook/LexWrap.pm 2010-09-23 21:40:08.000000000 -0700
+++ Hook-LexWrap-0.24-IVpg0D/lib/Hook/LexWrap.pm 2014-09-21 12:23:33.000000000 -0700
@@ -114,11 +114,11 @@ This document describes version 0.23 of
sub doit { print "[doit:", caller, "]"; return {my=>"data"} }
SCOPED: {
- wrap doit,
+ wrap doit =>
pre => sub { print "[pre1: @_]\n" },
post => sub { print "[post1:@_]\n"; $_[1]=9; };
- my $temporarily = wrap doit,
+ my $temporarily = wrap doit =>
post => sub { print "[post2:@_]\n" },
pre => sub { print "[pre2: @_]\n "};
@@ -205,7 +205,7 @@ Access to the arguments and return value
techniques such as memoization:
my %cache;
- wrap fibonacci,
+ wrap fibonacci =>
pre => sub { $_[-1] = $cache{$_[0]} if $cache{$_[0]} },
post => sub { $cache{$_[0]} = $_[-1] };
@@ -214,7 +214,7 @@ or for converting arguments and return v
# set_temp expects and returns degrees Fahrenheit,
# but we want to use Celsius
- wrap set_temp,
+ wrap set_temp =>
pre => sub { splice @_, 0, 1, $_[0] * 1.8 + 32 },
post => sub { $_[-1] = ($_[0] - 32) / 1.8 };
diff -rup Hook-LexWrap-0.24-IVpg0D-orig/t/example1.t Hook-LexWrap-0.24-IVpg0D/t/example1.t
--- Hook-LexWrap-0.24-IVpg0D-orig/t/example1.t 2010-09-23 21:41:19.000000000 -0700
+++ Hook-LexWrap-0.24-IVpg0D/t/example1.t 2014-09-21 12:12:39.000000000 -0700
@@ -9,11 +9,11 @@ sub doit { $str.= "[doit:{".join(',',cal
SCOPED: {
no warnings 'uninitialized'; #last argument in wrapper sub
- wrap doit,
+ wrap doit =>
pre => sub { $str.="[pre1: @_]" },
post => sub { $str.="[post1:@_]"; $_[1]=9; };
- my $temporarily = wrap doit,
+ my $temporarily = wrap doit =>
post => sub { $str.="[post2:@_]" },
pre => sub { $str.="[pre2: @_]"};
diff -rup Hook-LexWrap-0.24-IVpg0D-orig/t/test.t Hook-LexWrap-0.24-IVpg0D/t/test.t
--- Hook-LexWrap-0.24-IVpg0D-orig/t/test.t 2009-09-15 17:22:02.000000000 -0700
+++ Hook-LexWrap-0.24-IVpg0D/t/test.t 2014-09-21 12:14:58.000000000 -0700
@@ -10,11 +10,11 @@ sub actual { ok $_[0]; }
actual 1;
{
- my $lexical = wrap actual,
+ my $lexical = wrap actual =>
pre => sub { ok 2 },
post => sub { ok 4 };
- wrap actual, pre => sub { $_[0]++ };
+ wrap actual => pre => sub { $_[0]++ };
my $x = 2;
actual $x;
@@ -26,12 +26,12 @@ wrap *main::actual, post => sub { ok 6 }
actual my $x = 4;
no warnings qw/bareword reserved/;
-eval { wrap other, pre => sub { print "not ok 7\n" } } or ok 7;
+eval { wrap other => pre => sub { print "not ok 7\n" } } or ok 7;
-eval { wrap actual, pre => 1 } and print "not ";
+eval { wrap actual => pre => 1 } and print "not ";
ok 8;
-eval { wrap actual, post => [] } and print "not ";
+eval { wrap actual => post => [] } and print "not ";
ok 9;
BEGIN { *{CORE::GLOBAL::sqrt} = sub { CORE::sqrt(shift) } }
@@ -60,7 +60,7 @@ sub wrapped_callee {
return join '|', caller;
}
-wrap wrapped_callee,
+wrap wrapped_callee =>
pre =>sub{
print "not " unless $_[0] eq join '|', caller;
ok 17
@@ -77,11 +77,11 @@ sub raw_callee {
print "not " unless wrapped_callee(scalar raw_callee); ok 19;
sub scalar_return { return 'string' }
-wrap scalar_return, post => sub { $_[-1] .= 'ent' };
+wrap scalar_return => post => sub { $_[-1] .= 'ent' };
print "not " unless scalar_return eq 'stringent'; ok 20;
sub list_return { return (0..9) }
-wrap list_return, post => sub { @{$_[-1]} = reverse @{$_[-1]} };
+wrap list_return => post => sub { @{$_[-1]} = reverse @{$_[-1]} };
my @result = list_return;
for (0..9) {
print "not " and last unless $_ + $result[$_] == 9;
@@ -89,46 +89,46 @@ for (0..9) {
ok 21;
sub shorted_scalar { return 2 };
-wrap shorted_scalar, pre => sub { $_[-1] = 1 };
+wrap shorted_scalar => pre => sub { $_[-1] = 1 };
fail { shorted_scalar != 1 }; ok 22;
sub shorted_list { return (2..9) };
{
- my $lexical = wrap shorted_list, pre => sub { $_[-1] = [1..9] };
+ my $lexical = wrap shorted_list => pre => sub { $_[-1] = [1..9] };
fail { (shorted_list)[0] != 1 }; ok 23;
}
{
- my $lexical = wrap shorted_list, pre => sub { $_[-1] = 1 };
+ my $lexical = wrap shorted_list => pre => sub { $_[-1] = 1 };
fail { (shorted_list)[0] != 1 }; ok 24;
}
{
- my $lexical = wrap shorted_list, pre => sub { @{$_[-1]} = (1..9) };
+ my $lexical = wrap shorted_list=>pre => sub { @{$_[-1]} = (1..9) };
fail { (shorted_list)[0] != 1 }; ok 25;
}
{
- my $lexical = wrap shorted_list, pre => sub { @{$_[-1]} = [1..9] };
+ my $lexical = wrap shorted_list=>pre => sub { @{$_[-1]} = [1..9] };
fail { (shorted_list)[0]->[0] != 1 }; ok 26;
}
{
- my $lexical = wrap shorted_list, post => sub { $_[-1] = [1..9] };
+ my $lexical = wrap shorted_list=> post => sub { $_[-1] = [1..9] };
fail { (shorted_list)[0] != 1 }; ok 27;
}
{
- my $lexical = wrap shorted_list, post => sub { $_[-1] = 1 };
+ my $lexical = wrap shorted_list => post => sub { $_[-1] = 1 };
fail { (shorted_list)[0] != 1 }; ok 28;
}
{
- my $lexical = wrap shorted_list, post => sub { @{$_[-1]} = (1..9) };
+ my $lexical = wrap shorted_list=>post => sub { @{$_[-1]} = (1..9) };
fail { (shorted_list)[0] != 1 }; ok 29;
}
{
- my $lexical = wrap shorted_list, post => sub { @{$_[-1]} = [1..9] };
+ my $lexical = wrap shorted_list=>post => sub { @{$_[-1]} = [1..9] };
fail { (shorted_list)[0]->[0] != 1 }; ok 30;
}
sub howmany { ok 32 if @_ == 3 }
-wrap howmany,
+wrap howmany =>
pre => sub { ok 31 if @_ == 4 },
post => sub { ok 33 if @_ == 4 };
@@ -143,7 +143,7 @@ sub wanted {
ok $_[1]
}
-wrap wanted,
+wrap wanted =>
pre => sub {
my $expected = $_[3];
print 'not ' unless defined wantarray == defined $expected
@@ -185,15 +185,15 @@ sub inner { wrapped(@_) }
outer(43..48);
-wrap wrapped,
+wrap wrapped =>
pre => sub {},
post => sub {};
-wrap wrapped,
+wrap wrapped =>
pre => sub {},
post => sub {};
-wrap wrapped,
+wrap wrapped =>
pre => sub {},
post => sub {};