diff options
author | Aaron Crane <arc@cpan.org> | 2015-06-11 17:24:13 +0100 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2015-07-13 14:08:34 +0100 |
commit | 262309092c2de925e7ae4a527174f8dc2a0ec7b7 (patch) | |
tree | fc20e8ab0b42c87c232e3b233556fafe2ac85076 /t | |
parent | de6cb0abd243e5772b9783a2cbeef5755a8267d6 (diff) | |
download | perl-262309092c2de925e7ae4a527174f8dc2a0ec7b7.tar.gz |
Delete experimental autoderef feature
Diffstat (limited to 't')
-rw-r--r-- | t/lib/croak/op | 12 | ||||
-rw-r--r-- | t/lib/warnings/op | 56 | ||||
-rw-r--r-- | t/op/coresubs.t | 12 | ||||
-rw-r--r-- | t/op/cproto.t | 16 | ||||
-rw-r--r-- | t/op/kvaslice.t | 20 | ||||
-rw-r--r-- | t/op/kvhslice.t | 20 | ||||
-rw-r--r-- | t/op/push.t | 38 | ||||
-rw-r--r-- | t/op/smartkve.t | 400 | ||||
-rw-r--r-- | t/op/splice.t | 4 | ||||
-rw-r--r-- | t/op/tie_fetch_count.t | 10 | ||||
-rw-r--r-- | t/op/unshift.t | 35 |
11 files changed, 70 insertions, 553 deletions
diff --git a/t/lib/croak/op b/t/lib/croak/op index 2d2887d9b2..cd3a6544e3 100644 --- a/t/lib/croak/op +++ b/t/lib/croak/op @@ -111,31 +111,27 @@ EXPECT exists argument is not a subroutine name at - line 1. ######## # NAME push BAREWORD -no warnings 'experimental'; push FRED; EXPECT -Type of arg 1 to push must be array (not constant item) at - line 2, near "FRED;" +Type of arg 1 to push must be array (not constant item) at - line 1, near "FRED;" Execution of - aborted due to compilation errors. ######## # NAME pop BAREWORD -no warnings 'experimental'; pop FRED; EXPECT -Type of arg 1 to pop must be array (not constant item) at - line 2, near "FRED;" +Type of arg 1 to pop must be array (not constant item) at - line 1, near "FRED;" Execution of - aborted due to compilation errors. ######## # NAME shift BAREWORD -no warnings 'experimental'; shift FRED; EXPECT -Type of arg 1 to shift must be array (not constant item) at - line 2, near "FRED;" +Type of arg 1 to shift must be array (not constant item) at - line 1, near "FRED;" Execution of - aborted due to compilation errors. ######## # NAME unshift BAREWORD -no warnings 'experimental'; unshift FRED; EXPECT -Type of arg 1 to unshift must be array (not constant item) at - line 2, near "FRED;" +Type of arg 1 to unshift must be array (not constant item) at - line 1, near "FRED;" Execution of - aborted due to compilation errors. ######## # NAME keys BAREWORD diff --git a/t/lib/warnings/op b/t/lib/warnings/op index 477fdad286..d2f8e577d2 100644 --- a/t/lib/warnings/op +++ b/t/lib/warnings/op @@ -61,12 +61,6 @@ format FRED = . - push on reference is experimental [ck_fun] - pop on reference is experimental - shift on reference is experimental - unshift on reference is experimental - splice on reference is experimental - Statement unlikely to be reached (Maybe you meant system() when you said exec()? exec "true" ; my $a @@ -82,10 +76,6 @@ $[ used in comparison (did you mean $] ?) - each on reference is experimental [ck_each] - keys on reference is experimental - values on reference is experimental - length() used on @array (did you mean "scalar(@array)"?) length() used on %hash (did you mean "scalar(keys %hash)"?) @@ -240,12 +230,6 @@ use constant phoo => 1..3; @h{localtime 0}; @h{gmtime 0}; @h{eval ""}; -{ - no warnings 'experimental::autoderef'; - @h{each $foo} if 0; - @h{keys $foo} if 0; - @h{values $foo} if 0; -} # arrays @h[qw"a b c"] = 1..3; @@ -283,12 +267,6 @@ use constant phoo => 1..3; @h[localtime 0]; @h[gmtime 0]; @h[eval ""]; -{ - no warnings 'experimental::autoderef'; - @h[each $foo] if 0; - @h[keys $foo] if 0; - @h[values $foo] if 0; -} EXPECT ######## # op.c @@ -1053,26 +1031,6 @@ format FRED = EXPECT Format FRED redefined at - line 5. ######## -# op.c [Perl_ck_fun] -$fred = []; -push $fred; -pop $fred; -shift $fred; -unshift $fred; -splice $fred; -no warnings 'experimental::autoderef' ; -push $fred; -pop $fred; -shift $fred; -unshift $fred; -splice $fred; -EXPECT -push on reference is experimental at - line 3. -pop on reference is experimental at - line 4. -shift on reference is experimental at - line 5. -unshift on reference is experimental at - line 6. -splice on reference is experimental at - line 7. -######## # op.c use warnings 'exec' ; exec "$^X -e 1" ; @@ -1394,20 +1352,6 @@ $[ used in numeric gt (>) (did you mean $] ?) at - line 18. $[ used in numeric le (<=) (did you mean $] ?) at - line 19. $[ used in numeric ge (>=) (did you mean $] ?) at - line 20. ######## -# op.c [Perl_ck_each] -$fred = {}; -keys $fred; -values $fred; -each $fred; -no warnings 'experimental::autoderef' ; -keys $fred; -values $fred; -each $fred; -EXPECT -keys on reference is experimental at - line 3. -values on reference is experimental at - line 4. -each on reference is experimental at - line 5. -######## # op.c [Perl_ck_length] use warnings 'syntax' ; length(@a); diff --git a/t/op/coresubs.t b/t/op/coresubs.t index 6fec5f4c75..c18fdcde93 100644 --- a/t/op/coresubs.t +++ b/t/op/coresubs.t @@ -166,18 +166,6 @@ $tests++; ok eval { *CORE::exit = \42 }, '[rt.cpan.org #74289] *CORE::foo is not accidentally made read-only'; -for my $word (qw<keys values each>) { - # mykeys() etc were aliased to \&CORE::keys etc above - my $code = qq{ - no warnings 'experimental::autoderef'; - my \$x = []; - () = my$word(\$x); - 'ok' - }; - $tests++; - is(eval($code), 'ok', "inlined $word() on autoderef array") or diag $@; -} - inlinable_ok($_, '$_{k}', 'on hash') for qw<delete exists>; diff --git a/t/op/cproto.t b/t/op/cproto.t index b2f07f76c1..aace8aa036 100644 --- a/t/op/cproto.t +++ b/t/op/cproto.t @@ -75,7 +75,7 @@ delete undef die (@) do undef dump () -each (+) +each (\[%@]) else undef elsif undef endgrent () @@ -140,7 +140,7 @@ index ($$;$) int (_) ioctl (*$$) join ($@) -keys (+) +keys (\[%@]) kill (@) last undef lc (_) @@ -176,12 +176,12 @@ our undef pack ($@) package undef pipe (**) -pop (;+) +pop (;\@) pos (;\[$*]) print undef printf undef prototype (_) -push (+@) +push (\@@) q undef qq undef qr undef @@ -224,7 +224,7 @@ setprotoent ($) setpwent () setservent ($) setsockopt (*$$$) -shift (;+) +shift (;\@) shmctl ($$$) shmget ($$$) shmread ($$$$) @@ -235,7 +235,7 @@ sleep (;$) socket (*$$$) socketpair (**$$$) sort undef -splice (+;$$@) +splice (\@;$$@) split undef sprintf ($@) sqrt (_) @@ -267,12 +267,12 @@ undef (;\[$@%&*]) unless undef unlink (@) unpack ($_) -unshift (+@) +unshift (\@@) untie (\[$@%*]) until undef use undef utime (@) -values (+) +values (\[%@]) vec ($$$) wait () waitpid ($$) diff --git a/t/op/kvaslice.t b/t/op/kvaslice.t index 16ee4467f2..aec9a97801 100644 --- a/t/op/kvaslice.t +++ b/t/op/kvaslice.t @@ -8,7 +8,7 @@ BEGIN { # use strict; -plan tests => 40; +plan tests => 39; # simple use cases { @@ -178,17 +178,19 @@ plan tests => 40; ok( !exists $a[3], "no autovivification" ); } -# keys/value/each treat argument as scalar +# keys/value/each refuse to compile kvaslice { my %h = 'a'..'b'; my @i = \%h; - no warnings 'syntax', 'experimental::autoderef'; - my ($k,$v) = each %i[0]; - is $k, 'a', 'key returned by each %array[ix]'; - is $v, 'b', 'val returned by each %array[ix]'; - %h = 1..10; - is join('-', sort keys %i[(0)]), '1-3-5-7-9', 'keys %array[ix]'; - is join('-', sort values %i[(0)]), '10-2-4-6-8', 'values %array[ix]'; + eval '() = keys %i[(0)]'; + like($@, qr/Experimental keys on scalar is now forbidden/, + 'keys %array[ix] forbidden'); + eval '() = values %i[(0)]'; + like($@, qr/Experimental values on scalar is now forbidden/, + 'values %array[ix] forbidden'); + eval '() = each %i[(0)]'; + like($@, qr/Experimental each on scalar is now forbidden/, + 'each %array[ix] forbidden'); } # \% prototype expects hash deref diff --git a/t/op/kvhslice.t b/t/op/kvhslice.t index a5357adb85..2bc633423f 100644 --- a/t/op/kvhslice.t +++ b/t/op/kvhslice.t @@ -8,7 +8,7 @@ BEGIN { # use strict; -plan tests => 40; +plan tests => 39; # simple use cases { @@ -184,17 +184,19 @@ plan tests => 40; ok( !exists $h{e}, "no autovivification" ); } -# keys/value/each treat argument as scalar +# keys/value/each refuse to compile kvhslice { my %h = 'a'..'b'; my %i = (foo => \%h); - no warnings 'syntax', 'experimental::autoderef'; - my ($k,$v) = each %i{foo=>}; - is $k, 'a', 'key returned by each %hash{key}'; - is $v, 'b', 'val returned by each %hash{key}'; - %h = 1..10; - is join('-', sort keys %i{foo=>}), '1-3-5-7-9', 'keys %hash{key}'; - is join('-', sort values %i{foo=>}), '10-2-4-6-8', 'values %hash{key}'; + eval '() = keys %i{foo=>}'; + like($@, qr/Experimental keys on scalar is now forbidden/, + 'keys %hash{key} forbidden'); + eval '() = values %i{foo=>}'; + like($@, qr/Experimental values on scalar is now forbidden/, + 'values %hash{key} forbidden'); + eval '() = each %i{foo=>}'; + like($@, qr/Experimental each on scalar is now forbidden/, + 'each %hash{key} forbidden'); } # \% prototype expects hash deref diff --git a/t/op/push.t b/t/op/push.t index f4b034f81b..c94c91953f 100644 --- a/t/op/push.t +++ b/t/op/push.t @@ -20,7 +20,7 @@ BEGIN { -4, 4 5 6 7, 0 1 2 3 EOF -plan tests => 14 + @tests*4; +plan tests => 8 + @tests*2; die "blech" unless @tests; @x = (1,2,3); @@ -29,37 +29,20 @@ is( join(':',@x), '1:2:3:1:2:3', 'push array onto array'); push(@x,4); is( join(':',@x), '1:2:3:1:2:3:4', 'push integer onto array'); -no warnings 'experimental::autoderef'; - -# test for push/pop on arrayref -push(\@x,5); -is( join(':',@x), '1:2:3:1:2:3:4:5', 'push arrayref'); -pop(\@x); -is( join(':',@x), '1:2:3:1:2:3:4', 'pop arrayref'); - # test autovivification push @$undef1, 1, 2, 3; is( join(':',@$undef1), '1:2:3', 'autovivify array'); -# test push on undef (error) -eval { push $undef2, 1, 2, 3 }; -like( $@, qr/Not an ARRAY/, 'push on undef generates an error'); - -# test constant -use constant CONST_ARRAYREF => [qw/a b c/]; -push CONST_ARRAYREF(), qw/d e f/; -is( join(':',@{CONST_ARRAYREF()}), 'a:b:c:d:e:f', 'test constant'); - # test implicit dereference errors eval "push 42, 0, 1, 2, 3"; like ( $@, qr/must be array/, 'push onto a literal integer'); $hashref = { }; -eval { push $hashref, 0, 1, 2, 3 }; -like( $@, qr/Not an ARRAY reference/, 'push onto a hashref'); +eval q{ push $hashref, 0, 1, 2, 3 }; +like( $@, qr/Experimental push on scalar is now forbidden/, 'push onto a hashref'); -eval { push bless([]), 0, 1, 2, 3 }; -like( $@, qr/Not an unblessed ARRAY reference/, 'push onto a blessed array ref'); +eval q{ push bless([]), 0, 1, 2, 3 }; +like( $@, qr/Experimental push on scalar is now forbidden/, 'push onto a blessed array ref'); $test = 13; @@ -67,13 +50,9 @@ $test = 13; { my($first, $second) = ([1], [2]); sub two_things { return +($first, $second) } - push two_things(), 3; + push @{ two_things() }, 3; is( join(':',@$first), '1', "\$first = [ @$first ];"); is( join(':',@$second), '2:3', "\$second = [ @$second ]"); - - push @{ two_things() }, 4; - is( join(':',@$first), '1', "\$first = [ @$first ];"); - is( join(':',@$second), '2:3:4', "\$second = [ @$second ]"); } foreach $line (@tests) { @@ -82,19 +61,14 @@ foreach $line (@tests) { @get = split(' ',$get); @leave = split(' ',$leave); @x = (0,1,2,3,4,5,6,7); - $y = [0,1,2,3,4,5,6,7]; if (defined $len) { @got = splice(@x, $pos, $len, @list); - @got2 = splice($y, $pos, $len, @list); } else { @got = splice(@x, $pos); - @got2 = splice($y, $pos); } is(join(':',@got), join(':',@get), "got: @got == @get"); is(join(':',@x), join(':',@leave), "left: @x == @leave"); - is(join(':',@got2), join(':',@get), "ref got: @got2 == @get"); - is(join(':',@$y), join(':',@leave), "ref left: @$y == @leave"); } 1; # this file is require'd by lib/tie-stdpush.t diff --git a/t/op/smartkve.t b/t/op/smartkve.t index 1b54adccb8..d93dde142e 100644 --- a/t/op/smartkve.t +++ b/t/op/smartkve.t @@ -7,463 +7,119 @@ BEGIN { } use strict; use warnings; -no warnings 'experimental::autoderef', 'experimental::refaliasing'; +no warnings 'experimental::refaliasing'; use vars qw($data $array $values $hash $errpat); plan 'no_plan'; -sub j { join(":",@_) } - -# NOTE -# -# Hash insertion is currently unstable, in that -# %hash= %otherhash will not necessarily result in -# the same internal ordering of the data in the hash. -# For instance when keys collide the copy may not -# match the inserted order. So we declare one hash -# and then make all our copies from that, which should -# mean all the copies have the same internal structure. -# -# And these days, even if all that weren't true, we now -# per-hash randomize keys/values. So, we cant expect two -# hashes with the same internal structure to return the -# same thing at all. All we *can* expect is that keys() -# and values() use the same ordering. -our %base_hash; - -BEGIN { # in BEGIN for "use constant ..." later - # values match keys here so we can easily check that keys(%hash) == values(%hash) - %base_hash= ( pi => 'pi', e => 'e', i => 'i' ); - $array = [ qw(pi e i) ]; - $values = [ qw(pi e i) ]; - $hash = { %base_hash } ; - $data = { - hash => { %base_hash }, - array => [ @$array ], - }; -} - -package Foo; -sub new { - my $self = { - hash => { %base_hash }, - array => [@{$main::array}] - }; - bless $self, shift; -} -sub hash { no overloading; $_[0]->{hash} }; -sub array { no overloading; $_[0]->{array} }; - -package Foo::Overload::Array; -sub new { return bless [ qw/foo bar/ ], shift } -use overload '@{}' => sub { $main::array }, fallback => 1; - -package Foo::Overload::Hash; -sub new { return bless { qw/foo bar/ }, shift } -use overload '%{}' => sub { $main::hash }, fallback => 1; - -package Foo::Overload::Both; -sub new { return bless { qw/foo bar/ }, shift } -use overload '%{}' => sub { $main::hash }, - '@{}' => sub { $main::array }, fallback => 1; - -package Foo::Overload::HashOnArray; -sub new { return bless [ qw/foo bar/ ], shift } -use overload '%{}' => sub { $main::hash }, fallback => 1; - -package Foo::Overload::ArrayOnHash; -sub new { return bless { qw/foo bar/ }, shift } -use overload '@{}' => sub { $main::array }, fallback => 1; - -package main; - -use constant CONST_HASH => { %base_hash }; -use constant CONST_ARRAY => [ @$array ]; - -my %a_hash = %base_hash; -my @an_array = @$array; -sub hash_sub { return \%a_hash; } -sub array_sub { return \@an_array; } - -my $obj = Foo->new; - -my ($empty, $h_expect, $a_expect, @tmp, @tmp2, $k, $v); - -# Keys -- void - -keys $hash; pass('Void: keys $hash;'); -keys $data->{hash}; pass('Void: keys $data->{hash};'); -keys CONST_HASH; pass('Void: keys CONST_HASH;'); -keys CONST_HASH(); pass('Void: keys CONST_HASH();'); -keys hash_sub(); pass('Void: keys hash_sub();'); -keys hash_sub; pass('Void: keys hash_sub;'); -keys $obj->hash; pass('Void: keys $obj->hash;'); -keys $array; pass('Void: keys $array;'); -keys $data->{array}; pass('Void: keys $data->{array};'); -keys CONST_ARRAY; pass('Void: keys CONST_ARRAY;'); -keys CONST_ARRAY(); pass('Void: keys CONST_ARRAY();'); -keys array_sub; pass('Void: keys array_sub;'); -keys array_sub(); pass('Void: keys array_sub();'); -keys $obj->array; pass('Void: keys $obj->array;'); - -# Keys -- scalar - -is(keys $hash ,3, 'Scalar: keys $hash'); -is(keys $data->{hash} ,3, 'Scalar: keys $data->{hash}'); -is(keys CONST_HASH ,3, 'Scalar: keys CONST_HASH'); -is(keys CONST_HASH() ,3, 'Scalar: keys CONST_HASH()'); -is(keys hash_sub ,3, 'Scalar: keys hash_sub'); -is(keys hash_sub() ,3, 'Scalar: keys hash_sub()'); -is(keys $obj->hash ,3, 'Scalar: keys $obj->hash'); -is(keys $array ,3, 'Scalar: keys $array'); -is(keys $data->{array} ,3, 'Scalar: keys $data->{array}'); -is(keys CONST_ARRAY ,3, 'Scalar: keys CONST_ARRAY'); -is(keys CONST_ARRAY() ,3, 'Scalar: keys CONST_ARRAY()'); -is(keys array_sub ,3, 'Scalar: keys array_sub'); -is(keys array_sub() ,3, 'Scalar: keys array_sub()'); -is(keys $obj->array ,3, 'Scalar: keys $obj->array'); - -# Keys -- list - -$h_expect = j(sort keys %base_hash); -$a_expect = j(keys @$array); - -is(j(sort keys $hash) ,$h_expect, 'List: sort keys $hash'); -is(j(sort keys $data->{hash}) ,$h_expect, 'List: sort keys $data->{hash}'); -is(j(sort keys CONST_HASH) ,$h_expect, 'List: sort keys CONST_HASH'); -is(j(sort keys CONST_HASH()) ,$h_expect, 'List: sort keys CONST_HASH()'); -is(j(sort keys hash_sub) ,$h_expect, 'List: sort keys hash_sub'); -is(j(sort keys hash_sub()) ,$h_expect, 'List: sort keys hash_sub()'); -is(j(sort keys $obj->hash) ,$h_expect, 'List: sort keys $obj->hash'); - -is(j(keys $hash) ,j(values $hash), 'List: keys $hash == values $hash'); -is(j(keys $data->{hash}) ,j(values $data->{hash}), 'List: keys $data->{hash} == values $data->{hash}'); -is(j(keys CONST_HASH) ,j(values CONST_HASH), 'List: keys CONST_HASH == values CONST_HASH'); -is(j(keys CONST_HASH()) ,j(values CONST_HASH()), 'List: keys CONST_HASH() == values CONST_HASH()'); -is(j(keys hash_sub) ,j(values hash_sub), 'List: keys hash_sub == values hash_sub'); -is(j(keys hash_sub()) ,j(values hash_sub()), 'List: keys hash_sub() == values hash_sub()'); -is(j(keys $obj->hash) ,j(values $obj->hash), 'List: keys $obj->hash == values obj->hash'); - -is(j(keys $array) ,$a_expect, 'List: keys $array'); -is(j(keys $data->{array}) ,$a_expect, 'List: keys $data->{array}'); -is(j(keys CONST_ARRAY) ,$a_expect, 'List: keys CONST_ARRAY'); -is(j(keys CONST_ARRAY()) ,$a_expect, 'List: keys CONST_ARRAY()'); -is(j(keys array_sub) ,$a_expect, 'List: keys array_sub'); -is(j(keys array_sub()) ,$a_expect, 'List: keys array_sub()'); -is(j(keys $obj->array) ,$a_expect, 'List: keys $obj->array'); - -# Keys -- vivification -undef $empty; -eval { keys $empty->{hash} }; -ok(defined $empty, - 'Vivify: $empty (after keys $empty->{hash}) is HASHREF'); -ok(!defined $empty->{hash} , 'Vivify: $empty->{hash} is undef'); - -# Keys -- lvalue -$_{foo} = "bar"; -keys \%_ = 65; -is scalar %_, '1/128', 'keys $hashref as lvalue'; -eval 'keys \@_ = 65'; -like $@, qr/Can't modify keys on reference in scalar assignment/, - 'keys $arrayref as lvalue dies'; +my $empty; # Keys -- errors -$errpat = qr/ - (?-x:Type of argument to keys on reference must be unblessed hashref or) - (?-x: arrayref) -/x; +$errpat = qr/Experimental keys on scalar is now forbidden/; eval "keys undef"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: keys undef throws error' ); undef $empty; eval q"keys $empty"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: keys $undef throws error' ); is($empty, undef, 'keys $undef does not vivify $undef'); eval "keys 3"; -ok($@ =~ qr/Type of arg 1 to keys must be hash/, +like($@, qr/Type of arg 1 to keys must be hash/, 'Errors: keys CONSTANT throws error' ); eval "keys qr/foo/"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: keys qr/foo/ throws error' ); eval q"keys $hash qw/fo bar/"; -ok($@ =~ qr/syntax error/, +like($@, $errpat, 'Errors: keys $hash, @stuff throws error' ) or print "# Got: $@"; -# Values -- void - -values $hash; pass('Void: values $hash;'); -values $data->{hash}; pass('Void: values $data->{hash};'); -values CONST_HASH; pass('Void: values CONST_HASH;'); -values CONST_HASH(); pass('Void: values CONST_HASH();'); -values hash_sub(); pass('Void: values hash_sub();'); -values hash_sub; pass('Void: values hash_sub;'); -values $obj->hash; pass('Void: values $obj->hash;'); -values $array; pass('Void: values $array;'); -values $data->{array}; pass('Void: values $data->{array};'); -values CONST_ARRAY; pass('Void: values CONST_ARRAY;'); -values CONST_ARRAY(); pass('Void: values CONST_ARRAY();'); -values array_sub; pass('Void: values array_sub;'); -values array_sub(); pass('Void: values array_sub();'); -values $obj->array; pass('Void: values $obj->array;'); - -# Values -- scalar - -is(values $hash ,3, 'Scalar: values $hash'); -is(values $data->{hash} ,3, 'Scalar: values $data->{hash}'); -is(values CONST_HASH ,3, 'Scalar: values CONST_HASH'); -is(values CONST_HASH() ,3, 'Scalar: values CONST_HASH()'); -is(values hash_sub ,3, 'Scalar: values hash_sub'); -is(values hash_sub() ,3, 'Scalar: values hash_sub()'); -is(values $obj->hash ,3, 'Scalar: values $obj->hash'); -is(values $array ,3, 'Scalar: values $array'); -is(values $data->{array} ,3, 'Scalar: values $data->{array}'); -is(values CONST_ARRAY ,3, 'Scalar: values CONST_ARRAY'); -is(values CONST_ARRAY() ,3, 'Scalar: values CONST_ARRAY()'); -is(values array_sub ,3, 'Scalar: values array_sub'); -is(values array_sub() ,3, 'Scalar: values array_sub()'); -is(values $obj->array ,3, 'Scalar: values $obj->array'); - -# Values -- list - -$h_expect = j(sort values %base_hash); -$a_expect = j(values @$array); - -is(j(sort values $hash) ,$h_expect, 'List: sort values $hash'); -is(j(sort values $data->{hash}) ,$h_expect, 'List: sort values $data->{hash}'); -is(j(sort values CONST_HASH) ,$h_expect, 'List: sort values CONST_HASH'); -is(j(sort values CONST_HASH()) ,$h_expect, 'List: sort values CONST_HASH()'); -is(j(sort values hash_sub) ,$h_expect, 'List: sort values hash_sub'); -is(j(sort values hash_sub()) ,$h_expect, 'List: sort values hash_sub()'); -is(j(sort values $obj->hash) ,$h_expect, 'List: sort values $obj->hash'); - -is(j(values $hash) ,j(keys $hash), 'List: values $hash == keys $hash'); -is(j(values $data->{hash}) ,j(keys $data->{hash}), 'List: values $data->{hash} == keys $data->{hash}'); -is(j(values CONST_HASH) ,j(keys CONST_HASH), 'List: values CONST_HASH == keys CONST_HASH'); -is(j(values CONST_HASH()) ,j(keys CONST_HASH()), 'List: values CONST_HASH() == keys CONST_HASH()'); -is(j(values hash_sub) ,j(keys hash_sub), 'List: values hash_sub == keys hash_sub'); -is(j(values hash_sub()) ,j(keys hash_sub()), 'List: values hash_sub() == keys hash_sub()'); -is(j(values $obj->hash) ,j(keys $obj->hash), 'List: values $obj->hash == keys $obj->hash'); - -is(j(values $array) ,$a_expect, 'List: values $array'); -is(j(values $data->{array}) ,$a_expect, 'List: values $data->{array}'); -is(j(values CONST_ARRAY) ,$a_expect, 'List: values CONST_ARRAY'); -is(j(values CONST_ARRAY()) ,$a_expect, 'List: values CONST_ARRAY()'); -is(j(values array_sub) ,$a_expect, 'List: values array_sub'); -is(j(values array_sub()) ,$a_expect, 'List: values array_sub()'); -is(j(values $obj->array) ,$a_expect, 'List: values $obj->array'); - -# Values -- vivification -undef $empty; -eval { values $empty->{hash} }; -ok(defined $empty, - 'Vivify: $empty (after values $empty->{hash}) is HASHREF'); -ok(!defined $empty->{hash} , 'Vivify: $empty->{hash} is undef'); - # Values -- errors -$errpat = qr/ - (?-x:Type of argument to values on reference must be unblessed hashref or) - (?-x: arrayref) -/x; +$errpat = qr/Experimental values on scalar is now forbidden/; eval "values undef"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: values undef throws error' ); undef $empty; eval q"values $empty"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: values $undef throws error' ); is($empty, undef, 'values $undef does not vivify $undef'); eval "values 3"; -ok($@ =~ qr/Type of arg 1 to values must be hash/, +like($@, qr/Type of arg 1 to values must be hash/, 'Errors: values CONSTANT throws error' ); eval "values qr/foo/"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: values qr/foo/ throws error' ); eval q"values $hash qw/fo bar/"; -ok($@ =~ qr/syntax error/, +like($@, $errpat, 'Errors: values $hash, @stuff throws error' ) or print "# Got: $@"; -# Each -- void - -each $hash; pass('Void: each $hash'); -each $data->{hash}; pass('Void: each $data->{hash}'); -each CONST_HASH; pass('Void: each CONST_HASH'); -each CONST_HASH(); pass('Void: each CONST_HASH()'); -each hash_sub(); pass('Void: each hash_sub()'); -each hash_sub; pass('Void: each hash_sub'); -each $obj->hash; pass('Void: each $obj->hash'); -each $array; pass('Void: each $array'); -each $data->{array}; pass('Void: each $data->{array}'); -each CONST_ARRAY; pass('Void: each CONST_ARRAY'); -each CONST_ARRAY(); pass('Void: each CONST_ARRAY()'); -each array_sub; pass('Void: each array_sub'); -each array_sub(); pass('Void: each array_sub()'); -each $obj->array; pass('Void: each $obj->array'); - -# Reset iterators - -keys $hash; -keys $data->{hash}; -keys CONST_HASH; -keys CONST_HASH(); -keys hash_sub(); -keys hash_sub; -keys $obj->hash; -keys $array; -keys $data->{array}; -keys CONST_ARRAY; -keys CONST_ARRAY(); -keys array_sub; -keys array_sub(); -keys $obj->array; - -# Each -- scalar - -@tmp=(); while(defined( $k = each $hash)) {push @tmp,$k}; is(j(@tmp),j(keys $hash), 'Scalar: each $hash'); -@tmp=(); while(defined( $k = each $data->{hash})){push @tmp,$k}; is(j(@tmp),j(keys $data->{hash}), 'Scalar: each $data->{hash}'); -@tmp=(); while(defined( $k = each CONST_HASH)){push @tmp,$k}; is(j(@tmp),j(keys CONST_HASH), 'Scalar: each CONST_HASH'); -@tmp=(); while(defined( $k = each CONST_HASH())){push @tmp,$k}; is(j(@tmp),j(keys CONST_HASH()), 'Scalar: each CONST_HASH()'); -@tmp=(); while(defined( $k = each hash_sub())){push @tmp,$k}; is(j(@tmp),j(keys hash_sub()), 'Scalar: each hash_sub()'); -@tmp=(); while(defined( $k = each hash_sub)){push @tmp,$k}; is(j(@tmp),j(keys hash_sub), 'Scalar: each hash_sub'); -@tmp=(); while(defined( $k = each $obj->hash)){push @tmp,$k}; is(j(@tmp),j(keys $obj->hash), 'Scalar: each $obj->hash'); -@tmp=(); while(defined( $k = each $array)){push @tmp,$k}; is(j(@tmp),j(keys $array), 'Scalar: each $array'); -@tmp=(); while(defined( $k = each $data->{array})){push @tmp,$k}; is(j(@tmp),j(keys $data->{array}), 'Scalar: each $data->{array}'); -@tmp=(); while(defined( $k = each CONST_ARRAY)){push @tmp,$k}; is(j(@tmp),j(keys CONST_ARRAY), 'Scalar: each CONST_ARRAY'); -@tmp=(); while(defined( $k = each CONST_ARRAY())){push @tmp,$k}; is(j(@tmp),j(keys CONST_ARRAY()), 'Scalar: each CONST_ARRAY()'); -@tmp=(); while(defined( $k = each array_sub)){push @tmp,$k}; is(j(@tmp),j(keys array_sub), 'Scalar: each array_sub'); -@tmp=(); while(defined( $k = each array_sub())){push @tmp,$k}; is(j(@tmp),j(keys array_sub()), 'Scalar: each array_sub()'); -@tmp=(); while(defined( $k = each $obj->array)){push @tmp,$k}; is(j(@tmp),j(keys $obj->array), 'Scalar: each $obj->array'); - -# Each -- list - -@tmp=@tmp2=(); while(($k,$v) = each $hash) {push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys $hash, values $hash), 'List: each $hash'); -@tmp=@tmp2=(); while(($k,$v) = each $data->{hash}){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys $data->{hash}, values $data->{hash}), 'List: each $data->{hash}'); -@tmp=@tmp2=(); while(($k,$v) = each CONST_HASH){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys CONST_HASH, values CONST_HASH), 'List: each CONST_HASH'); -@tmp=@tmp2=(); while(($k,$v) = each CONST_HASH()){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys CONST_HASH(), values CONST_HASH()), 'List: each CONST_HASH()'); -@tmp=@tmp2=(); while(($k,$v) = each hash_sub()){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys hash_sub(), values hash_sub()), 'List: each hash_sub()'); -@tmp=@tmp2=(); while(($k,$v) = each hash_sub){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys hash_sub, values hash_sub), 'List: each hash_sub'); -@tmp=@tmp2=(); while(($k,$v) = each $obj->hash){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys $obj->hash, values $obj->hash), 'List: each $obj->hash'); -@tmp=@tmp2=(); while(($k,$v) = each $array){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys $array, values $array), 'List: each $array'); -@tmp=@tmp2=(); while(($k,$v) = each $data->{array}){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys $data->{array}, values $data->{array}), 'List: each $data->{array}'); -@tmp=@tmp2=(); while(($k,$v) = each CONST_ARRAY){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys CONST_ARRAY, values CONST_ARRAY), 'List: each CONST_ARRAY'); -@tmp=@tmp2=(); while(($k,$v) = each CONST_ARRAY()){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys CONST_ARRAY(), values CONST_ARRAY()), 'List: each CONST_ARRAY()'); -@tmp=@tmp2=(); while(($k,$v) = each array_sub){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys array_sub, values array_sub), 'List: each array_sub'); -@tmp=@tmp2=(); while(($k,$v) = each array_sub()){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys array_sub(), values array_sub()), 'List: each array_sub()'); -@tmp=@tmp2=(); while(($k,$v) = each $obj->array){push @tmp,$k; push @tmp2,$v}; is(j(@tmp,@tmp2),j(keys $obj->array, values $obj->array), 'List: each $obj->array'); - -# Each -- vivification -undef $empty; -eval { each $empty->{hash} }; -ok(defined $empty, - 'Vivify: $empty (after each $empty->{hash}) is HASHREF'); -ok(!defined $empty->{hash} , 'Vivify: $empty->{hash} is undef'); - # Each -- errors -$errpat = qr/ - (?-x:Type of argument to each on reference must be unblessed hashref or) - (?-x: arrayref) -/x; +$errpat = qr/Experimental each on scalar is now forbidden/; eval "each undef"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: each undef throws error' ); undef $empty; eval q"each $empty"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: each $undef throws error' ); is($empty, undef, 'each $undef does not vivify $undef'); eval "each 3"; -ok($@ =~ qr/Type of arg 1 to each must be hash/, +like($@, qr/Type of arg 1 to each must be hash/, 'Errors: each CONSTANT throws error' ); eval "each qr/foo/"; -ok($@ =~ $errpat, +like($@, $errpat, 'Errors: each qr/foo/ throws error' ); eval q"each $hash qw/foo bar/"; -ok($@ =~ qr/syntax error/, +like($@, $errpat, 'Errors: each $hash, @stuff throws error' ) or print "# Got: $@"; -# Overloaded objects -my $over_a = Foo::Overload::Array->new; -my $over_h = Foo::Overload::Hash->new; -my $over_b = Foo::Overload::Both->new; -my $over_h_a = Foo::Overload::HashOnArray->new; -my $over_a_h = Foo::Overload::ArrayOnHash->new; - -{ - my $warn = ''; - local $SIG{__WARN__} = sub { $warn = shift }; - - $errpat = qr/ - (?-x:Type of argument to keys on reference must be unblessed hashref or) - (?-x: arrayref) - /x; - - eval { keys $over_a }; - like($@, $errpat, "Overload: array dereference"); - is($warn, '', "no warning issued"); $warn = ''; - - eval { keys $over_h }; - like($@, $errpat, "Overload: hash dereference"); - is($warn, '', "no warning issued"); $warn = ''; - - eval { keys $over_b }; - like($@, $errpat, "Overload: ambiguous dereference (both)"); - is($warn, '', "no warning issued"); $warn = ''; - - eval { keys $over_h_a }; - like($@, $errpat, "Overload: ambiguous dereference"); - is($warn, '', "no warning issued"); $warn = ''; - - eval { keys $over_a_h }; - like($@, $errpat, "Overload: ambiguous dereference"); - is($warn, '', "no warning issued"); $warn = ''; -} - use feature 'refaliasing'; my $a = 7; our %h; \$h{f} = \$a; -($a, $b) = each \%h; -is "$a $b", "f 7", 'each \%hash in list assignment'; +($a, $b) = each %h; +is "$a $b", "f 7", 'each %hash in list assignment'; $a = 7; -($a, $b) = (3, values \%h); -is "$a $b", "3 7", 'values \%hash in list assignment'; +($a, $b) = (3, values %h); +is "$a $b", "3 7", 'values %hash in list assignment'; *a = sub { \@_ }->($a); $a = 7; -($a, $b) = each \our @a; -is "$a $b", "0 7", 'each \@array in list assignment'; +($a, $b) = each our @a; +is "$a $b", "0 7", 'each @array in list assignment'; $a = 7; -($a, $b) = (3, values \@a); -is "$a $b", "3 7", 'values \@array in list assignment'; +($a, $b) = (3, values @a); +is "$a $b", "3 7", 'values @array in list assignment'; diff --git a/t/op/splice.t b/t/op/splice.t index dde11f52ac..c0af5d397b 100644 --- a/t/op/splice.t +++ b/t/op/splice.t @@ -88,10 +88,6 @@ ok( ! Foo->isa('Bar'), 'Foo is not a Bar'); splice @Foo::ISA, 0, 0, 'Bar'; ok( Foo->isa('Bar'), 'splice @ISA and make Foo a Bar'); -# Test undef first arg -eval { no warnings 'experimental';splice( $new_arrayref, 0, 0, 1, 2, 3 ) }; -like($@, qr/Not an ARRAY/, 'undefined first argument to splice'); - # Test arrays with nonexistent elements (crashes when it fails) @a = (); $#a++; diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index 41fef0c339..82a8543d22 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -7,7 +7,7 @@ BEGIN { chdir 't' if -d 't'; require './test.pl'; set_up_inc('../lib'); - plan (tests => 347); + plan (tests => 345); } use strict; @@ -171,17 +171,9 @@ tie my $var1 => 'main', \1; $dummy = $$var1 ; check_count '${}'; tie my $var2 => 'main', []; $dummy = @$var2 ; check_count '@{}'; -{ - no warnings 'experimental::autoderef'; - $dummy = shift $var2 ; check_count 'shift arrayref'; -} tie my $var3 => 'main', {}; $dummy = %$var3 ; check_count '%{}'; { - no warnings 'experimental::autoderef'; - $dummy = keys $var3 ; check_count 'keys hashref'; -} -{ no strict 'refs'; tie my $var4 => 'main', *]; $dummy = *$var4 ; check_count '*{}'; diff --git a/t/op/unshift.t b/t/op/unshift.t index 7782b2a591..66fd0ff86a 100644 --- a/t/op/unshift.t +++ b/t/op/unshift.t @@ -5,51 +5,34 @@ BEGIN { require "./test.pl"; } -plan(36); +plan(18); @array = (1, 2, 3); -$aref = [1, 2, 3]; -no warnings 'experimental::autoderef'; { no warnings 'syntax'; $count3 = unshift (@array); - $count3r = unshift ($aref); } is(join(' ',@array), '1 2 3', 'unshift null'); cmp_ok($count3, '==', 3, 'unshift count == 3'); -is(join(' ',@$aref), '1 2 3', 'unshift null (ref)'); -cmp_ok($count3r, '==', 3, 'unshift count == 3 (ref)'); $count3_2 = unshift (@array, ()); is(join(' ',@array), '1 2 3', 'unshift null empty'); cmp_ok($count3_2, '==', 3, 'unshift count == 3 again'); -$count3_2r = unshift ($aref, ()); -is(join(' ',@$aref), '1 2 3', 'unshift null empty (ref)'); -cmp_ok($count3_2r, '==', 3, 'unshift count == 3 again (ref)'); $count4 = unshift (@array, 0); is(join(' ',@array), '0 1 2 3', 'unshift singleton list'); cmp_ok($count4, '==', 4, 'unshift count == 4'); -$count4r = unshift ($aref, 0); -is(join(' ',@$aref), '0 1 2 3', 'unshift singleton list (ref)'); -cmp_ok($count4r, '==', 4, 'unshift count == 4 (ref)'); $count7 = unshift (@array, 3, 2, 1); is(join(' ',@array), '3 2 1 0 1 2 3', 'unshift list'); cmp_ok($count7, '==', 7, 'unshift count == 7'); -$count7r = unshift ($aref, 3, 2, 1); -is(join(' ',@$aref), '3 2 1 0 1 2 3', 'unshift list (ref)'); -cmp_ok($count7r, '==', 7, 'unshift count == 7 (ref)'); @list = (5, 4); $count9 = unshift (@array, @list); is(join(' ',@array), '5 4 3 2 1 0 1 2 3', 'unshift array'); cmp_ok($count9, '==', 9, 'unshift count == 9'); -$count9r = unshift ($aref, @list); -is(join(' ',@$aref), '5 4 3 2 1 0 1 2 3', 'unshift array (ref)'); -cmp_ok($count9r, '==', 9, 'unshift count == 9 (ref)'); @list = (7); @@ -57,47 +40,31 @@ cmp_ok($count9r, '==', 9, 'unshift count == 9 (ref)'); $count11 = unshift (@array, @list, @list2); is(join(' ',@array), '7 6 5 4 3 2 1 0 1 2 3', 'unshift arrays'); cmp_ok($count11, '==', 11, 'unshift count == 11'); -$count11r = unshift ($aref, @list, @list2); -is(join(' ',@$aref), '7 6 5 4 3 2 1 0 1 2 3', 'unshift arrays (ref)'); -cmp_ok($count11r, '==', 11, 'unshift count == 11 (ref)'); # ignoring counts @alpha = ('y', 'z'); -$alpharef = ['y', 'z']; { no warnings 'syntax'; unshift (@alpha); - unshift ($alpharef); } is(join(' ',@alpha), 'y z', 'void unshift null'); -is(join(' ',@$alpharef), 'y z', 'void unshift null (ref)'); unshift (@alpha, ()); is(join(' ',@alpha), 'y z', 'void unshift null empty'); -unshift ($alpharef, ()); -is(join(' ',@$alpharef), 'y z', 'void unshift null empty (ref)'); unshift (@alpha, 'x'); is(join(' ',@alpha), 'x y z', 'void unshift singleton list'); -unshift ($alpharef, 'x'); -is(join(' ',@$alpharef), 'x y z', 'void unshift singleton list (ref)'); unshift (@alpha, 'u', 'v', 'w'); is(join(' ',@alpha), 'u v w x y z', 'void unshift list'); -unshift ($alpharef, 'u', 'v', 'w'); -is(join(' ',@$alpharef), 'u v w x y z', 'void unshift list (ref)'); @bet = ('s', 't'); unshift (@alpha, @bet); is(join(' ',@alpha), 's t u v w x y z', 'void unshift array'); -unshift ($alpharef, @bet); -is(join(' ',@$alpharef), 's t u v w x y z', 'void unshift array (ref)'); @bet = ('q'); @gimel = ('r'); unshift (@alpha, @bet, @gimel); is(join(' ',@alpha), 'q r s t u v w x y z', 'void unshift arrays'); -unshift ($alpharef, @bet, @gimel); -is(join(' ',@$alpharef), 'q r s t u v w x y z', 'void unshift arrays (ref)'); |