X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F20-get.t;h=02ef39bc62d2902e94bf0b2d67d9715eec5b448f;hb=ed45fb4404201c2e17ffa5c26a2320ceeb132e61;hp=60826a17737af38ee4ca0686cce2489c80c7ce95;hpb=a86e3e47a167afadf7de1231d6401a1139330ad0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/20-get.t b/t/20-get.t index 60826a1..02ef39b 100644 --- a/t/20-get.t +++ b/t/20-get.t @@ -3,24 +3,24 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 2 * 4 + 2 + 1; -use Variable::Magic qw/wizard cast/; +use Variable::Magic qw/cast/; -my $c = 0; -my $wiz = wizard get => sub { ++$c }; -is($c, 0, 'get : create wizard'); +use lib 't/lib'; +use Variable::Magic::TestWatcher; + +my $wiz = init 'get', 'get'; my $n = int rand 1000; my $a = $n; -cast $a, $wiz; -is($c, 0, 'get : cast'); +check { cast $a, $wiz } { }, 'cast'; -my $b = $a; -is($c, 1, 'get : assign to'); -is($b, $n, 'get : assign to correctly'); +my $b; +# $b has to be set inside the block for the test to pass on 5.8.3 and lower +check { $b = $a } { get => 1 }, 'assign to'; +is $b, $n, 'get: assign to correctly'; -$b = "X${a}Y"; -is($c, 2, 'get : interpolate'); -is($b, "X${n}Y", 'get : interpolate correctly'); +$b = check { "X${a}Y" } { get => 1 }, 'interpolate'; +is $b, "X${n}Y", 'get: interpolate correctly';