]> git.vpit.fr Git - perl/modules/autovivification.git/blob - t/34-array-numerous.t
This is 0.18
[perl/modules/autovivification.git] / t / 34-array-numerous.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 2 * 2 * 4;
7
8 my $n = 100;
9 my $i = 0;
10
11 {
12  my $w;
13  {
14   my $r;
15   no autovivification;
16   $r = $w->[0][$i] for 1 .. $n;
17  }
18  is_deeply $w, undef, 'numerous fetches from an undef lexical';
19
20  $w = [ undef ];
21  {
22   my $r;
23   no autovivification;
24   $r = $w->[0][$i] for 1 .. $n;
25  }
26  is_deeply $w, [ undef ], 'numerous fetches from a 1-level arrayref lexical';
27 }
28
29 {
30  our $w;
31  {
32   my $r;
33   no autovivification;
34   $r = $w->[0][$i] for 1 .. $n;
35  }
36  is_deeply $w, undef, 'numerous fetches from an undef global';
37
38  $w = [ undef ];
39  {
40   my $r;
41   no autovivification;
42   $r = $w->[0][$i] for 1 .. $n;
43  }
44  is_deeply $w, [ undef ], 'numerous fetches from a 1-level arrayref global';
45 }
46
47 {
48  my $x;
49  {
50   my @r;
51   no autovivification;
52   @r = @{$x}[0, 1] for 1 .. $n;
53  }
54  is_deeply $x, undef, 'numerous slices from an undef lexical';
55
56  $x = [ undef ];
57  {
58   my @r;
59   no autovivification;
60   @r = @{$x->[0]}[0, 1] for 1 .. $n;
61  }
62  is_deeply $x, [ undef ], 'numerous slices from a 1-level arrayref lexical';
63 }
64
65 {
66  our $x;
67  {
68   my @r;
69   no autovivification;
70   @r = @{$x}[0, 1] for 1 .. $n;
71  }
72  is_deeply $x, undef, 'numerous slices from an undef global';
73
74  $x = [ undef ];
75  {
76   my @r;
77   no autovivification;
78   @r = @{$x->[0]}[0, 1] for 1 .. $n;
79  }
80  is_deeply $x, [ undef ], 'numerous slices from a 1-level arrayref global';
81 }
82 {
83  my $y;
84  {
85   my $r;
86   no autovivification;
87   $r = exists $y->[0][$i] for 1 .. $n;
88  }
89  is_deeply $y, undef, 'numerous exists from an undef lexical';
90
91  $y = [ undef ];
92  {
93   my $r;
94   no autovivification;
95   $r = exists $y->[0][$i] for 1 .. $n;
96  }
97  is_deeply $y, [ undef ], 'numerous exists from a 1-level arrayref lexical';
98 }
99
100 {
101  our $y;
102  {
103   my $r;
104   no autovivification;
105   $r = exists $y->[0][$i] for 1 .. $n;
106  }
107  is_deeply $y, undef, 'numerous exists from an undef global';
108
109  $y = [ undef ];
110  {
111   my $r;
112   no autovivification;
113   $r = exists $y->[0][$i] for 1 .. $n;
114  }
115  is_deeply $y, [ undef ], 'numerous exists from a 1-level arrayref global';
116 }
117
118 {
119  my $z;
120  {
121   my $r;
122   no autovivification;
123   $r = delete $z->[0][$i] for 1 .. $n;
124  }
125  is_deeply $z, undef, 'numerous deletes from an undef lexical';
126
127  $z = [ undef ];
128  {
129   my $r;
130   no autovivification;
131   $r = delete $z->[0][$i] for 1 .. $n;
132  }
133  is_deeply $z, [ undef ], 'numerous deletes from a 1-level arrayref lexical';
134 }
135
136 {
137  our $z;
138  {
139   my $r;
140   no autovivification;
141   $r = delete $z->[0][$i] for 1 .. $n;
142  }
143  is_deeply $z, undef, 'numerous deletes from an undef global';
144
145  $z = [ undef ];
146  {
147   my $r;
148   no autovivification;
149   $r = delete $z->[0][$i] for 1 .. $n;
150  }
151  is_deeply $z, [ undef ], 'numerous deletes from a 1-level arrayref global';
152 }