X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F23-clear.t;h=3af5545755e7e3e1585a10c04c4a280be1b7197e;hb=HEAD;hp=d07d4b01958b843a26be53ebd793752f3cd9bdd9;hpb=47fcdae90d7af36c40b950c1154fa2dd306b5edb;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/23-clear.t b/t/23-clear.t index d07d4b0..3af5545 100644 --- a/t/23-clear.t +++ b/t/23-clear.t @@ -3,25 +3,37 @@ use strict; use warnings; -use Test::More tests => 2 * 5 + 2 + 1; +use Test::More tests => (2 * 5 + 2) + (2 * 2 + 1) + 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 'clear', 'clear'; +my $wiz = init_watcher 'clear', 'clear'; -my @a = qw/a b c/; +my @a = qw; -check { cast @a, $wiz } { }, 'cast array'; +watch { cast @a, $wiz } { }, 'cast array'; -check { @a = () } { clear => 1 }, 'clear array'; +watch { @a = () } { clear => 1 }, 'clear array'; is_deeply \@a, [ ], 'clear: clear array correctly'; my %h = (foo => 1, bar => 2); -check { cast %h, $wiz } { }, 'cast hash'; +watch { cast %h, $wiz } { }, 'cast hash'; -check { %h = () } { clear => 1 }, 'clear hash'; +watch { %h = () } { clear => 1 }, 'clear hash'; is_deeply \%h, { }, 'clear: clear hash correctly'; + +{ + my @val = (4 .. 6); + + my $wv = init_value @val, 'clear', 'clear'; + + value { @val = () } [ 4 .. 6 ]; + + dispell @val, $wv; + is_deeply \@val, [ ], 'clear: value after'; +}