use strict;
use warnings;
-use Test::More tests => (2 * 14 + 2) + 2 * (2 * 8 + 4) + 1;
+use Config qw/%Config/;
-use Variable::Magic qw/cast dispell/;
+use Test::More tests => (2 * 14 + 2) + 2 * (2 * 8 + 4) + 3 + 1;
+
+use Variable::Magic qw/wizard cast dispell MGf_COPY/;
use lib 't/lib';
use Variable::Magic::TestWatcher;
check { $h{b} = 4 } { }, 'hash element: set after delete';
+SKIP: {
+ my $SKIP;
+
+ unless (MGf_COPY) {
+ $SKIP = 'No copy magic for this perl';
+ } elsif ($Config{useithreads} and $] le 5.008003) {
+ $SKIP = 'Causes havoc during global destruction for old threaded perls';
+ } else {
+ eval "use Tie::Array";
+ $SKIP = 'Tie::Array required to test clear magic on tied array values' if $@;
+ }
+
+ skip $SKIP => 3 if $SKIP;
+ diag "Using Tie::Array $Tie::Array::VERSION" if defined $Tie::Array::VERSION;
+
+ tie my @a, 'Tie::StdArray';
+ $a[0] = $$;
+
+ eval {
+ cast @a, wizard copy => sub { cast $_[3], $wiz; () };
+ };
+ is $@, '', 'cast copy magic on tied array';
+
+ check { delete $a[0] } [ qw/get clear free/ ], 'delete from tied array';
+}