From: Vincent Pit Date: Tue, 6 Dec 2016 23:38:07 +0000 (-0200) Subject: Test that recasting happens only once X-Git-Tag: rt115792~1 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=commitdiff_plain;h=ecc16f5aeded896b3ab1f0019fc489bb5e15bc08 Test that recasting happens only once This fails starting from perl 5.24. --- diff --git a/t/15-self.t b/t/15-self.t index adc4ec7..a9560ab 100644 --- a/t/15-self.t +++ b/t/15-self.t @@ -6,7 +6,7 @@ use warnings; use Test::More; my $tests; -BEGIN { $tests = 17 } +BEGIN { $tests = 18 } plan tests => $tests; @@ -183,6 +183,23 @@ my $c = 0; } } +SKIP: { + skip "Called twice starting from perl 5.24" => 1 if "$]" >= 5.024; + + my $recasted = 0; + + my $wiz2 = wizard; + my $wiz1 = wizard free => sub { ++$recasted; &cast($_[0], $wiz2); die 'xxx' }; + + local $@; + my $res = eval { + my $v = do { my $val = 123; \$val }; + &cast($v, $wiz1); + }; + + is $recasted, 1, 'recasting free callback called only once'; +} + eval q[ use lib 't/lib'; BEGIN { require Variable::Magic::TestDestroyRequired; }