]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - t/25-copy.t
Test when magic actions take place
[perl/modules/Variable-Magic.git] / t / 25-copy.t
index 5ebcbe03406b17a61f63ecba11f7dc00738e3077..98fbf22d3fcdf378e417ee675e031393dd9b0a1c 100644 (file)
@@ -5,22 +5,24 @@ use warnings;
 
 use Test::More;
 
-use Variable::Magic qw/cast MGf_COPY/;
+use Variable::Magic qw/cast dispell MGf_COPY/;
 
 if (MGf_COPY) {
- plan tests => 2 + (2 * 5 + 3) + (2 * 9 + 6) + 1;
+ plan tests => 2 + ((2 * 5 + 3) + (2 * 2 + 1)) + (2 * 9 + 6) + 1;
 } else {
  plan skip_all => 'No copy magic for this perl';
 }
 
 use lib 't/lib';
 use Variable::Magic::TestWatcher;
+use Variable::Magic::TestValue;
 
 my $wiz = init_watcher 'copy', 'copy';
 
 SKIP: {
  eval "use Tie::Array";
- skip 'Tie::Array required to test copy magic on arrays', 2 * 5 + 3 if $@;
+ skip 'Tie::Array required to test copy magic on arrays'
+                                             => (2 * 5 + 3) + (2 * 2 + 1) if $@;
  diag "Using Tie::Array $Tie::Array::VERSION" if defined $Tie::Array::VERSION;
 
  tie my @a, 'Tie::StdArray';
@@ -38,6 +40,18 @@ SKIP: {
  ok $s, 'copy: tied array exists correctly';
 
  watch { undef @a } { }, 'tied array undef';
+
+ {
+  tie my @val, 'Tie::StdArray';
+  @val = (4 .. 6);
+
+  my $wv = init_value @val, 'copy', 'copy';
+
+  value { $val[3] = 8 } [ 4 .. 6 ];
+
+  dispell @val, $wv;
+  is_deeply \@val, [ 4 .. 6, 8 ], 'copy: value after';
+ }
 }
 
 SKIP: {