10 if (eval "use Symbol qw<gensym>; 1") {
11 plan tests => 2 * 17 + 1;
12 defined and diag "Using Symbol $_" for $Symbol::VERSION;
14 plan skip_all => "Symbol::gensym required for testing magic for globs";
18 use Variable::Magic qw<cast dispell VMG_COMPAT_GLOB_GET>;
20 my %get = VMG_COMPAT_GLOB_GET ? (get => 1) : ();
23 use Variable::Magic::TestWatcher;
25 my $wiz = init_watcher
26 [ qw<get set len clear free copy dup local fetch store exists delete> ],
31 watch { cast *a, $wiz } +{ }, 'cast';
33 watch { local *b = *a } +{ %get }, 'assign to';
36 skip 'This failed temporarily between perls 5.13.1 and 5.13.8 (included)'
37 => 5 * 2 if "$]" >= 5.013_001 and "$]" <= 5.013_008;
39 my $cxt = 'void contex';
40 my $exp = { set => 1 };
42 watch { *a = \1 } $exp, "assign scalar slot in $cxt";
43 watch { *a = [ qw<x y> ] } $exp, "assign array slot in $cxt";
44 watch { *a = { u => 1 } } $exp, "assign hash slot in $cxt";
45 watch { *a = sub { } } $exp, "assign code slot in $cxt";
46 watch { *a = gensym() } $exp, "assign glob in $cxt";
50 my $cxt = 'scalar context';
51 my $exp = { %get, set => 1 };
54 $v = watch { *a = \1 } $exp, "assign scalar slot in $cxt";
55 $v = watch { *a = [ qw<x y> ] } $exp, "assign array slot in $cxt";
56 $v = watch { *a = { u => 1 } } $exp, "assign hash slot in $cxt";
57 $v = watch { *a = sub { } } $exp, "assign code slot in $cxt";
58 $v = watch { *a = gensym() } $exp, "assign glob in $cxt";
63 watch { cast *b, $wiz } +{ }, 'cast 2';
66 %get = () if "$]" >= 5.013_007;
68 watch { undef *a } +{ %get }, 'undef';
70 watch { dispell *a, $wiz } +{ %get }, 'dispell';