]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/23-clear.t
3f7f57e7ed8d0928b4a5db1c36aa65ad93352ea7
[perl/modules/Variable-Magic.git] / t / 23-clear.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 2 * 5 + 2 + 1;
7
8 use Variable::Magic qw/cast/;
9
10 use lib 't/lib';
11 use Variable::Magic::TestWatcher;
12
13 my $wiz = init_watcher 'clear', 'clear';
14
15 my @a = qw/a b c/;
16
17 watch { cast @a, $wiz } { }, 'cast array';
18
19 watch { @a = () } { clear => 1 }, 'clear array';
20 is_deeply \@a, [ ], 'clear: clear array correctly';
21
22 my %h = (foo => 1, bar => 2);
23
24 watch { cast %h, $wiz } { }, 'cast hash';
25
26 watch { %h = () } { clear => 1 }, 'clear hash';
27 is_deeply \%h, { }, 'clear: clear hash correctly';