X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F21-set.t;h=70af0e41fc2bfcf173867d243589e112ceeb8d96;hb=HEAD;hp=b81684fdb7eff8b31ed401d2b52d76b0f1398391;hpb=ce101a145be6761a5ea535ea9ec2872477842231;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/21-set.t b/t/21-set.t index b81684f..70af0e4 100644 --- a/t/21-set.t +++ b/t/21-set.t @@ -3,26 +3,35 @@ use strict; use warnings; -use Test::More tests => 2 * 5 + 3 + 1; +use Test::More tests => (2 * 5 + 3) + (2 * 2 + 1); -use Variable::Magic qw/cast/; +use Variable::Magic qw; use lib 't/lib'; use Variable::Magic::TestWatcher; +use Variable::Magic::TestValue; -my $wiz = init 'set', 'set'; +my $wiz = init_watcher 'set', 'set'; my $a = 0; -check { cast $a, $wiz } { }, 'cast'; +watch { cast $a, $wiz } { }, 'cast'; my $n = int rand 1000; -check { $a = $n } { set => 1 }, 'assign'; +watch { $a = $n } { set => 1 }, 'assign'; is $a, $n, 'set: assign correctly'; -check { ++$a } { set => 1 }, 'increment'; +watch { ++$a } { set => 1 }, 'increment'; is $a, $n + 1, 'set: increment correctly'; -check { --$a } { set => 1 }, 'decrement'; +watch { --$a } { set => 1 }, 'decrement'; is $a, $n, 'set: decrement correctly'; + +{ + my $val = 0; + + init_value $val, 'set', 'set'; + + value { $val = 1 } \1; +}