]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/23-clear.t
Test when magic actions take place
[perl/modules/Variable-Magic.git] / t / 23-clear.t
index 3f7f57e7ed8d0928b4a5db1c36aa65ad93352ea7..a3aad82ded0d9e07f14c90ac9ab46600e07163ab 100644 (file)
@@ -3,12 +3,13 @@
 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/cast dispell/;
 
 use lib 't/lib';
 use Variable::Magic::TestWatcher;
+use Variable::Magic::TestValue;
 
 my $wiz = init_watcher 'clear', 'clear';
 
@@ -25,3 +26,14 @@ watch { cast %h, $wiz } { }, 'cast 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';
+}