]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blob - t/34-glob.t
Update VPIT::TestHelpers to e8344578
[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 use lib 't/lib';
9 use VPIT::TestHelpers;
10
11 BEGIN {
12  load_or_skip_all('Symbol', undef, [ 'gensym' ]);
13  plan tests => 2 * 17 + 1;
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 SKIP: {
34  skip 'This failed temporarily between perls 5.13.1 and 5.13.8 (included)'
35                             => 5 * 2 if "$]" >= 5.013_001 and "$]" <= 5.013_008;
36
37  my $cxt = 'void contex';
38  my $exp = { set => 1 };
39
40  watch { *a = \1 }          $exp, "assign scalar slot in $cxt";
41  watch { *a = [ qw<x y> ] } $exp, "assign array slot in $cxt";
42  watch { *a = { u => 1 } }  $exp, "assign hash slot in $cxt";
43  watch { *a = sub { } }     $exp, "assign code slot in $cxt";
44  watch { *a = gensym() }    $exp, "assign glob in $cxt";
45 }
46
47 {
48  my $cxt = 'scalar context';
49  my $exp = { %get, set => 1 };
50  my $v;
51
52  $v = watch { *a = \1 }          $exp, "assign scalar slot in $cxt";
53  $v = watch { *a = [ qw<x y> ] } $exp, "assign array slot in $cxt";
54  $v = watch { *a = { u => 1 } }  $exp, "assign hash slot in $cxt";
55  $v = watch { *a = sub { } }     $exp, "assign code slot in $cxt";
56  $v = watch { *a = gensym() }    $exp, "assign glob in $cxt";
57 }
58
59 watch {
60  local *b = gensym();
61  watch { cast *b, $wiz } +{ }, 'cast 2';
62 } +{ }, 'scope end';
63
64 %get = () if "$]" >= 5.013_007;
65
66 watch { undef *a } +{ %get }, 'undef';
67
68 watch { dispell *a, $wiz } +{ %get }, 'dispell';