1#!perl -T 2 3use strict; 4use warnings; 5 6use Test::More tests => (2 * 5 + 3) + (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 'set', 'set'; 15 16my $a = 0; 17 18watch { cast $a, $wiz } { }, 'cast'; 19 20my $n = int rand 1000; 21 22watch { $a = $n } { set => 1 }, 'assign'; 23is $a, $n, 'set: assign correctly'; 24 25watch { ++$a } { set => 1 }, 'increment'; 26is $a, $n + 1, 'set: increment correctly'; 27 28watch { --$a } { set => 1 }, 'decrement'; 29is $a, $n, 'set: decrement correctly'; 30 31{ 32 my $val = 0; 33 34 init_value $val, 'set', 'set'; 35 36 value { $val = 1 } \1; 37} 38