This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate above \xFF in bitwise string ops
[perl5.git] / t / op / smartkve.t
index d93dde1..818cbf3 100644 (file)
@@ -8,14 +8,24 @@ BEGIN {
 use strict;
 use warnings;
 no warnings 'experimental::refaliasing';
-use vars qw($data $array $values $hash $errpat);
+our ($data, $array, $values, $hash, $errpat);
 
 plan 'no_plan';
 
 my $empty;
 
+sub set_errpat {
+    # Checking for a comma after the line number ensures that we are using
+    # yyerror for the error, rather than croak.  yyerror is preferable for
+    # compile-time errors.
+    $errpat =
+       qr/Experimental $_[0] on scalar is now forbidden .* line 1\.(?x:
+         ).*Type of arg 1 to $_[0] must be hash or array \(not (?x:
+         ).*line 1,/s;
+}
+
 # Keys -- errors
-$errpat = qr/Experimental keys on scalar is now forbidden/;
+set_errpat 'keys';
 
 eval "keys undef";
 like($@, $errpat,
@@ -46,7 +56,7 @@ like($@, $errpat,
 ) or print "# Got: $@";
 
 # Values -- errors
-$errpat = qr/Experimental values on scalar is now forbidden/;
+set_errpat 'values';
 
 eval "values undef";
 like($@, $errpat,
@@ -77,7 +87,7 @@ like($@, $errpat,
 ) or print "# Got: $@";
 
 # Each -- errors
-$errpat = qr/Experimental each on scalar is now forbidden/;
+set_errpat 'each';
 
 eval "each undef";
 like($@, $errpat,
@@ -106,20 +116,3 @@ eval q"each $hash qw/foo bar/";
 like($@, $errpat,
   'Errors: each $hash, @stuff throws error'
 ) or print "# Got: $@";
-
-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 = 7;
-($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 = 7;
-($a, $b) = (3, values @a);
-is "$a $b", "3 7", 'values @array in list assignment';