]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/34-glob.t
5.13.2 calls get magic on globs
[perl/modules/Variable-Magic.git] / t / 34-glob.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 eval "use Symbol qw/gensym/";
9 if ($@) {
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
16 use Variable::Magic qw/cast dispell VMG_COMPAT_GLOB_GET/;
17
18 my %get = VMG_COMPAT_GLOB_GET ? (get => 1) : ();
19
20 use lib 't/lib';
21 use Variable::Magic::TestWatcher;
22
23 my $wiz = init_watcher
24         [ qw/get set len clear free copy dup local fetch store exists delete/ ],
25         'glob';
26
27 local *a = gensym();
28
29 watch { cast *a, $wiz } +{ }, 'cast';
30
31 watch { local *b = *a } +{ %get }, 'assign to';
32
33 watch { *a = gensym() } +{ %get, set => 1 }, 'assign';
34
35 watch {
36  local *b = gensym();
37  watch { cast *b, $wiz } +{ }, 'cast 2';
38 } +{ }, 'scope end';
39
40 watch { undef *a } +{ %get }, 'undef';
41
42 watch { dispell *a, $wiz } +{ %get }, 'dispell';