BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
require './test.pl';
+ set_up_inc('../lib');
}
# use strict;
-plan tests => 40;
+plan tests => 39;
# simple use cases
{
like $@, qr{^Can't modify key/value hash slice in local at},
'local dies';
}
- # no delete
- {
- local $@;
- eval 'delete %h{qw(a b)}';
- like $@, qr{^delete argument is key/value hash slice, use hash slice},
- 'delete dies';
- }
# no assign
{
local $@;
# lvalue subs in assignment
{
local $@;
- eval 'sub bar:lvalue{ %h{qw(a b)} }; bar() = "1"';
+ eval 'sub bar:lvalue{ %h{qw(a b)} }; (bar) = "1"';
like $@, qr{^Can't modify key/value hash slice in list assignment},
'not allowed as result of lvalue sub';
+ eval 'sub bbar:lvalue{ %h{qw(a b)} }; bbar() = "1"';
+ like $@,
+ qr{^Can't modify key/value hash slice in scalar assignment},
+ 'not allowed as result of lvalue sub';
}
}
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