1#!perl -T
2
3use strict;
4use warnings;
5
6use Test::More;
7
8eval "use Symbol qw/gensym/";
9if ($@) {
10 plan skip_all => "Symbol::gensym required for testing magic for globs";
11} else {
12 plan tests => 2 * 8 + 1;
13 diag "Using Symbol $Symbol::VERSION" if defined $Symbol::VERSION;
14}
15
16use Variable::Magic qw/cast dispell VMG_COMPAT_GLOB_GET/;
17
18my %get = VMG_COMPAT_GLOB_GET ? (get => 1) : ();
19
20use lib 't/lib';
21use Variable::Magic::TestWatcher;
22
23my $wiz = init_watcher
24        [ qw/get set len clear free copy dup local fetch store exists delete/ ],
25        'glob';
26
27local *a = gensym();
28
29watch { cast *a, $wiz } +{ }, 'cast';
30
31watch { local *b = *a } +{ %get }, 'assign to';
32
33watch { *a = gensym() } +{ %get, set => 1 }, 'assign';
34
35watch {
36 local *b = gensym();
37 watch { cast *b, $wiz } +{ }, 'cast 2';
38} +{ }, 'scope end';
39
40watch { undef *a } +{ %get }, 'undef';
41
42watch { dispell *a, $wiz } +{ %get }, 'dispell';
43