diff options
author | 2009-10-12 18:10:27 +0000 | |
---|---|---|
committer | 2009-10-12 18:10:27 +0000 | |
commit | 43003dfe3ad45d1698bed8a37f2b0f5b14f20d4f (patch) | |
tree | 1abc677556fd1cb82189030802130c0f670a32d9 /gnu/usr.bin/perl/t/lib | |
parent | More inodes by default on the ramdisk, because otherwise a many-disk (diff) | |
download | wireguard-openbsd-43003dfe3ad45d1698bed8a37f2b0f5b14f20d4f.tar.xz wireguard-openbsd-43003dfe3ad45d1698bed8a37f2b0f5b14f20d4f.zip |
import perl 5.10.1
Diffstat (limited to 'gnu/usr.bin/perl/t/lib')
31 files changed, 1637 insertions, 494 deletions
diff --git a/gnu/usr.bin/perl/t/lib/Dev/Null.pm b/gnu/usr.bin/perl/t/lib/Dev/Null.pm index 2bd22740612..24ec07ab578 100644 --- a/gnu/usr.bin/perl/t/lib/Dev/Null.pm +++ b/gnu/usr.bin/perl/t/lib/Dev/Null.pm @@ -1,17 +1,8 @@ -# For shutting up Test::Harness. -# Has to work on 5.004 which doesn't have Tie::StdHandle. package Dev::Null; -sub WRITE {} -sub PRINT {} -sub PRINTF {} -sub TIEHANDLE { - my $class = shift; - my $fh = do { local *HANDLE; \*HANDLE }; - return bless $fh, $class; -} -sub READ {} -sub READLINE {} -sub GETC {} +use strict; + +sub TIEHANDLE { bless {}, shift } +sub PRINT { 1 } 1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/NoXS.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/NoXS.pm new file mode 100644 index 00000000000..45faf7e2306 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/NoXS.pm @@ -0,0 +1,19 @@ +package MakeMaker::Test::NoXS; + +# Disable all XS loading. + +use Carp; + +require DynaLoader; +require XSLoader; + +# Things like Cwd key on this to decide if they're running miniperl +delete $DynaLoader::{boot_DynaLoader}; + +# This isn't 100%. Things like Win32.pm will crap out rather than +# just not load. See ExtUtils::MM->_is_win95 for an example +no warnings 'redefine'; +*DynaLoader::bootstrap = sub { confess "Tried to load XS for @_"; }; +*XSLoader::load = sub { confess "Tried to load XS for @_"; }; + +1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/BFD.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/BFD.pm index c540708529f..9745656f63e 100644 --- a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/BFD.pm +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/BFD.pm @@ -108,6 +108,11 @@ sub setup_recurs { open(FILE, ">$file") || die "Can't create $file: $!"; print FILE $text; close FILE; + + # ensure file at least 1 second old for makes that assume + # files with the same time are out of date. + my $time = calibrate_mtime(); + utime $time, $time - 1, $file; } return 1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/MPV.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/MPV.pm new file mode 100644 index 00000000000..f30d65f5676 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/MPV.pm @@ -0,0 +1,67 @@ +package MakeMaker::Test::Setup::MPV; + +@ISA = qw(Exporter); +require Exporter; +@EXPORT = qw(setup_recurs teardown_recurs); + +use strict; +use File::Path; +use File::Basename; + +my %Files = ( + 'Min-PerlVers/Makefile.PL' => <<'END', +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'Min::PerlVers', + AUTHOR => 'John Doe <jd@example.com>', + VERSION_FROM => 'lib/Min/PerlVers.pm', + PREREQ_PM => { strict => 0 }, + MIN_PERL_VERSION => '5.005', +); +END + + 'Min-PerlVers/lib/Min/PerlVers.pm' => <<'END', +package Min::PerlVers; + +$VERSION = 0.05; + +=head1 NAME + +Min::PerlVers - being picky about perl versions + +=cut + +1; +END + +); + + +sub setup_recurs { + while(my($file, $text) = each %Files) { + # Convert to a relative, native file path. + $file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file); + + my $dir = dirname($file); + mkpath $dir; + open(FILE, ">$file") || die "Can't create $file: $!"; + print FILE $text; + close FILE; + } + + return 1; +} + +sub teardown_recurs { + foreach my $file (keys %Files) { + my $dir = dirname($file); + if( -e $dir ) { + rmtree($dir) || return; + } + } + return 1; +} + + +1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/PL_FILES.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/PL_FILES.pm index 98cbebdf642..74461854442 100644 --- a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/PL_FILES.pm +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/PL_FILES.pm @@ -100,6 +100,11 @@ sub setup { open(FILE, ">$file") || die "Can't create $file: $!"; print FILE $text; close FILE; + + # ensure file at least 1 second old for makes that assume + # files with the same time are out of date. + my $time = calibrate_mtime(); + utime $time, $time - 1, $file; } return 1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Problem.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Problem.pm index 4cb14b59ac8..c6573a1aadd 100644 --- a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Problem.pm +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Problem.pm @@ -7,6 +7,7 @@ require Exporter; use strict; use File::Path; use File::Basename; +use MakeMaker::Test::Utils; my %Files = ( 'Problem-Module/Makefile.PL' => <<'END', @@ -37,6 +38,11 @@ sub setup_recurs { open(FILE, ">$file") || die "Can't create $file: $!"; print FILE $text; close FILE; + + # ensure file at least 1 second old for makes that assume + # files with the same time are out of date. + my $time = calibrate_mtime(); + utime $time, $time - 1, $file; } return 1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Recurs.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Recurs.pm index d3585eb9c2e..ad1be2f6d1d 100644 --- a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Recurs.pm +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Setup/Recurs.pm @@ -50,6 +50,11 @@ sub setup_recurs { open(FILE, ">$file") || die "Can't create $file: $!"; print FILE $text; close FILE; + + # ensure file at least 1 second old for makes that assume + # files with the same time are out of date. + my $time = calibrate_mtime(); + utime $time, $time - 1, $file; } return 1; diff --git a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Utils.pm b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Utils.pm index fb8162d2cd1..b81791d95e3 100644 --- a/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Utils.pm +++ b/gnu/usr.bin/perl/t/lib/MakeMaker/Test/Utils.pm @@ -4,21 +4,56 @@ use File::Spec; use strict; use Config; -use vars qw($VERSION @ISA @EXPORT); - require Exporter; -@ISA = qw(Exporter); - -$VERSION = 0.03; - -@EXPORT = qw(which_perl perl_lib makefile_name makefile_backup - make make_run run make_macro calibrate_mtime - setup_mm_test_root - have_compiler - ); +our @ISA = qw(Exporter); + +our $Is_VMS = $^O eq 'VMS'; +our $Is_MacOS = $^O eq 'MacOS'; + +our @EXPORT = qw(which_perl perl_lib makefile_name makefile_backup + make make_run run make_macro calibrate_mtime + setup_mm_test_root + have_compiler slurp + $Is_VMS $Is_MacOS + run_ok + ); + + +# Setup the code to clean out %ENV +{ + # Environment variables which might effect our testing + my @delete_env_keys = qw( + PERL_MM_OPT + PERL_MM_USE_DEFAULT + HARNESS_TIMER + HARNESS_OPTIONS + HARNESS_VERBOSE + PREFIX + MAKEFLAGS + ); + + # Remember the ENV values because on VMS %ENV is global + # to the user, not the process. + my %restore_env_keys; + + sub clean_env { + for my $key (@delete_env_keys) { + if( exists $ENV{$key} ) { + $restore_env_keys{$key} = delete $ENV{$key}; + } + else { + delete $ENV{$key}; + } + } + } -my $Is_VMS = $^O eq 'VMS'; -my $Is_MacOS = $^O eq 'MacOS'; + END { + while( my($key, $val) = each %restore_env_keys ) { + $ENV{$key} = $val; + } + } +} +clean_env(); =head1 NAME @@ -45,6 +80,8 @@ MakeMaker::Test::Utils - Utility routines for testing MakeMaker my $have_compiler = have_compiler(); + my $text = slurp($filename); + =head1 DESCRIPTION @@ -253,9 +290,10 @@ sub run { use ExtUtils::MM; - # Unix can handle 2>&1 and OS/2 from 5.005_54 up. + # Unix, modern Windows and OS/2 from 5.005_54 up can handle 2>&1 # This makes our failure diagnostics nicer to read. - if( MM->os_flavor_is('Unix') or + if( MM->os_flavor_is('Unix') or + (MM->os_flavor_is('Win32') and !MM->os_flavor_is('Win9x')) or ($] > 5.00554 and MM->os_flavor_is('OS/2')) ) { return `$cmd 2>&1`; @@ -265,6 +303,27 @@ sub run { } } + +=item B<run_ok> + + my @out = run_ok($cmd); + +Like run() but it tests that the result exited normally. + +The output from run() will be used as a diagnostic if it fails. + +=cut + +sub run_ok { + my $tb = Test::Builder->new; + + my @out = run(@_); + + $tb->cmp_ok( $?, '==', 0, "run(@_)" ) || $tb->diag(@out); + + return wantarray ? @out : join "", @out; +} + =item B<setup_mm_test_root> Creates a rooted logical to avoid the 8-level limit on older VMS systems. @@ -321,6 +380,26 @@ sub have_compiler { return $have_compiler; } +=item slurp + + $contents = slurp($filename); + +Returns the $contents of $filename. + +Will die if $filename cannot be opened. + +=cut + +sub slurp { + my $filename = shift; + + local $/ = undef; + open my $fh, $filename or die "Can't open $filename for reading: $!"; + my $text = <$fh>; + close $fh; + + return $text; +} =back diff --git a/gnu/usr.bin/perl/t/lib/Parse/CPAN/Meta/Test.pm b/gnu/usr.bin/perl/t/lib/Parse/CPAN/Meta/Test.pm new file mode 100644 index 00000000000..46f967b7dd0 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/Parse/CPAN/Meta/Test.pm @@ -0,0 +1,86 @@ +package Parse::CPAN::Meta::Test; + +use strict; +use Test::More (); +use Parse::CPAN::Meta; +use File::Spec; + +use vars qw{@ISA @EXPORT}; +BEGIN { + require Exporter; + @ISA = qw{ Exporter }; + @EXPORT = qw{ + tests yaml_ok yaml_error slurp load_ok + test_data_directory + }; +} + +sub test_data_directory { + return( + $ENV{PERL_CORE} + ? File::Spec->catdir(File::Spec->updir, qw(lib Parse CPAN Meta t data)) + : File::Spec->catdir(qw(t data)) + ); +} + +# 22 tests per call to yaml_ok +# 4 tests per call to load_ok +sub tests { + return ( tests => count(@_) ); +} + +sub count { + my $yaml_ok = shift || 0; + my $load_ok = shift || 0; + my $single = shift || 0; + my $count = $yaml_ok * 3 + $load_ok * 4 + $single; + return $count; +} + +sub yaml_ok { + my $string = shift; + my $array = shift; + my $name = shift || 'unnamed'; + + # Does the string parse to the structure + my $yaml_copy = $string; + my @yaml = eval { Parse::CPAN::Meta::Load( $yaml_copy ); }; + Test::More::is( $@, '', "$name: Parse::CPAN::Meta parses without error" ); + Test::More::is( $yaml_copy, $string, "$name: Parse::CPAN::Meta does not modify the input string" ); + SKIP: { + Test::More::skip( "Shortcutting after failure", 1 ) if $@; + Test::More::is_deeply( \@yaml, $array, "$name: Parse::CPAN::Meta parses correctly" ); + } + + # Return true as a convenience + return 1; +} + +sub yaml_error { + my $string = shift; + my $yaml = eval { Parse::CPAN::Meta::Load( $string ); }; + Test::More::like( $@, qr/$_[0]/, "YAML::Tiny throws expected error" ); +} + +sub slurp { + my $file = shift; + local $/ = undef; + open( FILE, " $file" ) or die "open($file) failed: $!"; + my $source = <FILE>; + close( FILE ) or die "close($file) failed: $!"; + $source; +} + +sub load_ok { + my $name = shift; + my $file = shift; + my $size = shift; + Test::More::ok( -f $file, "Found $name" ) or Test::More::diag("Searched at '$file'"); + Test::More::ok( -r $file, "Can read $name" ); + my $content = slurp( $file ); + Test::More::ok( (defined $content and ! ref $content), "Loaded $name" ); + Test::More::ok( ($size < length $content), "Content of $name larger than $size bytes" ); + return $content; +} + +1; diff --git a/gnu/usr.bin/perl/t/lib/Sans_mypragma.pm b/gnu/usr.bin/perl/t/lib/Sans_mypragma.pm new file mode 100644 index 00000000000..a0b9dedd532 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/Sans_mypragma.pm @@ -0,0 +1,7 @@ +package Sans_mypragma; + +sub affected { + mypragma::in_effect(); +} + +1; diff --git a/gnu/usr.bin/perl/t/lib/Test/Builder/NoOutput.pm b/gnu/usr.bin/perl/t/lib/Test/Builder/NoOutput.pm new file mode 100644 index 00000000000..d83db9f1785 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/Test/Builder/NoOutput.pm @@ -0,0 +1,122 @@ +package Test::Builder::NoOutput; + +use strict; +use warnings; + +use base qw(Test::Builder); + + +=head1 NAME + +Test::Builder::NoOutput - A subclass of Test::Builder which prints nothing + +=head1 SYNOPSIS + + use Test::Builder::NoOutput; + + my $tb = Test::Builder::NoOutput->new; + + ...test as normal... + + my $output = $tb->read; + +=head1 DESCRIPTION + +This is a subclass of Test::Builder which traps all its output. +It is mostly useful for testing Test::Builder. + +=head3 read + + my $all_output = $tb->read; + my $output = $tb->read($stream); + +Returns all the output (including failure and todo output) collected +so far. It is destructive, each call to read clears the output +buffer. + +If $stream is given it will return just the output from that stream. +$stream's are... + + out output() + err failure_output() + todo todo_output() + all all outputs + +Defaults to 'all'. + +=cut + +my $Test = __PACKAGE__->new; + +sub create { + my $class = shift; + my $self = $class->SUPER::create(@_); + + my %outputs = ( + all => '', + out => '', + err => '', + todo => '', + ); + $self->{_outputs} = \%outputs; + + tie *OUT, "Test::Builder::NoOutput::Tee", \$outputs{all}, \$outputs{out}; + tie *ERR, "Test::Builder::NoOutput::Tee", \$outputs{all}, \$outputs{err}; + tie *TODO, "Test::Builder::NoOutput::Tee", \$outputs{all}, \$outputs{todo}; + + $self->output(*OUT); + $self->failure_output(*ERR); + $self->todo_output(*TODO); + + return $self; +} + +sub read { + my $self = shift; + my $stream = @_ ? shift : 'all'; + + my $out = $self->{_outputs}{$stream}; + + $self->{_outputs}{$stream} = ''; + + # Clear all the streams if 'all' is read. + if( $stream eq 'all' ) { + my @keys = keys %{$self->{_outputs}}; + $self->{_outputs}{$_} = '' for @keys; + } + + return $out; +} + + +package Test::Builder::NoOutput::Tee; + +# A cheap implementation of IO::Tee. + +sub TIEHANDLE { + my($class, @refs) = @_; + + my @fhs; + for my $ref (@refs) { + my $fh = Test::Builder->_new_fh($ref); + push @fhs, $fh; + } + + my $self = [@fhs]; + return bless $self, $class; +} + +sub PRINT { + my $self = shift; + + print $_ @_ for @$self; +} + +sub PRINTF { + my $self = shift; + my $format = shift; + + printf $_ @_ for @$self; +} + +1; diff --git a/gnu/usr.bin/perl/t/lib/common.pl b/gnu/usr.bin/perl/t/lib/common.pl index 36d45f3c99a..ef95c9d5415 100644 --- a/gnu/usr.bin/perl/t/lib/common.pl +++ b/gnu/usr.bin/perl/t/lib/common.pl @@ -15,9 +15,7 @@ our $pragma_name; $| = 1; my $Is_MacOS = $^O eq 'MacOS'; -my $tmpfile = "tmp0000"; -1 while -e ++$tmpfile; -END { 1 while unlink $tmpfile } +my $tmpfile = tempfile(); my @prgs = () ; my @w_files = () ; @@ -73,17 +71,20 @@ for (@prgs){ } my($prog,$expected) = split(/\nEXPECT(?:\n|$)/, $_, 2); - my ($todo, $todo_reason); - $todo = $prog =~ s/^#\s*TODO\s*(.*)\n//m and $todo_reason = $1; - # If the TODO reason starts ? then it's taken as a code snippet to evaluate - # This provides the flexibility to have conditional TODOs - if ($todo_reason && $todo_reason =~ s/^\?//) { - my $temp = eval $todo_reason; - if ($@) { - die "# In TODO code reason:\n# $todo_reason\n$@"; + my %reason; + foreach my $what (qw(skip todo)) { + $prog =~ s/^#\s*\U$what\E\s*(.*)\n//m and $reason{$what} = $1; + # If the SKIP reason starts ? then it's taken as a code snippet to + # evaluate. This provides the flexibility to have conditional SKIPs + if ($reason{$what} && $reason{$what} =~ s/^\?//) { + my $temp = eval $reason{$what}; + if ($@) { + die "# In \U$what\E code reason:\n# $reason{$what}\n$@"; + } + $reason{$what} = $temp; } - $todo_reason = $temp; } + if ( $prog =~ /--FILE--/) { my(@files) = split(/\n--FILE--\s*([^\s\n]*)\s*\n/, $prog) ; shift @files ; @@ -126,7 +127,7 @@ for (@prgs){ my $status = $?; $results =~ s/\n+$//; # allow expected output to be written as if $prog is on STDIN - $results =~ s/tmp\d+/-/g; + $results =~ s/$::tempfile_regexp/-/g; if ($^O eq 'VMS') { # some tests will trigger VMS messages that won't be expected $results =~ s/\n?%[A-Z]+-[SIWEF]-[A-Z]+,.*//; @@ -184,9 +185,9 @@ for (@prgs){ $ok = $results eq $expected; } - print_err_line( $switch, $prog, $expected, $results, $todo ) unless $ok; + local $::TODO = $reason{todo}; + print_err_line( $switch, $prog, $expected, $results, $::TODO ) unless $ok; - our $TODO = $todo ? $todo_reason : 0; ok($ok); foreach (@temps) diff --git a/gnu/usr.bin/perl/t/lib/compress/CompTestUtils.pm b/gnu/usr.bin/perl/t/lib/compress/CompTestUtils.pm index 1763b0309d8..22b6d5646c1 100644 --- a/gnu/usr.bin/perl/t/lib/compress/CompTestUtils.pm +++ b/gnu/usr.bin/perl/t/lib/compress/CompTestUtils.pm @@ -203,6 +203,14 @@ sub cmpFile return readFile($filename) eq unpack("u", $uue) ; } +sub isRawFormat +{ + my $class = shift; + my %raw = map { $_ => 1 } qw( RawDeflate ); + + return defined $raw{$class}; +} + sub uncompressBuffer { my $compWith = shift ; @@ -222,6 +230,8 @@ sub uncompressBuffer 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop', 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf' , 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf', + 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd' , + 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd', 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp', ); @@ -265,6 +275,10 @@ my %ErrorMap = ( 'IO::Compress::Gzip' => \$IO::Compress::Gzip: 'IO::Compress::Lzf::lzf' => \$IO::Compress::Lzf::LzfError, 'IO::Uncompress::UnLzf' => \$IO::Uncompress::UnLzf::UnLzfError, 'IO::Uncompress::UnLzf::unlzf' => \$IO::Uncompress::UnLzf::UnLzfError, + 'IO::Compress::PPMd' => \$IO::Compress::PPMd::PPMdError, + 'IO::Compress::PPMd::ppmd' => \$IO::Compress::PPMd::PPMdError, + 'IO::Uncompress::UnPPMd' => \$IO::Uncompress::UnPPMd::UnPPMdError, + 'IO::Uncompress::UnPPMd::unppmd' => \$IO::Uncompress::UnPPMd::UnPPMdError, 'IO::Compress::DummyComp' => \$IO::Compress::DummyComp::DummyCompError, 'IO::Compress::DummyComp::dummycomp'=> \$IO::Compress::DummyComp::DummyCompError, @@ -293,6 +307,8 @@ my %TopFuncMap = ( 'IO::Compress::Gzip' => 'IO::Compress::Gzip::gzip', 'IO::Uncompress::UnLzop' => 'IO::Uncompress::UnLzop::unlzop', 'IO::Compress::Lzf' => 'IO::Compress::Lzf::lzf', 'IO::Uncompress::UnLzf' => 'IO::Uncompress::UnLzf::unlzf', + 'IO::Compress::PPMd' => 'IO::Compress::PPMd::ppmd', + 'IO::Uncompress::UnPPMd' => 'IO::Uncompress::UnPPMd::unppmd', 'IO::Compress::DummyComp' => 'IO::Compress::DummyComp::dummyuncomp', 'IO::Uncompress::DummyUncomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', ); @@ -319,6 +335,8 @@ my %inverse = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gun 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf::unlzf', 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf', + 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd::unppmd', + 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd', 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', ); @@ -372,6 +390,8 @@ sub compressBuffer 'IO::Uncompress::UnLzop::unlzop' => 'IO::Compress::Lzop', 'IO::Uncompress::UnLzp' => 'IO::Compress::Lzf', 'IO::Uncompress::UnLzf::unlzf' => 'IO::Compress::Lzf', + 'IO::Uncompress::UnPPMd' => 'IO::Compress::PPMd', + 'IO::Uncompress::UnPPMd::unppmd' => 'IO::Compress::PPMd', 'IO::Uncompress::AnyInflate' => 'IO::Compress::Gzip', 'IO::Uncompress::AnyInflate::anyinflate' => 'IO::Compress::Gzip', 'IO::Uncompress::AnyUncompress' => 'IO::Compress::Gzip', diff --git a/gnu/usr.bin/perl/t/lib/compress/destroy.pl b/gnu/usr.bin/perl/t/lib/compress/destroy.pl index 9107b15096a..186520df162 100644 --- a/gnu/usr.bin/perl/t/lib/compress/destroy.pl +++ b/gnu/usr.bin/perl/t/lib/compress/destroy.pl @@ -17,7 +17,7 @@ BEGIN $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 7 + $extra ; + plan tests => 15 + $extra ; use_ok('IO::File') ; } @@ -73,6 +73,43 @@ EOM ok anyUncompress($name) eq $hello ; } + + { + title "Testing DESTROY doesn't clobber \$! etc "; + + my $lex = new LexFile my $name ; + + my $out; + my $result; + + { + ok my $z = new $CompressClass($name); + $z->write("abc") ; + $! = 22 ; + + cmp_ok $!, '==', 22, ' $! is 22'; + } + + cmp_ok $!, '==', 22, " \$! has not been changed by $CompressClass destructor"; + + + { + my $uncomp; + ok my $x = new $UncompressClass($name, -Append => 1) ; + + my $len ; + 1 while ($len = $x->read($result)) > 0 ; + + $! = 22 ; + + cmp_ok $!, '==', 22, ' $! is 22'; + } + + cmp_ok $!, '==', 22, " \$! has not been changed by $UncompressClass destructor"; + + is $result, "abc", " Got uncompressed content ok"; + + } } 1; diff --git a/gnu/usr.bin/perl/t/lib/compress/generic.pl b/gnu/usr.bin/perl/t/lib/compress/generic.pl index 51b45fc74ba..54abab0a545 100644 --- a/gnu/usr.bin/perl/t/lib/compress/generic.pl +++ b/gnu/usr.bin/perl/t/lib/compress/generic.pl @@ -18,7 +18,7 @@ BEGIN $extra = 1 if $st ; - plan(tests => 670 + $extra) ; + plan(tests => 666 + $extra) ; } sub myGZreadFile @@ -47,6 +47,7 @@ sub run my $Error = getErrorRef($CompressClass); my $UnError = getErrorRef($UncompressClass); + if(1) { title "Testing $CompressClass Errors"; @@ -56,13 +57,6 @@ sub run like $@, mkEvalErr("^$CompressClass: output buffer is read-only") ; my($out, $gz); - $out = "" ; - eval qq[\$a = new $CompressClass ] . '$out ;' ; - like $@, mkEvalErr("^$CompressClass: output filename is undef or null string"); - - $out = undef ; - eval qq[\$a = new $CompressClass \$out ;] ; - like $@, mkEvalErr("^$CompressClass: output filename is undef or null string"); my $x ; $gz = new $CompressClass(\$x); @@ -75,13 +69,12 @@ sub run eval ' $gz->write({})' ; like $@, mkEvalErr("^${CompressClass}::write: not a scalar reference"); - #like $@, mkEvalErr("^${CompressClass}::write: input parameter not a filename, filehandle, array ref or scalar ref"); eval ' $gz->syswrite("abc", 1, 5)' ; like $@, mkEvalErr("^${CompressClass}::write: offset outside string"); eval ' $gz->syswrite("abc", 1, -4)' ; - like $@, mkEvalErr("^${CompressClass}::write: offset outside string"); + like $@, mkEvalErr("^${CompressClass}::write: offset outside string"), "write outside string"; } @@ -89,18 +82,13 @@ sub run title "Testing $UncompressClass Errors"; my $out = "" ; - eval qq[\$a = new $UncompressClass \$out ;] ; - like $@, mkEvalErr("^$UncompressClass: input filename is undef or null string"); - $out = undef ; - eval qq[\$a = new $UncompressClass \$out ;] ; - like $@, mkEvalErr("^$UncompressClass: input filename is undef or null string"); my $lex = new LexFile my $name ; ok ! -e $name, " $name does not exist"; - eval qq[\$a = new $UncompressClass "$name" ;] ; - is $$UnError, "input file '$name' does not exist"; + $a = new $UncompressClass "$name" ; + is $a, undef; my $gc ; my $guz = new $CompressClass(\$gc); @@ -118,6 +106,7 @@ sub run } + { title "Testing $CompressClass and $UncompressClass"; @@ -161,7 +150,6 @@ sub run my $lex = new LexFile my $name ; - #my $name = "/tmp/try.lzf"; my $hello = <<EOM ; hello world @@ -322,7 +310,6 @@ EOM ok $x->close, " close" ; } - #exit; is $uncomp, $hello, " expected output" ; } @@ -419,11 +406,11 @@ EOM ok ! defined $x->fileno() ; 1 while $x->read($uncomp) > 0 ; - ok $x->close ; + ok $x->close, "closed" ; } - is $uncomp, $hello ; - ok $buffer eq $keep ; + is $uncomp, $hello, "got expected uncompressed data" ; + ok $buffer eq $keep, "compressed input not changed" ; } if ($CompressClass ne 'RawDeflate') @@ -434,8 +421,9 @@ EOM my $buffer = ''; { my $x ; - ok $x = new $CompressClass(\$buffer) ; - ok $x->close ; + $x = new $CompressClass(\$buffer); + ok $x, "new $CompressClass" ; + ok $x->close, "close ok" ; } @@ -541,7 +529,6 @@ EOM read($fh1, $rest, 5000); is $x->trailingData() . $rest, $trailer ; #print "# [".$x->trailingData() . "][$rest]\n" ; - #exit; } @@ -1416,7 +1403,6 @@ EOT } } - { title "write tests - invalid data" ; diff --git a/gnu/usr.bin/perl/t/lib/compress/merge.pl b/gnu/usr.bin/perl/t/lib/compress/merge.pl index 7811966e84e..61342924662 100644 --- a/gnu/usr.bin/perl/t/lib/compress/merge.pl +++ b/gnu/usr.bin/perl/t/lib/compress/merge.pl @@ -89,15 +89,7 @@ sub run ok ! $gz, " Did not create $CompressClass object"; - { - if ($to_file) { - is $$Error, "Output file '$out_file' is not writable", - " Got non-writable filename message" ; - } - else { - ok $$Error, " Got error message" ; - } - } + ok $$Error, " Got error message" ; } chmod 0777, $out_file ; @@ -137,7 +129,7 @@ sub run ok ! $CompressClass->new($buffer, Merge => 1), " constructor fails"; { - like $$Error, '/Cannot create InflateScan object: (Header Error|unexpected end of file)/', " got Bad Magic" ; + like $$Error, '/Cannot create InflateScan object: (Header Error|unexpected end of file|Inflation Error: data error)/', " got Bad Magic" ; } } diff --git a/gnu/usr.bin/perl/t/lib/compress/multi.pl b/gnu/usr.bin/perl/t/lib/compress/multi.pl index cfb5666f6ca..3e9bbfd4642 100644 --- a/gnu/usr.bin/perl/t/lib/compress/multi.pl +++ b/gnu/usr.bin/perl/t/lib/compress/multi.pl @@ -13,7 +13,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 694 + $extra ; + plan tests => 1324 + $extra ; use_ok('IO::Uncompress::AnyUncompress', qw($AnyUncompressError)) ; @@ -47,6 +47,9 @@ EOM even more stuff EOM + my $b0length = length $buffers[0]; + my $bufcount = @buffers; + { my $cc ; my $gz ; @@ -136,6 +139,46 @@ EOM } foreach my $unc ($UncompressClass, 'IO::Uncompress::AnyUncompress') { + foreach my $blk (1, 20, $b0length - 1, $b0length, $b0length +1) { + title " Testing $CompressClass with $unc, BlockSize $blk and $i streams, from $fb"; + $cc = $output ; + if ($fb eq 'filehandle') + { + $cc = new IO::File "<$name" ; + } + my @opts = $unc ne $UncompressClass + ? (RawInflate => 1) + : (); + my $gz = new $unc($cc, + @opts, + Strict => 1, + AutoClose => 1, + Append => 1, + MultiStream => 1, + Transparent => 0) + or diag $$UnError; + isa_ok $gz, $UncompressClass, ' $gz' ; + + my $un = ''; + my $b = $blk; + # Want the first read to be in the middle of a stream + # and the second to cross a stream boundary + $b = 1000 while $gz->read($un, $b) > 0 ; + #print "[[$un]]\n" while $gz->read($un) > 0 ; + ok ! $gz->error(), " ! error()" + or diag "Error is " . $gz->error() ; + ok $gz->eof(), " eof()"; + ok $gz->close(), " close() ok" + or diag "errno $!\n" ; + + is $gz->streamCount(), $i +1, " streamCount ok " . ($i +1) + or diag "Stream count is " . $gz->streamCount(); + ok $un eq join('', @buffs), " expected output" ; + + } + } + + foreach my $unc ($UncompressClass, 'IO::Uncompress::AnyUncompress') { title " Testing $CompressClass with $unc nextStream and $i streams, from $fb"; $cc = $output ; if ($fb eq 'filehandle') @@ -195,7 +238,8 @@ EOM is $gz->tell(), 0, " tell is 0"; } - is $gz->nextStream(), 0, " nextStream ok"; + is $gz->nextStream(), 0, " nextStream ok" + or diag $gz->error() ; ok $gz->eof(), " eof()"; ok $gz->close(), " close() ok" or diag "errno $!\n" ; diff --git a/gnu/usr.bin/perl/t/lib/compress/oneshot.pl b/gnu/usr.bin/perl/t/lib/compress/oneshot.pl index 0646958d89d..4f8bb83ac6b 100644 --- a/gnu/usr.bin/perl/t/lib/compress/oneshot.pl +++ b/gnu/usr.bin/perl/t/lib/compress/oneshot.pl @@ -16,7 +16,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 970 + $extra ; + plan tests => 986 + $extra ; use_ok('IO::Uncompress::AnyUncompress', qw(anyuncompress $AnyUncompressError)) ; @@ -42,6 +42,9 @@ sub run my $Func = getTopFuncRef($bit); my $TopType = getTopFuncName($bit); + #my $inverse = getInverse($bit); + #my $InverseFunc = getTopFuncRef($inverse); + title "Testing $TopType Error Cases"; my $a; @@ -510,6 +513,7 @@ sub run my $TopTypeInverse = getInverse($bit); my $FuncInverse = getTopFuncRef($TopTypeInverse); + my $ErrorInverse = getErrorRef($TopTypeInverse); my $lex = new LexFile(my $file1, my $file2) ; @@ -606,6 +610,34 @@ sub run my @headers = getHeaders($file3); is @headers, $ms ? @input : 1, " Header count ok"; } + + SKIP: + { + title "Truncated file"; + skip '', 7 + if $CompressClass =~ /lzop|lzf/i ; + + my @in ; + push @in, "abcde" x 10; + push @in, "defgh" x 1000; + push @in, "12345" x 50000; + + my $out; + + for (@in) { + ok &$Func(\$_ , \$out, Append => 1 ), ' Compressed ok' + or diag $$Error; + } + #ok &$Func(\@in, \$out, MultiStream => 1 ), ' Compressed ok' + substr($out, -179) = ''; + + my $got; + my $status ; + ok $status = &$FuncInverse(\$out => \$got, MultiStream => 0), " Uncompressed stream 1 ok"; + is $got, "abcde" x 10 ; + ok ! &$FuncInverse(\$out => \$got, MultiStream => 1), " Didn't uncompress"; + is $$ErrorInverse, "unexpected end of file", " Got unexpected eof"; + } } } diff --git a/gnu/usr.bin/perl/t/lib/contains_bad_pod.xr b/gnu/usr.bin/perl/t/lib/contains_bad_pod.xr new file mode 100644 index 00000000000..ad65663e221 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/contains_bad_pod.xr @@ -0,0 +1,5 @@ +=head foo + +bar baz. + +=cut diff --git a/gnu/usr.bin/perl/t/lib/cygwin.t b/gnu/usr.bin/perl/t/lib/cygwin.t index 096cb98dcf5..8f1410efef4 100755 --- a/gnu/usr.bin/perl/t/lib/cygwin.t +++ b/gnu/usr.bin/perl/t/lib/cygwin.t @@ -43,7 +43,7 @@ chdir($pwd); is(Cygwin::win_to_posix_path($winpath, 1), "/", "win to absolute posix path"); my $mount = join '', `/usr/bin/mount`; -$mount =~ m|on /usr/bin type .+ \((\w+mode)\)|m; +$mount =~ m|on /usr/bin type .+ \((\w+mode)[,\)]|m; my $binmode = $1 eq 'binmode'; is(Cygwin::is_binmount("/"), $binmode ? 1 : '', "check / for binmount"); diff --git a/gnu/usr.bin/perl/t/lib/feature/bundle b/gnu/usr.bin/perl/t/lib/feature/bundle new file mode 100644 index 00000000000..a869c7541fb --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/feature/bundle @@ -0,0 +1,50 @@ +Check feature bundles. + +__END__ +# Standard feature bundle +use feature ":5.10"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# more specific: 5.10.0 maps to 5.10 +use feature ":5.10.0"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# as does 5.10.1 +use feature ":5.10.1"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# as does 5.10.99 +use feature ":5.10.99"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# 5.9.5 also supported +use feature ":5.9.5"; +say "Hello", "world"; +EXPECT +Helloworld +######## +# 5.9 not supported +use feature ":5.9"; +EXPECT +OPTIONS regex +^Feature bundle "5.9" is not supported by Perl \d+\.\d+\.\d+ at - line \d+ +######## +# 5.9.4 not supported +use feature ":5.9.4"; +EXPECT +OPTIONS regex +^Feature bundle "5.9.4" is not supported by Perl \d+\.\d+\.\d+ at - line \d+ +######## +# 5.8.8 not supported +use feature ":5.8.8"; +EXPECT +OPTIONS regex +^Feature bundle "5.8.8" is not supported by Perl \d+\.\d+\.\d+ at - line \d+ diff --git a/gnu/usr.bin/perl/t/lib/h2ph.h b/gnu/usr.bin/perl/t/lib/h2ph.h index 495789a206d..78429ca3107 100644 --- a/gnu/usr.bin/perl/t/lib/h2ph.h +++ b/gnu/usr.bin/perl/t/lib/h2ph.h @@ -26,6 +26,10 @@ #undef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) +/* Test #undef'ining an existing constant function */ +#define NOTTRUE 0 +#undef NOTTRUE + /* Test #ifdef */ #ifdef __SOME_UNIMPORTANT_PROPERTY #define MIN(a,b) ((a) < (b) ? (a) : (b)) @@ -68,9 +72,11 @@ function Tru64_Pascal(n: Integer): Integer; * with `use lib qw(/opt/perl5/lib/site_perl/i586-linux/linux);' or whatever * your equivalent is... */ +#if 0 #include <sys/socket.h> #import "sys/ioctl.h" #include_next <sys/fcntl.h> +#endif /* typedefs should be ignored */ typedef struct a_struct { diff --git a/gnu/usr.bin/perl/t/lib/h2ph.pht b/gnu/usr.bin/perl/t/lib/h2ph.pht index 145e6824ae2..3723fca84ad 100644 --- a/gnu/usr.bin/perl/t/lib/h2ph.pht +++ b/gnu/usr.bin/perl/t/lib/h2ph.pht @@ -1,6 +1,6 @@ require '_h2ph_pre.ph'; -no warnings 'redefine'; +no warnings qw(redefine misc); unless(defined(&SQUARE)) { sub SQUARE { @@ -22,6 +22,8 @@ unless(defined(&_H2PH_H_)) { my($a,$b) = @_; eval q((($a) > ($b) ? ($a) : ($b))); }' unless defined(&MAX); + eval 'sub NOTTRUE () {0;}' unless defined(&NOTTRUE); + undef(&NOTTRUE) if defined(&NOTTRUE); if(defined(&__SOME_UNIMPORTANT_PROPERTY)) { eval 'sub MIN { my($a,$b) = @_; @@ -47,15 +49,17 @@ unless(defined(&_H2PH_H_)) { } else { eval 'sub WHATEVER () {1000;}' unless defined(&WHATEVER); } - require 'sys/socket.ph'; - require 'sys/ioctl.ph'; - eval { - my(@REM); - my(%INCD) = map { $INC{$_} => 1 } (grep { $_ eq "sys/fcntl.ph" } keys(%INC)); - @REM = map { "$_/sys/fcntl.ph" } (grep { not exists($INCD{"$_/sys/fcntl.ph"}) and -f "$_/sys/fcntl.ph" } @INC); - require "$REM[0]" if @REM; - }; - warn($@) if $@; + if(0) { + require 'sys/socket.ph'; + require 'sys/ioctl.ph'; + eval { + my(@REM); + my(%INCD) = map { $INC{$_} => 1 } (grep { $_ eq "sys/fcntl.ph" } keys(%INC)); + @REM = map { "$_/sys/fcntl.ph" } (grep { not exists($INCD{"$_/sys/fcntl.ph"}) and -f "$_/sys/fcntl.ph" } @INC); + require "$REM[0]" if @REM; + }; + warn($@) if $@; + } eval("sub sun () { 0; }") unless defined(&sun); eval("sub mon () { 1; }") unless defined(&mon); eval("sub tue () { 2; }") unless defined(&tue); diff --git a/gnu/usr.bin/perl/t/lib/manifest.t b/gnu/usr.bin/perl/t/lib/manifest.t new file mode 100755 index 00000000000..377f6660a72 --- /dev/null +++ b/gnu/usr.bin/perl/t/lib/manifest.t @@ -0,0 +1,52 @@ +#!./perl -w + +# Test the well-formed-ness of the MANIFEST file. + +BEGIN { + chdir 't'; + @INC = '../lib'; +} + +use strict; +use File::Spec; +require './test.pl'; + +plan('no_plan'); + +my $manifest = File::Spec->catfile(File::Spec->updir(), 'MANIFEST'); + +open my $m, '<', $manifest or die "Can't open '$manifest': $!"; + +# Test that MANIFEST uses tabs - not spaces - after the name of the file. +while (<$m>) { + chomp; + next unless /\s/; # Ignore lines without whitespace (i.e., filename only) + my ($file, $separator) = /^(\S+)(\s+)/; + isnt($file, undef, "Line $. doesn't start with a blank") or next; + if ($separator !~ tr/\t//c) { + # It's all tabs + next; + } elsif ($separator !~ tr/ //c) { + # It's all spaces + fail("Spaces in entry for $file"); + } elsif ($separator =~ tr/\t//) { + fail("Mixed tabs and spaces in entry for $file"); + } else { + fail("Odd whitespace in entry for $file"); + } +} + +close $m or die $!; + +# Test that MANIFEST is properly sorted +SKIP: { + skip("'Porting/manisort' not found", 1) if (! -f '../Porting/manisort'); + + my $result = runperl('progfile' => '../Porting/manisort', + 'args' => [ '-c', '../MANIFEST' ], + 'stderr' => 1); + + like($result, qr/is sorted properly/, 'MANIFEST sorted properly'); +} + +# EOF diff --git a/gnu/usr.bin/perl/t/lib/mypragma.t b/gnu/usr.bin/perl/t/lib/mypragma.t index 48e9865384a..0ebd2075b0e 100644 --- a/gnu/usr.bin/perl/t/lib/mypragma.t +++ b/gnu/usr.bin/perl/t/lib/mypragma.t @@ -7,7 +7,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 14; use mypragma (); # don't enable this pragma yet @@ -22,7 +22,10 @@ is(mypragma::in_effect(), undef, "pragma not in effect yet"); or die $@; use mypragma; + use Sans_mypragma; is(mypragma::in_effect(), 42, "pragma is in effect within this block"); + is(Sans_mypragma::affected(), undef, + "pragma not in effect outside this file"); eval qq{is(mypragma::in_effect(), 42, "pragma is in effect within this eval"); 1} or die $@; diff --git a/gnu/usr.bin/perl/t/lib/proxy_constant_subs.t b/gnu/usr.bin/perl/t/lib/proxy_constant_subs.t index 4af73d38c42..45b0a54b9fb 100644 --- a/gnu/usr.bin/perl/t/lib/proxy_constant_subs.t +++ b/gnu/usr.bin/perl/t/lib/proxy_constant_subs.t @@ -7,20 +7,20 @@ BEGIN { print "1..0 # Skip -- Perl configured without B module\n"; exit 0; } - if ($Config::Config{'extensions'} !~ /\bPOSIX\b/) { - print "1..0 # Skip -- Perl configured without POSIX\n"; + if ($Config::Config{'extensions'} !~ /\bFcntl\b/) { + print "1..0 # Skip -- Perl configured without Fcntl\n"; exit 0; } - # errno is a real subroutine, and acts as control + # S_IFMT is a real subroutine, and acts as control # SEEK_SET is a proxy constant subroutine. - @symbols = qw(errno SEEK_SET); + @symbols = qw(S_IFMT SEEK_SET); } use strict; use warnings; use Test::More tests => 4 * @symbols; use B qw(svref_2object GVf_IMPORTED_CV); -use POSIX @symbols; +use Fcntl @symbols; # GVf_IMPORTED_CV should not be set on the original, but should be set on the # imported GV. @@ -29,7 +29,7 @@ foreach my $symbol (@symbols) { my ($ps, $ms); { no strict 'refs'; - $ps = svref_2object(\*{"POSIX::$symbol"}); + $ps = svref_2object(\*{"Fcntl::$symbol"}); $ms = svref_2object(\*{"::$symbol"}); } isa_ok($ps, 'B::GV'); diff --git a/gnu/usr.bin/perl/t/lib/warnings/7fatal b/gnu/usr.bin/perl/t/lib/warnings/7fatal index dfbb7134ab1..6eeac741c2a 100644 --- a/gnu/usr.bin/perl/t/lib/warnings/7fatal +++ b/gnu/usr.bin/perl/t/lib/warnings/7fatal @@ -285,7 +285,8 @@ time ; { use warnings FATAL => qw(void) ; - length "abc" ; + $a = "abc"; + length $a ; } join "", 1,2,3 ; @@ -293,7 +294,7 @@ join "", 1,2,3 ; print "done\n" ; EXPECT Useless use of time in void context at - line 4. -Useless use of length in void context at - line 8. +Useless use of length in void context at - line 9. ######## # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : '' @@ -303,7 +304,8 @@ time ; { use warnings FATAL => qw(void) ; - length "abc" ; + $a = "abc"; + length $a ; } join "", 1,2,3 ; @@ -311,7 +313,7 @@ join "", 1,2,3 ; print "done\n" ; EXPECT Useless use of time in void context at - line 4. -Useless use of length in void context at - line 8. +Useless use of length in void context at - line 9. ######## use warnings FATAL => 'all'; @@ -362,35 +364,39 @@ Use of uninitialized value $b in scalar chop at - line 7. use warnings FATAL => 'syntax', NONFATAL => 'void' ; -length "abc"; +$a = "abc"; +length $a; print STDERR "The End.\n" ; EXPECT -Useless use of length in void context at - line 4. +Useless use of length in void context at - line 5. The End. ######## use warnings FATAL => 'all', NONFATAL => 'void' ; -length "abc"; +$a = "abc"; +length $a; print STDERR "The End.\n" ; EXPECT -Useless use of length in void context at - line 4. +Useless use of length in void context at - line 5. The End. ######## use warnings FATAL => 'all', NONFATAL => 'void' ; my $a ; chomp $a; -length "abc"; + +$b = "abc" ; +length $b; print STDERR "The End.\n" ; EXPECT -Useless use of length in void context at - line 5. +Useless use of length in void context at - line 7. Use of uninitialized value $a in scalar chomp at - line 4. ######## use warnings FATAL => 'void', NONFATAL => 'void' ; - -length "abc"; +$a = "abc"; +length $a; print STDERR "The End.\n" ; EXPECT Useless use of length in void context at - line 4. @@ -399,8 +405,8 @@ The End. # TODO ? !$Config{usethreads} && $::UTF8 && ($ENV{PERL_DESTRUCT_LEVEL} || 0) > 1 ? "Parser leaks OPs, which leak shared hash keys" : '' use warnings NONFATAL => 'void', FATAL => 'void' ; - -length "abc"; +$a = "abc"; +length $a; print STDERR "The End.\n" ; EXPECT Useless use of length in void context at - line 4. diff --git a/gnu/usr.bin/perl/t/lib/warnings/9enabled b/gnu/usr.bin/perl/t/lib/warnings/9enabled index 6d15948ed4b..a6ad931ed74 100644 --- a/gnu/usr.bin/perl/t/lib/warnings/9enabled +++ b/gnu/usr.bin/perl/t/lib/warnings/9enabled @@ -2,95 +2,95 @@ Check warnings::enabled & warnings::warn __END__ ---FILE-- abc.pm -package abc ; +--FILE-- abc0.pm +package abc0 ; use warnings "io" ; print "ok1\n" if ! warnings::enabled('all') ; print "ok2\n" if ! warnings::enabled("io") ; 1; ---FILE-- +--FILE-- no warnings; -use abc ; +use abc0 ; EXPECT ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc1.pm +package abc1 ; no warnings ; print "ok1\n" if !warnings::enabled('all') ; print "ok2\n" if warnings::enabled("syntax") ; 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; +use abc1 ; EXPECT ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc2.pm +package abc2 ; use warnings 'syntax' ; print "ok1\n" if warnings::enabled('io') ; print "ok2\n" if ! warnings::enabled("syntax") ; 1; ---FILE-- +--FILE-- use warnings 'io' ; -use abc ; +use abc2 ; EXPECT ok1 ok2 ######## ---FILE-- abc +--FILE-- abc3 no warnings ; print "ok1\n" if !warnings::enabled('all') ; print "ok2\n" if !warnings::enabled("syntax") ; 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -require "abc" ; +require "abc3" ; EXPECT ok1 ok2 ######## ---FILE-- abc +--FILE-- abc4 use warnings 'syntax' ; print "ok1\n" if ! warnings::enabled('all') ; print "ok2\n" if ! warnings::enabled("syntax") ; print "ok3\n" if ! warnings::enabled("io") ; 1; ---FILE-- +--FILE-- use warnings 'io' ; -require "abc" ; +require "abc4" ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc5.pm +package abc5 ; no warnings ; sub check { print "ok1\n" if !warnings::enabled('all') ; print "ok2\n" if warnings::enabled("syntax") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -abc::check() ; +use abc5 ; +abc5::check() ; EXPECT ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc6.pm +package abc6 ; use warnings 'io' ; sub check { print "ok1\n" if ! warnings::enabled('all') ; @@ -98,35 +98,35 @@ sub check { print "ok3\n" if ! warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -abc::check() ; +use abc6 ; +abc6::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc -package abc ; +--FILE-- abc7 +package abc7 ; no warnings ; sub check { print "ok1\n" if !warnings::enabled('all') ; print "ok2\n" if warnings::enabled("syntax") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -require "abc" ; -abc::check() ; +require "abc7" ; +abc7::check() ; EXPECT ok1 ok2 ######## ---FILE-- abc -package abc ; +--FILE-- abc8 +package abc8 ; use warnings 'io' ; sub check { print "ok1\n" if ! warnings::enabled('all') ; @@ -134,18 +134,18 @@ sub check { print "ok3\n" if ! warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -require "abc" ; -abc::check() ; +require "abc8" ; +abc8::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc9.pm +package abc9 ; use warnings "io" ; print "ok1\n" if ! warnings::enabled('all') ; print "ok2\n" if ! warnings::enabled("io") ; @@ -153,9 +153,9 @@ print "ok2\n" if ! warnings::enabled("io") ; --FILE-- def.pm package def; no warnings; -use abc ; +use abc9 ; 1; ---FILE-- +--FILE-- use warnings; use def ; EXPECT @@ -163,8 +163,8 @@ ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc10.pm +package abc10 ; no warnings ; print "ok1\n" if ! warnings::enabled('all') ; print "ok2\n" if warnings::enabled("syntax") ; @@ -174,7 +174,7 @@ print "ok3\n" if !warnings::enabled("io") ; use warnings 'syntax' ; print "ok4\n" if !warnings::enabled('all') ; print "ok5\n" if !warnings::enabled("io") ; -use abc ; +use abc10 ; 1; --FILE-- use warnings 'io' ; @@ -187,19 +187,19 @@ ok4 ok5 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc11.pm +package abc11 ; no warnings ; sub check { print "ok1\n" if !warnings::enabled('all') ; print "ok2\n" if warnings::enabled("syntax") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -eval { - abc::check() ; +use abc11 ; +eval { + abc11::check() ; }; print $@ ; EXPECT @@ -207,8 +207,8 @@ ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc12.pm +package abc12 ; use warnings 'io' ; sub check { print "ok1\n" if ! warnings::enabled('all') ; @@ -216,11 +216,11 @@ sub check { print "ok3\n" if ! warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -eval { - abc::check() ; +use abc12 ; +eval { + abc12::check() ; } ; print $@ ; EXPECT @@ -229,19 +229,19 @@ ok2 ok3 ######## ---FILE-- abc -package abc ; +--FILE-- abc13 +package abc13 ; no warnings ; sub check { print "ok1\n" if !warnings::enabled('all') ; print "ok2\n" if warnings::enabled("syntax") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -require "abc" ; -eval { - abc::check() ; +require "abc13" ; +eval { + abc13::check() ; } ; print $@ ; EXPECT @@ -249,8 +249,8 @@ ok1 ok2 ######## ---FILE-- abc -package abc ; +--FILE-- abc14 +package abc14 ; use warnings 'io' ; sub check { print "ok1\n" if !warnings::enabled('all') ; @@ -258,14 +258,14 @@ sub check { print "ok3\n" if warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -require "abc" ; -eval { - use warnings 'io' ; - abc::check() ; +require "abc14" ; +eval { + use warnings 'io' ; + abc14::check() ; }; -abc::check() ; +abc14::check() ; print $@ ; EXPECT ok1 @@ -275,8 +275,8 @@ ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc15.pm +package abc15 ; use warnings 'io' ; sub check { print "ok1\n" if ! warnings::enabled('all') ; @@ -284,10 +284,10 @@ sub check { print "ok3\n" if ! warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -sub fred { abc::check() } +use abc15 ; +sub fred { abc15::check() } fred() ; EXPECT ok1 @@ -295,24 +295,24 @@ ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc16.pm +package abc16 ; use warnings 'io' ; sub check { print "ok1\n" if ! warnings::enabled('all') ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -sub fred { no warnings ; abc::check() } +use abc16 ; +sub fred { no warnings ; abc16::check() } fred() ; EXPECT ok1 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc17.pm +package abc17 ; use warnings 'misc' ; sub check { print "ok1\n" if ! warnings::enabled('all') ; @@ -321,10 +321,10 @@ sub check { print "ok4\n" if ! warnings::enabled("misc") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -sub fred { use warnings 'io' ; abc::check() } +use abc17 ; +sub fred { use warnings 'io' ; abc17::check() } fred() ; EXPECT ok1 @@ -335,12 +335,12 @@ ok4 # check warnings::warn use warnings ; -eval { - warnings::warn() +eval { + warnings::warn() } ; print $@ ; -eval { - warnings::warn("fred", "joe") +eval { + warnings::warn("fred", "joe") } ; print $@ ; EXPECT @@ -350,12 +350,12 @@ Unknown warnings category 'fred' at - line 9 # check warnings::warnif use warnings ; -eval { - warnings::warnif() +eval { + warnings::warnif() } ; print $@ ; -eval { - warnings::warnif("fred", "joe") +eval { + warnings::warnif("fred", "joe") } ; print $@ ; EXPECT @@ -363,42 +363,42 @@ Usage: warnings::warnif([category,] 'message') at - line 5 Unknown warnings category 'fred' at - line 9 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc18.pm +package abc18 ; use warnings 'misc' ; sub check { warnings::warn("io", "hello") } 1; --FILE-- use warnings "io" ; -use abc; -abc::check() ; +use abc18; +abc18::check() ; EXPECT hello at - line 3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc19.pm +package abc19 ; use warnings 'misc' ; sub check { warnings::warn("misc", "hello") } 1; --FILE-- use warnings "io" ; -use abc; -abc::check() ; +use abc19; +abc19::check() ; EXPECT hello at - line 3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc20.pm +package abc20 ; use warnings 'misc' ; sub check { warnings::warn("io", "hello") } 1; --FILE-- use warnings qw( FATAL deprecated ) ; -use abc; -eval { - abc::check() ; +use abc20; +eval { + abc20::check() ; } ; print "[[$@]]\n"; EXPECT @@ -406,16 +406,16 @@ hello at - line 4 [[]] ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc21.pm +package abc21 ; use warnings 'misc' ; sub check { warnings::warn("io", "hello") } 1; --FILE-- use warnings qw( FATAL io ) ; -use abc; -eval { - abc::check() ; +use abc21; +eval { + abc21::check() ; } ; print "[[$@]]\n"; EXPECT @@ -423,81 +423,81 @@ EXPECT ]] ######## -W ---FILE-- abc.pm -package abc ; +--FILE-- abc22.pm +package abc22 ; use warnings "io" ; print "ok1\n" if warnings::enabled("io") ; print "ok2\n" if warnings::enabled("all") ; 1; ---FILE-- +--FILE-- no warnings; -use abc ; +use abc22 ; EXPECT ok1 ok2 ######## -X ---FILE-- abc.pm -package abc ; +--FILE-- abc23.pm +package abc23 ; use warnings "io" ; print "ok1\n" if !warnings::enabled("io") ; print "ok2\n" if !warnings::enabled("all") ; 1; ---FILE-- +--FILE-- use warnings; -use abc ; +use abc23 ; EXPECT ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc24.pm +package abc24 ; no warnings ; sub check { print "ok\n" if ! warnings::enabled() ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -abc::check() ; +use abc24 ; +abc24::check() ; EXPECT -package 'abc' not registered for warnings at abc.pm line 4 +package 'abc24' not registered for warnings at abc24.pm line 4 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc25.pm +package abc25 ; no warnings ; sub check { warnings::warn("fred") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -abc::check() ; +use abc25 ; +abc25::check() ; EXPECT -package 'abc' not registered for warnings at abc.pm line 4 +package 'abc25' not registered for warnings at abc25.pm line 4 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc26.pm +package abc26 ; no warnings ; sub check { warnings::warnif("fred") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -abc::check() ; +use abc26 ; +abc26::check() ; EXPECT -package 'abc' not registered for warnings at abc.pm line 4 +package 'abc26' not registered for warnings at abc26.pm line 4 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc27.pm +package abc27 ; use warnings 'io' ; use warnings::register ; sub check { @@ -506,19 +506,19 @@ sub check { print "ok3\n" if !warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -use warnings 'abc' ; -abc::check() ; +use abc27 ; +use warnings 'abc27' ; +abc27::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc28.pm +package abc28 ; use warnings 'io' ; use warnings::register ; sub check { @@ -527,18 +527,18 @@ sub check { print "ok3\n" if !warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -abc::check() ; +use abc28 ; +abc28::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc29.pm +package abc29 ; no warnings ; use warnings::register ; sub check { @@ -546,19 +546,19 @@ sub check { print "ok2\n" if warnings::enabled("syntax") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -use warnings 'abc' ; -eval { abc::check() ; }; +use abc29 ; +use warnings 'abc29' ; +eval { abc29::check() ; }; print $@ ; EXPECT ok1 ok2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc30.pm +package abc30 ; use warnings 'io' ; use warnings::register ; sub check { @@ -567,10 +567,10 @@ sub check { print "ok3\n" if !warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -eval { abc::check() ; } ; +use abc30 ; +eval { abc30::check() ; } ; print $@ ; EXPECT ok1 @@ -578,8 +578,8 @@ ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc31.pm +package abc31 ; use warnings 'io' ; use warnings::register ; sub check { @@ -588,11 +588,11 @@ sub check { print "ok3\n" if !warnings::enabled("io") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -use warnings 'abc' ; -sub fred { abc::check() } +use abc31 ; +use warnings 'abc31' ; +sub fred { abc31::check() } fred() ; EXPECT ok1 @@ -600,25 +600,25 @@ ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc32.pm +package abc32 ; use warnings 'io' ; use warnings::register ; sub check { print "ok1\n" if ! warnings::enabled ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -sub fred { no warnings ; abc::check() } +use abc32 ; +sub fred { no warnings ; abc32::check() } fred() ; EXPECT ok1 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc33.pm +package abc33 ; use warnings 'misc' ; use warnings::register; sub check { @@ -628,11 +628,11 @@ sub check { print "ok4\n" if ! warnings::enabled("misc") ; } 1; ---FILE-- +--FILE-- use warnings 'syntax' ; -use abc ; -use warnings 'abc' ; -sub fred { use warnings 'io' ; abc::check() } +use abc33 ; +use warnings 'abc33' ; +sub fred { use warnings 'io' ; abc33::check() } fred() ; EXPECT ok1 @@ -641,42 +641,42 @@ ok3 ok4 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc34.pm +package abc34 ; use warnings 'misc' ; use warnings::register; sub check { warnings::warn("hello") } 1; --FILE-- -use abc; -use warnings "abc" ; -abc::check() ; +use abc34; +use warnings "abc34" ; +abc34::check() ; EXPECT hello at - line 3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc35.pm +package abc35 ; use warnings::register; sub check { warnings::warn("hello") } 1; --FILE-- -use abc; -abc::check() ; +use abc35; +abc35::check() ; EXPECT hello at - line 2 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc36.pm +package abc36 ; use warnings::register ; sub check { warnings::warn("hello") } 1; --FILE-- -use abc; +use abc36; use warnings qw( FATAL deprecated ) ; eval { - abc::check() ; + abc36::check() ; } ; print "[[$@]]\n"; EXPECT @@ -684,16 +684,16 @@ hello at - line 4 [[]] ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc37.pm +package abc37 ; use warnings::register ; sub check { warnings::warn("hello") } 1; --FILE-- -use abc; -use warnings qw( FATAL abc ) ; -eval { - abc::check() ; +use abc37; +use warnings qw( FATAL abc37 ) ; +eval { + abc37::check() ; } ; print "[[$@]]\n"; EXPECT @@ -701,305 +701,305 @@ EXPECT ]] ######## -W ---FILE-- abc.pm -package abc ; +--FILE-- abc38.pm +package abc38 ; use warnings "io" ; use warnings::register ; -sub check { +sub check { print "ok1\n" if warnings::enabled() ; print "ok2\n" if warnings::enabled("io") ; print "ok3\n" if warnings::enabled("all") ; } 1; ---FILE-- +--FILE-- no warnings; -use abc ; -abc::check() ; +use abc38 ; +abc38::check() ; EXPECT ok1 ok2 ok3 ######## -X ---FILE-- abc.pm -package abc ; +--FILE-- abc39.pm +package abc39 ; use warnings "io" ; use warnings::register ; -sub check { +sub check { print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; } 1; ---FILE-- +--FILE-- no warnings; -use abc ; -abc::check() ; +use abc39 ; +abc39::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc40.pm +package abc40 ; use warnings "io" ; use warnings::register ; -sub check { +sub check { print "ok1\n" if warnings::enabled() ; print "ok2\n" if warnings::enabled("io") ; print "ok3\n" if warnings::enabled("all") ; } 1; ---FILE-- +--FILE-- use warnings 'all'; -use abc ; -abc::check() ; +use abc40 ; +abc40::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc41.pm +package abc41 ; use warnings "io" ; use warnings::register ; -sub check { +sub check { print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; } 1; ---FILE-- -use abc ; +--FILE-- +use abc41 ; no warnings ; -abc::check() ; +abc41::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc42.pm +package abc42 ; use warnings "io" ; use warnings::register ; -sub check { +sub check { print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; warnings::warnif("my message 1") ; - warnings::warnif('abc', "my message 2") ; + warnings::warnif('abc42', "my message 2") ; warnings::warnif('io', "my message 3") ; warnings::warnif('all', "my message 4") ; } 1; ---FILE-- -use abc ; -use warnings 'abc'; +--FILE-- +use abc42 ; +use warnings 'abc42'; no warnings ; -abc::check() ; +abc42::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc43.pm +package abc43 ; use warnings "io" ; use warnings::register ; -sub check { - print "abc self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; - print "abc def" . (warnings::enabled('def') ? "" : " not") . " enabled\n" ; - print "abc all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; +sub check { + print "abc43 self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; + print "abc43 def" . (warnings::enabled('def') ? "" : " not") . " enabled\n" ; + print "abc43 all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; } 1; --FILE-- def.pm package def ; use warnings "io" ; use warnings::register ; -sub check { +sub check { print "def self" . (warnings::enabled() ? "" : " not") . " enabled\n" ; - print "def abc" . (warnings::enabled('abc') ? "" : " not") . " enabled\n" ; + print "def abc43" . (warnings::enabled('abc43') ? "" : " not") . " enabled\n" ; print "def all" . (warnings::enabled('all') ? "" : " not") . " enabled\n" ; } 1; ---FILE-- -use abc ; +--FILE-- +use abc43 ; use def ; -use warnings 'abc'; -abc::check() ; +use warnings 'abc43'; +abc43::check() ; def::check() ; -no warnings 'abc' ; +no warnings 'abc43' ; use warnings 'def' ; -abc::check() ; +abc43::check() ; def::check() ; -use warnings 'abc' ; +use warnings 'abc43' ; use warnings 'def' ; -abc::check() ; +abc43::check() ; def::check() ; -no warnings 'abc' ; +no warnings 'abc43' ; no warnings 'def' ; -abc::check() ; +abc43::check() ; def::check() ; use warnings; -abc::check() ; +abc43::check() ; def::check() ; -no warnings 'abc' ; -abc::check() ; +no warnings 'abc43' ; +abc43::check() ; def::check() ; EXPECT -abc self enabled -abc def not enabled -abc all not enabled +abc43 self enabled +abc43 def not enabled +abc43 all not enabled def self not enabled -def abc enabled +def abc43 enabled def all not enabled -abc self not enabled -abc def enabled -abc all not enabled +abc43 self not enabled +abc43 def enabled +abc43 all not enabled def self enabled -def abc not enabled +def abc43 not enabled def all not enabled -abc self enabled -abc def enabled -abc all not enabled +abc43 self enabled +abc43 def enabled +abc43 all not enabled def self enabled -def abc enabled +def abc43 enabled def all not enabled -abc self not enabled -abc def not enabled -abc all not enabled +abc43 self not enabled +abc43 def not enabled +abc43 all not enabled def self not enabled -def abc not enabled +def abc43 not enabled def all not enabled -abc self enabled -abc def enabled -abc all enabled +abc43 self enabled +abc43 def enabled +abc43 all enabled def self enabled -def abc enabled +def abc43 enabled def all enabled -abc self not enabled -abc def enabled -abc all not enabled +abc43 self not enabled +abc43 def enabled +abc43 all not enabled def self enabled -def abc not enabled +def abc43 not enabled def all not enabled ######## -w ---FILE-- abc.pm -package abc ; +--FILE-- abc44.pm +package abc44 ; no warnings ; use warnings::register ; -sub check { +sub check { print "ok1\n" if warnings::enabled() ; print "ok2\n" if warnings::enabled("io") ; print "ok3\n" if warnings::enabled("all") ; } 1; ---FILE-- -use abc ; -abc::check() ; +--FILE-- +use abc44 ; +abc44::check() ; EXPECT ok1 ok2 ok3 ######## -w ---FILE-- abc.pm -package abc ; +--FILE-- abc45.pm +package abc45 ; no warnings ; use warnings::register ; -sub check { +sub check { print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; } 1; ---FILE-- -use abc ; -use warnings 'abc'; +--FILE-- +use abc45 ; +use warnings 'abc45'; no warnings ; -abc::check() ; +abc45::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc46.pm +package abc46 ; no warnings ; use warnings::register ; -sub check { +sub check { print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; warnings::warnif("my message 1") ; - warnings::warnif('abc', "my message 2") ; + warnings::warnif('abc46', "my message 2") ; warnings::warnif('io', "my message 3") ; warnings::warnif('all', "my message 4") ; } 1; ---FILE-- -use abc ; -use warnings 'abc'; +--FILE-- +use abc46 ; +use warnings 'abc46'; no warnings ; BEGIN { $^W = 1 ; } -abc::check() ; +abc46::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm -package abc ; +--FILE-- abc47.pm +package abc47 ; no warnings ; use warnings::register ; -sub check { +sub check { print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; } 1; ---FILE-- -use abc ; -use warnings 'abc'; +--FILE-- +use abc47 ; +use warnings 'abc47'; no warnings ; $^W = 1 ; -abc::check() ; +abc47::check() ; EXPECT ok1 ok2 ok3 ######## ---FILE-- abc.pm +--FILE-- abc48.pm $| = 1; -package abc ; +package abc48 ; no warnings ; use warnings::register ; -sub check { +sub check { print "ok1\n" if warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; - print "ok4\n" if warnings::enabled("abc") ; + print "ok4\n" if warnings::enabled("abc48") ; warnings::warn("my message 1") ; warnings::warnif("my message 2") ; - warnings::warnif('abc', "my message 3") ; + warnings::warnif('abc48', "my message 3") ; warnings::warnif('io', "my message 4") ; warnings::warnif('all', "my message 5") ; } sub in2 { no warnings ; check() } sub in1 { no warnings ; in2() } 1; ---FILE-- -use abc ; -use warnings 'abc'; -abc::in1() ; +--FILE-- +use abc48 ; +use warnings 'abc48'; +abc48::in1() ; EXPECT ok1 ok2 @@ -1014,7 +1014,7 @@ my message 3 at - line 3 package def ; no warnings ; use warnings::register ; -sub check { +sub check { print "ok1\n" if warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; @@ -1028,25 +1028,25 @@ sub check { sub in2 { no warnings ; check() } sub in1 { no warnings ; in2() } 1; ---FILE-- abc.pm +--FILE-- abc49.pm $| = 1; -package abc ; +package abc49 ; use def ; use warnings 'def'; sub in1 { def::in1() ; } 1; ---FILE-- -use abc ; +--FILE-- +use abc49 ; no warnings; -abc::in1() ; +abc49::in1() ; EXPECT ok1 ok2 ok3 ok4 -my message 1 at abc.pm line 5 -my message 2 at abc.pm line 5 -my message 3 at abc.pm line 5 +my message 1 at abc49.pm line 5 +my message 2 at abc49.pm line 5 +my message 3 at abc49.pm line 5 ######## --FILE-- def.pm @@ -1057,15 +1057,15 @@ use warnings::register ; require Exporter; @ISA = qw( Exporter ) ; @EXPORT = qw( in1 ) ; -sub check { +sub check { print "ok1\n" if warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; - print "ok4\n" if warnings::enabled("abc") ; + print "ok4\n" if warnings::enabled("abc50") ; print "ok5\n" if !warnings::enabled("def") ; warnings::warn("my message 1") ; warnings::warnif("my message 2") ; - warnings::warnif('abc', "my message 3") ; + warnings::warnif('abc50', "my message 3") ; warnings::warnif('def', "my message 4") ; warnings::warnif('io', "my message 5") ; warnings::warnif('all', "my message 6") ; @@ -1073,17 +1073,17 @@ sub check { sub in2 { no warnings ; check() } sub in1 { no warnings ; in2() } 1; ---FILE-- abc.pm -package abc ; +--FILE-- abc50.pm +package abc50 ; use warnings::register ; use def ; #@ISA = qw(def) ; 1; ---FILE-- -use abc ; +--FILE-- +use abc50 ; no warnings; -use warnings 'abc'; -abc::in1() ; +use warnings 'abc50'; +abc50::in1() ; EXPECT ok2 ok3 @@ -1104,13 +1104,13 @@ sub new bless [], $class ; } -sub check -{ +sub check +{ my $self = shift ; print "ok1\n" if !warnings::enabled() ; print "ok2\n" if !warnings::enabled("io") ; print "ok3\n" if !warnings::enabled("all") ; - print "ok4\n" if warnings::enabled("abc") ; + print "ok4\n" if warnings::enabled("abc51") ; print "ok5\n" if !warnings::enabled("def") ; print "ok6\n" if warnings::enabled($self) ; @@ -1118,28 +1118,28 @@ sub check warnings::warn($self, "my message 2") ; warnings::warnif("my message 3") ; - warnings::warnif('abc', "my message 4") ; + warnings::warnif('abc51', "my message 4") ; warnings::warnif('def', "my message 5") ; warnings::warnif('io', "my message 6") ; warnings::warnif('all', "my message 7") ; warnings::warnif($self, "my message 8") ; } -sub in2 +sub in2 { - no warnings ; + no warnings ; my $self = shift ; $self->check() ; } -sub in1 -{ +sub in1 +{ no warnings ; my $self = shift ; $self->in2(); } 1; ---FILE-- abc.pm +--FILE-- abc51.pm $| = 1; -package abc ; +package abc51 ; use warnings::register ; use def ; @ISA = qw(def) ; @@ -1150,11 +1150,11 @@ sub new } 1; ---FILE-- -use abc ; +--FILE-- +use abc51 ; no warnings; -use warnings 'abc'; -$a = new abc ; +use warnings 'abc51'; +$a = new abc51 ; $a->in1() ; print "**\n"; $b = new def ; @@ -1223,7 +1223,7 @@ eval { print "ok1\n" if $@ =~ /$warn_msg/; # does it indicate the right line? -print "ok2\n" if $@ =~ /line $warn_line/; +print "ok2\n" if $@ =~ /line $warn_line/; EXPECT ok1 ok2 diff --git a/gnu/usr.bin/perl/t/lib/warnings/9uninit b/gnu/usr.bin/perl/t/lib/warnings/9uninit index e2e6ef9fecd..512bdf7df1a 100644 --- a/gnu/usr.bin/perl/t/lib/warnings/9uninit +++ b/gnu/usr.bin/perl/t/lib/warnings/9uninit @@ -282,13 +282,13 @@ print STDERR $ga[1000]; print STDERR $m1, $g1, $ga[1],$m2; print STDERR "", $ga[1],""; EXPECT -Use of uninitialized value $ga[1000] in print at - line 5. -Use of uninitialized value $ga[1000] in print at - line 6. +Use of uninitialized value in print at - line 5. +Use of uninitialized value in print at - line 6. Use of uninitialized value $m1 in print at - line 7. Use of uninitialized value $g1 in print at - line 7. Use of uninitialized value in print at - line 7. Use of uninitialized value $m2 in print at - line 7. -Use of uninitialized value $ga[1] in print at - line 8. +Use of uninitialized value in print at - line 8. ######## use warnings 'uninitialized'; my ($m1); @@ -669,6 +669,9 @@ $foo =~ s/$m1/z/; $foo =~ s//$g1/; $foo =~ s/$m1/$g1/; $foo =~ s/./$m1/e; +undef $g1; +$m1 = '$g1'; +$foo =~ s//$m1/ee; EXPECT Use of uninitialized value $_ in pattern match (m//) at - line 5. Use of uninitialized value $m1 in regexp compilation at - line 6. @@ -731,6 +734,7 @@ Use of uninitialized value $g1 in substitution (s///) at - line 39. Use of uninitialized value $m1 in regexp compilation at - line 40. Use of uninitialized value $g1 in substitution iterator at - line 40. Use of uninitialized value $m1 in substitution iterator at - line 41. +Use of uninitialized value in substitution iterator at - line 44. ######## use warnings 'uninitialized'; my ($m1); @@ -870,7 +874,6 @@ Use of uninitialized value $g2 in substr at - line 7. Use of uninitialized value $m2 in substr at - line 7. Use of uninitialized value $g1 in substr at - line 7. Use of uninitialized value $m1 in substr at - line 7. -Use of uninitialized value $m1 in substr at - line 7. Use of uninitialized value $g1 in substr at - line 8. Use of uninitialized value $m1 in substr at - line 8. Use of uninitialized value in scalar assignment at - line 8. @@ -1060,8 +1063,6 @@ reset $m1; reset $g1; EXPECT Use of uninitialized value $m1 in subroutine dereference at - line 5. -Use of uninitialized value $m1 in subroutine dereference at - line 5. -Use of uninitialized value $g1 in subroutine dereference at - line 6. Use of uninitialized value $g1 in subroutine dereference at - line 6. Use of uninitialized value $m1 in splice at - line 9. Use of uninitialized value $g1 in splice at - line 9. @@ -1132,7 +1133,6 @@ eval { my $x; sysread $m1, $x, $g1 }; eval { my $x; sysread $m1, $x, $g1, $g2 }; EXPECT Use of uninitialized value $m1 in tie at - line 5. -Use of uninitialized value $m1 in tie at - line 5. Use of uninitialized value $m1 in ref-to-glob cast at - line 7. Use of uninitialized value $g1 in read at - line 7. Use of uninitialized value $m1 in ref-to-glob cast at - line 8. @@ -1161,15 +1161,15 @@ Use of uninitialized value $m2 in printf at - line 6. Use of uninitialized value $g1 in printf at - line 6. Use of uninitialized value $g2 in printf at - line 6. 0000 -Use of uninitialized value $ga[1000] in printf at - line 7. -Use of uninitialized value $ga[1000] in printf at - line 8. +Use of uninitialized value in printf at - line 7. +Use of uninitialized value in printf at - line 8. FOO1: Use of uninitialized value $m1 in printf at - line 9. Use of uninitialized value $g1 in printf at - line 9. Use of uninitialized value in printf at - line 9. Use of uninitialized value $m2 in printf at - line 9. FOO2: -Use of uninitialized value $ga[1] in printf at - line 10. +Use of uninitialized value in printf at - line 10. FOO3:XY ######## use warnings 'uninitialized'; @@ -1281,7 +1281,6 @@ Use of uninitialized value $m1 in -f at - line 27. Use of uninitialized value $m1 in -d at - line 28. Use of uninitialized value $m1 in -p at - line 29. Use of uninitialized value $m1 in -l at - line 30. -Use of uninitialized value $m1 in -l at - line 30. Use of uninitialized value $m1 in -u at - line 31. Use of uninitialized value $m1 in -g at - line 32. Use of uninitialized value $m1 in -t at - line 34. @@ -1299,13 +1298,15 @@ Use of uninitialized value $m1 in localtime at - line 5. Use of uninitialized value $g1 in gmtime at - line 6. ######## use warnings 'uninitialized'; -my ($m1, $v); +my ($m1, $m2, $v); $v = eval; $v = eval $m1; +$m2 = q($m1); $v = 1 + eval $m2; EXPECT Use of uninitialized value $_ in eval "string" at - line 4. Use of uninitialized value $m1 in eval "string" at - line 5. +Use of uninitialized value in addition (+) at - line 6. ######## use warnings 'uninitialized'; my ($m1); @@ -1313,3 +1314,535 @@ my ($m1); exit $m1; EXPECT Use of uninitialized value $m1 in exit at - line 4. +######## +use warnings 'uninitialized'; +my $undef; + +if ($undef == 3) { +} elsif ($undef == 0) { +} +EXPECT +Use of uninitialized value $undef in numeric eq (==) at - line 4. +Use of uninitialized value $undef in numeric eq (==) at - line 5. +######## +# TODO long standing bug - conditions of while loops +use warnings; + +my $c; +my $d = 1; +while ($c == 0 && $d) { + # a + # few + # blank + # lines + undef $d; +} +EXPECT +Use of uninitialized value $c in numeric eq (==) at - line 5. +Use of uninitialized value $c in numeric eq (==) at - line 5. +######## +# TODO long standing bug - conditions of until loops +use warnings; + +my $c; +my $d; +until ($c == 1) { + # a + # few + # blank + # lines + $c = 1 if ++$d == 2; +} +EXPECT +Use of uninitialized value $c in numeric eq (==) at - line 5. +Use of uninitialized value $c in numeric eq (==) at - line 5. +######## +# TODO long standing bug - conditions of for loops +use warnings; + +my $c; +my $d; +for ($d = 1; $c == 0 && $d; ) { + # a + # few + # blank + # lines + undef $d; +} + +my $e; +for ($d = 2; $d > 0; $e = !($c == 0)) { + # a + # few + # blank + # lines + --$d; +} +EXPECT +Use of uninitialized value $c in numeric eq (==) at - line 5. +Use of uninitialized value $c in numeric eq (==) at - line 5. +Use of uninitialized value $c in numeric eq (==) at - line 14. +Use of uninitialized value $c in numeric eq (==) at - line 14. +######## +# TODO long standing bug - more general variant of the above problem +use warnings; +my $undef; + +my $a = $undef + 1; +my $b + = $undef + + 1; +EXPECT +Use of uninitialized value $undef in addition (+) at - line 4. +Use of uninitialized value $undef in addition (+) at - line 7. +######## +use warnings 'uninitialized'; +# +# ops that can return undef for defined args +# split into separate tests to diagnose the cause of daily build smoke +# +# *** `` not tested: Windows produces an error on STDERR +# *** ditto qx() +# *** pipe() not tested +# *** ioctl not tested +# *** socket not tested +# *** socketpair not tested +# *** bind not tested +# *** connect not tested +# *** listen not tested +# *** shutdown not tested +# *** setsockopt not tested +# *** getpeername not tested +# *** readdir not tested +# *** telldir not tested +# *** seekdir not tested +# *** rewinddir not tested +# *** closedir not tested +# *** gmtime not tested +# *** alarm not tested +# *** semget not tested +# *** getlogin not tested +EXPECT +######## +use warnings 'uninitialized'; +if ($^O eq 'MSWin32') { + print <<'EOM'; +SKIPPED +# `` produces an error on STDERR on Win32 +EOM + exit; +} +my $nocmd = '/no/such/command'; +my $v; +$v = 1 + `$nocmd`; +EXPECT +Use of uninitialized value in addition (+) at - line 11. +######## +use warnings 'uninitialized'; +if ($^O eq 'MSWin32') { + print <<'EOM'; +SKIPPED +# qx produces an error on STDERR on Win32 +EOM + exit; +} +my $nocmd = '/no/such/command'; +my $v; +$v = 1 + qx($nocmd); +EXPECT +Use of uninitialized value in addition (+) at - line 11. +######## +use warnings 'uninitialized'; +my $nan = "NaN"; +if ($nan == $nan) { + print <<'EOM'; +SKIPPED +# NaN not supported here. +EOM + exit; +} +my $v; +$v = 1 + ($nan <=> 1); +EXPECT +Use of uninitialized value in addition (+) at - line 11. +######## +use warnings 'uninitialized'; +if ($^O eq 'MSWin32') { + print <<'EOM'; +SKIPPED +# -k produces no warning on Win32 +EOM + exit; +} +my $nofile = '/no/such/file'; +my $v; +$v = 1 + -k $nofile; +EXPECT +Use of uninitialized value in addition (+) at - line 11. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +my $f = ""; +$v = 1 + open($f, $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 5. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + fileno($nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + binmode($nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + tied($nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + getc($nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + sysread($nofile, my $buf,1); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + eval { send($nofile, $buf,0) }; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +my $fh = ""; +$v = 1 + eval { accept($fh, $nofile) }; +EXPECT +Use of uninitialized value in addition (+) at - line 5. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-r $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-w $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-x $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-o $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-R $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-W $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-X $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-O $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-e $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-z $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-s $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-f $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-d $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-l $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-p $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-S $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-b $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-c $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-t $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-u $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-g $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-T $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-B $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-M $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-A $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + (-C $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + eval { readlink $nofile }; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + opendir($f, $nofile); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + undef; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +my $x = 1; $v = 1 + undef($x); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $emptys = ""; +$v = 1 + substr($emptys,2,1); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my @emptya; +$v = 1 + each @emptya; # *** Not supported under 5.10.x +EXPECT +Type of arg 1 to each must be hash (not private array) at - line 4, near "@emptya;" +Execution of - aborted due to compilation errors. +######## +use warnings 'uninitialized'; +my $v; +my %emptyh; +$v = 1 + each %emptyh; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my @emptya; +$v = 1 + sort @emptya; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $zero = 0; $v = 1 + caller($zero); +EXPECT +Use of uninitialized value in addition (+) at - line 3. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +$v = 1 + do $nofile; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $fn = sub {}; +$v = 1 + prototype $fn; +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $fn = sub {}; +$v = 1 + (1 ~~ $fn); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $f = ""; +$v = 1 + (print STDIN $f); # print to STDIN returns undef +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $f = ""; +$v = 1 + (printf STDIN "%s", $f); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $f = ""; +{ use feature 'say'; $v = 1 + (say STDIN "%s", $f); } +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $v; +my $f = ""; +$v = 1 + (unpack("",$f)); +EXPECT +Use of uninitialized value in addition (+) at - line 4. +######## +use warnings 'uninitialized'; +my $nofile = '/no/such/file'; +my $v; +my $f = ""; +$v = 1 + sysopen($f, $nofile, 0); +EXPECT +Use of uninitialized value in addition (+) at - line 5. +######## +use warnings 'uninitialized'; +my $v; +{ my $x = -1; $v = 1 + sysseek(DATA, $x, 0); } +__END__ +EXPECT +Use of uninitialized value in addition (+) at - line 3. diff --git a/gnu/usr.bin/perl/t/lib/warnings/op b/gnu/usr.bin/perl/t/lib/warnings/op index a7445906e63..f0a6e62a5e9 100644 --- a/gnu/usr.bin/perl/t/lib/warnings/op +++ b/gnu/usr.bin/perl/t/lib/warnings/op @@ -211,6 +211,8 @@ eval { getgrgid 1 }; # OP_GGRGID eval { getpwnam 1 }; # OP_GPWNAM eval { getpwuid 1 }; # OP_GPWUID prototype "foo"; # OP_PROTOTYPE +$a ~~ $b; # OP_SMARTMATCH +$a <=> $b; # OP_NCMP EXPECT Useless use of repeat (x) in void context at - line 3. Useless use of wantarray in void context at - line 5. @@ -250,6 +252,8 @@ Useless use of getgrgid in void context at - line 51. Useless use of getpwnam in void context at - line 52. Useless use of getpwuid in void context at - line 53. Useless use of subroutine prototype in void context at - line 54. +Useless use of smart match in void context at - line 55. +Useless use of numeric comparison (<=>) in void context at - line 56. ######## # op.c use warnings 'void' ; close STDIN ; diff --git a/gnu/usr.bin/perl/t/lib/warnings/pp_ctl b/gnu/usr.bin/perl/t/lib/warnings/pp_ctl index 923d54cf109..afaf0a78dbc 100644 --- a/gnu/usr.bin/perl/t/lib/warnings/pp_ctl +++ b/gnu/usr.bin/perl/t/lib/warnings/pp_ctl @@ -222,18 +222,6 @@ EXPECT Use of uninitialized value $foo in print at (eval 1) line 1. ######## # pp_ctl.c -use warnings 'portable'; -eval 'use 5.6.1'; -EXPECT -v-string in use/require non-portable at (eval 1) line 2. -######## -# pp_ctl.c -use warnings 'portable'; -eval 'use v5.6.1'; -EXPECT -v-string in use/require non-portable at (eval 1) line 2. -######## -# pp_ctl.c use warnings; { no warnings; @@ -245,15 +233,3 @@ EXPECT use warnings; eval 'use 5.006; use 5.10.0'; EXPECT -######## -# pp_ctl.c -use warnings; -eval '{use 5.006;} use 5.10.0'; -EXPECT -v-string in use/require non-portable at (eval 1) line 2. -######## -# pp_ctl.c -use warnings; -eval 'use vars; use 5.10.0'; -EXPECT -v-string in use/require non-portable at (eval 1) line 2. |