summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/t/lib/warnings/op
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/perl/t/lib/warnings/op')
-rw-r--r--gnu/usr.bin/perl/t/lib/warnings/op208
1 files changed, 101 insertions, 107 deletions
diff --git a/gnu/usr.bin/perl/t/lib/warnings/op b/gnu/usr.bin/perl/t/lib/warnings/op
index 528639e5a9a..54e2e3de20e 100644
--- a/gnu/usr.bin/perl/t/lib/warnings/op
+++ b/gnu/usr.bin/perl/t/lib/warnings/op
@@ -87,8 +87,6 @@
Use of /g modifier is meaningless in split
- The bitwise feature is experimental [Perl_ck_bitop]
-
Possible precedence problem on bitwise %c operator [Perl_ck_bitop]
Mandatory Warnings
@@ -134,6 +132,28 @@ Found = in conditional, should be == at - line 3.
Found = in conditional, should be == at - line 4.
########
# op.c
+# NAME while with assignment as condition
+use warnings 'syntax';
+1 while $a = 0;
+while ($a = 0) {
+ 1;
+}
+EXPECT
+Found = in conditional, should be == at - line 3.
+Found = in conditional, should be == at - line 4.
+########
+# op.c
+# NAME until with assignment as condition
+use warnings 'syntax';
+1 until $a = 1;
+until ($a = 1) {
+ 1;
+}
+EXPECT
+Found = in conditional, should be == at - line 3.
+Found = in conditional, should be == at - line 4.
+########
+# op.c
use warnings 'syntax' ;
@a[3];
@a{3};
@@ -145,9 +165,13 @@ use warnings 'syntax' ;
@a{--$_};
@a[$_];
@a[--$_];
+delete @a[$x];
+delete @a{$x};
no warnings 'syntax' ;
@a[3];
@a{3};
+delete @a[$x];
+delete @a{$x};
EXPECT
Scalar value @a[3] better written as $a[3] at - line 3.
Scalar value @a{3} better written as $a{3} at - line 4.
@@ -159,6 +183,15 @@ Scalar value @a{...} better written as $a{...} at - line 9.
Scalar value @a{...} better written as $a{...} at - line 10.
Scalar value @a[...] better written as $a[...] at - line 11.
Scalar value @a[...] better written as $a[...] at - line 12.
+Scalar value @a[...] better written as $a[...] at - line 13.
+Scalar value @a{...} better written as $a{...} at - line 14.
+########
+# op.c
+# [perl #132645]
+use warnings 'syntax';
+@inf[3];
+EXPECT
+Scalar value @inf[3] better written as $inf[3] at - line 4.
########
# op.c
use utf8;
@@ -997,15 +1030,11 @@ sub phred { 2 };
state sub jorge { 1 }
sub jorge () { 2 } # should *not* produce redef warnings by default
EXPECT
-The lexical_subs feature is experimental at - line 3.
Prototype mismatch: sub fred () vs none at - line 4.
Constant subroutine fred redefined at - line 4.
-The lexical_subs feature is experimental at - line 5.
Prototype mismatch: sub george: none vs () at - line 6.
-The lexical_subs feature is experimental at - line 7.
Prototype mismatch: sub phred () vs none at - line 8.
Constant subroutine phred redefined at - line 8.
-The lexical_subs feature is experimental at - line 9.
Prototype mismatch: sub jorge: none vs () at - line 10.
########
# op.c
@@ -1104,65 +1133,6 @@ Prototype mismatch: sub main::frèd () vs ($) at - line 5.
use utf8;
use open qw( :utf8 :std );
use warnings;
-eval "sub fòò (@\$\0) {}";
-EXPECT
-Prototype after '@' for main::fòò : @$\0 at (eval 1) line 1.
-Illegal character in prototype for main::fòò : @$\0 at (eval 1) line 1.
-########
-# op.c
-use utf8;
-use open qw( :utf8 :std );
-use warnings;
-eval "sub foo (@\0) {}";
-EXPECT
-Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
-Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
-########
-# op.c
-BEGIN {
- if (ord('A') == 193) {
- print "SKIPPED\n# Different results on EBCDIC";
- exit 0;
- }
-}
-use utf8;
-use open qw( :utf8 :std );
-use warnings;
-BEGIN { $::{"foo"} = "\@\$\0L\351on" }
-BEGIN { eval "sub foo (@\$\0L\x{c3}\x{a9}on) {}"; }
-EXPECT
-Prototype after '@' for main::foo : @$\x{0}L... at (eval 1) line 1.
-Illegal character in prototype for main::foo : @$\x{0}L... at (eval 1) line 1.
-########
-# op.c
-use utf8;
-use open qw( :utf8 :std );
-use warnings;
-BEGIN { eval "sub foo (@\0) {}"; }
-EXPECT
-Prototype after '@' for main::foo : @\0 at (eval 1) line 1.
-Illegal character in prototype for main::foo : @\0 at (eval 1) line 1.
-########
-# op.c
-use warnings;
-eval "sub foo (@\xAB) {}";
-EXPECT
-Prototype after '@' for main::foo : @\x{ab} at (eval 1) line 1.
-Illegal character in prototype for main::foo : @\x{ab} at (eval 1) line 1.
-########
-# op.c
-use utf8;
-use open qw( :utf8 :std );
-use warnings;
-BEGIN { eval "sub foo (@\x{30cb}) {}"; }
-EXPECT
-Prototype after '@' for main::foo : @\x{30cb} at (eval 1) line 1.
-Illegal character in prototype for main::foo : @\x{30cb} at (eval 1) line 1.
-########
-# op.c
-use utf8;
-use open qw( :utf8 :std );
-use warnings;
BEGIN { $::{"foo"} = "\x{30cb}" }
BEGIN { eval "sub foo {}"; }
EXPECT
@@ -1435,6 +1405,7 @@ END { print "in end\n"; }
print "in mainline\n";
1;
--FILE--
+BEGIN { unshift @INC, '.' }
require abc;
do "abc.pm";
EXPECT
@@ -1512,34 +1483,6 @@ $_ |.= $_;
$_ &.= $_;
$_ ^.= $_;
EXPECT
-The bitwise feature is experimental at - line 2.
-The bitwise feature is experimental at - line 3.
-The bitwise feature is experimental at - line 4.
-The bitwise feature is experimental at - line 5.
-The bitwise feature is experimental at - line 6.
-The bitwise feature is experimental at - line 7.
-The bitwise feature is experimental at - line 8.
-The bitwise feature is experimental at - line 9.
-The bitwise feature is experimental at - line 10.
-The bitwise feature is experimental at - line 11.
-The bitwise feature is experimental at - line 12.
-The bitwise feature is experimental at - line 13.
-The bitwise feature is experimental at - line 14.
-The bitwise feature is experimental at - line 15.
-The bitwise feature is experimental at - line 17.
-The bitwise feature is experimental at - line 18.
-The bitwise feature is experimental at - line 19.
-The bitwise feature is experimental at - line 20.
-The bitwise feature is experimental at - line 21.
-The bitwise feature is experimental at - line 22.
-The bitwise feature is experimental at - line 23.
-The bitwise feature is experimental at - line 24.
-The bitwise feature is experimental at - line 25.
-The bitwise feature is experimental at - line 26.
-The bitwise feature is experimental at - line 27.
-The bitwise feature is experimental at - line 28.
-The bitwise feature is experimental at - line 29.
-The bitwise feature is experimental at - line 30.
########
# op.c
use warnings 'precedence';
@@ -1747,13 +1690,13 @@ if (my $w2) { $a=1 }
if ($a && (my $w3 = 1)) {$a = 2}
EXPECT
-Deprecated use of my() in false conditional at - line 2.
-Deprecated use of my() in false conditional at - line 3.
-Deprecated use of my() in false conditional at - line 4.
-Deprecated use of my() in false conditional at - line 5.
-Deprecated use of my() in false conditional at - line 6.
-Deprecated use of my() in false conditional at - line 7.
-Deprecated use of my() in false conditional at - line 8.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 2.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 3.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 4.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 5.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 6.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 7.
+Deprecated use of my() in false conditional. This will be a fatal error in Perl 5.30 at - line 8.
########
# op.c
$[ = 1;
@@ -1761,14 +1704,15 @@ $[ = 1;
use warnings 'deprecated';
$[ = 2;
($[) = 2;
+$[ = 0;
no warnings 'deprecated';
$[ = 3;
($[) = 3;
EXPECT
-Use of assignment to $[ is deprecated at - line 2.
-Use of assignment to $[ is deprecated at - line 3.
-Use of assignment to $[ is deprecated at - line 5.
-Use of assignment to $[ is deprecated at - line 6.
+Use of assignment to $[ is deprecated, and will be fatal in Perl 5.30 at - line 2.
+Use of assignment to $[ is deprecated, and will be fatal in Perl 5.30 at - line 3.
+Use of assignment to $[ is deprecated, and will be fatal in Perl 5.30 at - line 5.
+Use of assignment to $[ is deprecated, and will be fatal in Perl 5.30 at - line 6.
########
# op.c
use warnings 'void';
@@ -2024,6 +1968,17 @@ EXPECT
Negative repeat count does nothing at - line 3.
Negative repeat count does nothing at - line 4.
########
+use Config;
+my $non_ieee_fp = ($Config{doublekind} == 9 ||
+ $Config{doublekind} == 10 ||
+ $Config{doublekind} == 11);
+if ($non_ieee_fp) {
+ print <<EOM ;
+SKIPPED
+# No inf/nan support
+EOM
+ exit ;
+}
my $a = "inf" + 0;
my $b = -$a;
my $c = "nan" + 0;
@@ -2037,9 +1992,9 @@ my $y = "y" x $b;
my $z = "z" x $c;
no warnings 'numeric';
EXPECT
-Non-finite repeat count does nothing at - line 5.
-Non-finite repeat count does nothing at - line 6.
-Non-finite repeat count does nothing at - line 7.
+Non-finite repeat count does nothing at - line 16.
+Non-finite repeat count does nothing at - line 17.
+Non-finite repeat count does nothing at - line 18.
########
# NAME warn on stat @array
@foo = ("op/stat.t");
@@ -2057,3 +2012,42 @@ Array passed to stat will be coerced to a scalar (did you want stat $foo[0]?) at
Array passed to stat will be coerced to a scalar (did you want stat $bar[0]?) at - line 9.
Array passed to stat will be coerced to a scalar at - line 10.
+########
+# NAME barewords and conditionals near constant folding
+use warnings;
+my $x1 = !a || !b; # no "in conditional" warnings
+my $x2 = !A || !B; # warning-free, because upper-case won't clash
+EXPECT
+Unquoted string "a" may clash with future reserved word at - line 2.
+Unquoted string "b" may clash with future reserved word at - line 2.
+########
+# RT #6870: Odd parsing of do...for...
+# This was really more a tokenizer bug, but it manifests as spurious warnings
+use warnings;
+no warnings 'reserved';
+$a=do xa for ax;
+do "xa" for ax;
+do xa for ax;
+do xa for "ax";
+do xa for sin(1);
+do xa for (sin(1));
+do xa for "sin";
+do xa for qq(sin);
+do xa for my $a;
+do xa for my @a;
+EXPECT
+########
+# TODO [perl #125493
+use warnings;
+$_="3.14159";
+tr/0-9/\x{6F0}-\x{6F9}/;
+EXPECT
+########
+# Useless use of concatenation should appear for any number of args
+use warnings;
+($a, $b, $c) = (42)x3;
+$a.$b;
+$a.$b.$c;
+EXPECT
+Useless use of concatenation (.) or string in void context at - line 4.
+Useless use of concatenation (.) or string in void context at - line 5.