]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/34-glob.t
Switch to qw<>
[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 BEGIN {
9  local $@;
10  if (eval "use Symbol qw<gensym>; 1") {
11   plan tests => 2 * 12 + 1;
12   defined and diag "Using Symbol $_" for $Symbol::VERSION;
13  } else {
14   plan skip_all => "Symbol::gensym required for testing magic for globs";
15  }
16 }
17
18 use Variable::Magic qw<cast dispell VMG_COMPAT_GLOB_GET>;
19
20 my %get = VMG_COMPAT_GLOB_GET ? (get => 1) : ();
21
22 use lib 't/lib';
23 use Variable::Magic::TestWatcher;
24
25 my $wiz = init_watcher
26         [ qw<get set len clear free copy dup local fetch store exists delete> ],
27         'glob';
28
29 local *a = gensym();
30
31 watch { cast *a, $wiz } +{ }, 'cast';
32
33 watch { local *b = *a } +{ %get }, 'assign to';
34
35 watch { *a = \1 }          +{ %get, set => 1 }, 'assign scalar slot';
36 watch { *a = [ qw<x y> ] } +{ %get, set => 1 }, 'assign array slot';
37 watch { *a = { u => 1 } }  +{ %get, set => 1 }, 'assign hash slot';
38 watch { *a = sub { } }     +{ %get, set => 1 }, 'assign code slot';
39
40 watch { *a = gensym() }    +{ %get, set => 1 }, 'assign glob';
41
42 watch {
43  local *b = gensym();
44  watch { cast *b, $wiz } +{ }, 'cast 2';
45 } +{ }, 'scope end';
46
47 %get = () if $] >= 5.013007;
48
49 watch { undef *a } +{ %get }, 'undef';
50
51 watch { dispell *a, $wiz } +{ %get }, 'dispell';