1#!perl -T 2 3use strict; 4use warnings; 5 6use Test::More tests => (2 * 4 + 2) + (2 * 2) + 1; 7 8use Variable::Magic qw/cast/; 9 10use lib 't/lib'; 11use Variable::Magic::TestWatcher; 12use Variable::Magic::TestValue; 13 14my $wiz = init_watcher 'get', 'get'; 15 16my $n = int rand 1000; 17my $a = $n; 18 19watch { cast $a, $wiz } { }, 'cast'; 20 21my $b; 22# $b has to be set inside the block for the test to pass on 5.8.3 and lower 23watch { $b = $a } { get => 1 }, 'assign to'; 24is $b, $n, 'get: assign to correctly'; 25 26$b = watch { "X${a}Y" } { get => 1 }, 'interpolate'; 27is $b, "X${n}Y", 'get: interpolate correctly'; 28 29{ 30 my $val = 0; 31 32 init_value $val, 'get', 'get'; 33 34 value { my $x = $val } \0; 35} 36