X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=t%2F32-array-kv.t;fp=t%2F32-array-kv.t;h=9ca1f0579e04f3d1ff1ca796d25eb081b030b32a;hb=c79d4e423275faf328a1cdb9e47fdd1ba432388d;hp=0000000000000000000000000000000000000000;hpb=3d65456241cf253443837fd0d69a8ddb753ae49a;p=perl%2Fmodules%2Fautovivification.git diff --git a/t/32-array-kv.t b/t/32-array-kv.t new file mode 100644 index 0000000..9ca1f05 --- /dev/null +++ b/t/32-array-kv.t @@ -0,0 +1,103 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More; + +BEGIN { + if ($] >= 5.011) { plan tests => 9 * 3 * 64 } else { plan skip_all => 'perl 5.11 required for keys/values @array' } +} + +use lib 't/lib'; +use autovivification::TestCases; + +while () { + 1 while chomp; + next unless /#/; + testcase_ok($_, '@'); +} + +__DATA__ + +--- keys --- + +$x # keys @$x # '', 0, [ ] +$x # keys @$x # '', 0, undef # +$x # keys @$x # '', 0, undef # +fetch +$x # keys @$x # '', 0, [ ] # +exists +$x # keys @$x # '', 0, [ ] # +delete +$x # keys @$x # '', 0, [ ] # +store + +$x # keys @$x # qr/^Reference vivification forbidden/, undef, undef # +strict +fetch +$x # keys @$x # '', 0, [ ] # +strict +exists +$x # keys @$x # '', 0, [ ] # +strict +delete +$x # keys @$x # '', 0, [ ] # +strict +store + +$x # [ keys @$x ] # '', [ ], [ ] +$x # [ keys @$x ] # '', [ ], undef # +$x # [ keys @$x ] # '', [ ], undef # +fetch +$x # [ keys @$x ] # '', [ ], [ ] # +exists +delete +store + +$x->[0] = 1 # [ keys @$x ] # '', [0], [ 1 ] +$x->[0] = 1 # [ keys @$x ] # '', [0], [ 1 ] # +$x->[0] = 1 # [ keys @$x ] # '', [0], [ 1 ] # +fetch +$x->[0] = 1 # [ keys @$x ] # '', [0], [ 1 ] # +exists +delete +store + +$x # keys @{$x->[0]} # '', 0, [ [ ] ] +$x # keys @{$x->[0]} # '', 0, undef # +$x # keys @{$x->[0]} # '', 0, undef # +fetch +$x # keys @{$x->[0]} # '', 0, [ [ ] ] # +exists +$x # keys @{$x->[0]} # '', 0, [ [ ] ] # +delete +$x # keys @{$x->[0]} # '', 0, [ [ ] ] # +store + +$x # keys @{$x->[0]} # qr/^Reference vivification forbidden/, undef, undef # +strict +fetch +$x # keys @{$x->[0]} # '', 0, [ [ ] ] # +strict +exists +$x # keys @{$x->[0]} # '', 0, [ [ ] ] # +strict +delete +$x # keys @{$x->[0]} # '', 0, [ [ ] ] # +strict +store + +$x # [ keys @{$x->[0]} ] # '', [ ], [ [ ] ] +$x # [ keys @{$x->[0]} ] # '', [ ], undef # +$x # [ keys @{$x->[0]} ] # '', [ ], undef # +fetch +$x # [ keys @{$x->[0]} ] # '', [ ], [ [ ] ] # +exists +delete +store + +--- values --- + +$x # values @$x # '', 0, [ ] +$x # values @$x # '', 0, undef # +$x # values @$x # '', 0, undef # +fetch +$x # values @$x # '', 0, [ ] # +exists +$x # values @$x # '', 0, [ ] # +delete +$x # values @$x # '', 0, [ ] # +store + +$x # values @$x # qr/^Reference vivification forbidden/, undef, undef # +strict +fetch +$x # values @$x # '', 0, [ ] # +strict +exists +$x # values @$x # '', 0, [ ] # +strict +delete +$x # values @$x # '', 0, [ ] # +strict +store + +$x # [ values @$x ] # '', [ ], [ ] +$x # [ values @$x ] # '', [ ], undef # +$x # [ values @$x ] # '', [ ], undef # +fetch +$x # [ values @$x ] # '', [ ], [ ] # +exists +delete +store + +$x->[0] = 1 # [ values @$x ] # '', [ 1 ], [ 1 ] +$x->[0] = 1 # [ values @$x ] # '', [ 1 ], [ 1 ] # +$x->[0] = 1 # [ values @$x ] # '', [ 1 ], [ 1 ] # +fetch +$x->[0] = 1 # [ values @$x ] # '', [ 1 ], [ 1 ] # +exists +delete +store + +$x # values @{$x->[0]} # '', 0, [ [ ] ] +$x # values @{$x->[0]} # '', 0, undef # +$x # values @{$x->[0]} # '', 0, undef # +fetch +$x # values @{$x->[0]} # '', 0, [ [ ] ] # +exists +$x # values @{$x->[0]} # '', 0, [ [ ] ] # +delete +$x # values @{$x->[0]} # '', 0, [ [ ] ] # +store + +$x # values @{$x->[0]} # qr/^Reference vivification forbidden/, undef, undef # +strict +fetch +$x # values @{$x->[0]} # '', 0, [ [ ] ] # +strict +exists +$x # values @{$x->[0]} # '', 0, [ [ ] ] # +strict +delete +$x # values @{$x->[0]} # '', 0, [ [ ] ] # +strict +store + +$x # [ values @{$x->[0]} ] # '', [ ], [ [ ] ] +$x # [ values @{$x->[0]} ] # '', [ ], undef # +$x # [ values @{$x->[0]} ] # '', [ ], undef # +fetch +$x # [ values @{$x->[0]} ] # '', [ ], [ [ ] ] # +exists +delete +store