X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=blobdiff_plain;f=t%2F25-copy.t;h=46e324141653d2298c32b85ad5a3b4ce948e379e;hp=394449541b3ab123f7ff015b0bf16834ab77c3a1;hb=9ad970e109ea4caa9767db1bda9d475444920c7a;hpb=3644707ff79f48c935403a704459f79a908c2121 diff --git a/t/25-copy.t b/t/25-copy.t index 3944495..46e3241 100644 --- a/t/25-copy.t +++ b/t/25-copy.t @@ -8,9 +8,9 @@ use Test::More; use lib 't/lib'; use VPIT::TestHelpers; -use Variable::Magic qw; +use Variable::Magic qw; -plan tests => 2 + ((2 * 5 + 3) + (2 * 2 + 1)) + (2 * 9 + 6) + 1; +plan tests => 2 + ((2 * 5 + 3) + (2 * 2 + 1)) + (2 * 9 + 6) + 3 + 1; use lib 't/lib'; use Variable::Magic::TestWatcher; @@ -80,3 +80,23 @@ SKIP: { watch { undef %h } { }, 'tied hash undef'; } + +SKIP: { + skip 'copy magic not called for cloned prototypes before perl 5.17.0' => 3 + unless VMG_COMPAT_CODE_COPY_CLONE; + my $w = wizard copy => sub { + is ref($_[0]), 'CODE', 'first arg in copy on clone is a code ref'; + is $_[2], undef, 'third arg in copy on clone is undef'; + is ref($_[3]), 'CODE', 'fourth arg in copy on clone is a code ref'; + }; + eval <<'TEST_COPY'; + package X; + sub MODIFY_CODE_ATTRIBUTES { + my ($pkg, $sub) = @_; + &Variable::Magic::cast($sub, $w); + return; + } + my $i; + my $f = sub : Hello { $i }; +TEST_COPY +}