diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-09-11 06:23:39 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-09-11 06:23:39 +0000 |
commit | c9b8d07a63ebe36e22cf35e83f7d6beac85bca88 (patch) | |
tree | f3c970b6a70b4f6cbfad681762de8974b174cf15 /t | |
parent | e9c5ca9205c44a223c1bf0632cde03b38166cbc2 (diff) | |
parent | c079d275c4f9c514ec0de3de1aef066d6f4595aa (diff) | |
download | perl-c9b8d07a63ebe36e22cf35e83f7d6beac85bca88.tar.gz |
Part Integrate mainline
p4raw-id: //depot/perlio@11995
Diffstat (limited to 't')
34 files changed, 780 insertions, 530 deletions
@@ -226,7 +226,7 @@ EOT $ok = 1; } else { - if (/^(not )?ok (\d+)(\s*#.*)?/ && + if (/^(not )?ok (\d+)[^#]*(\s*#.*)?/ && $2 == $next) { my($not, $num, $extra) = ($1, $2, $3); diff --git a/t/comp/proto.t b/t/comp/proto.t index ae0f9abfcb..a60f36f75b 100755 --- a/t/comp/proto.t +++ b/t/comp/proto.t @@ -16,7 +16,7 @@ BEGIN { use strict; -print "1..125\n"; +print "1..130\n"; my $i = 1; @@ -506,3 +506,24 @@ print "ok ", $i++, "\n"; # recv takes a scalar reference for its second argument print "not " unless prototype "CORE::recv" eq '*\\$$$'; print "ok ", $i++, "\n"; + +{ + my $myvar; + my @myarray; + my %myhash; + sub mysub { print "not calling mysub I hope\n" } + local *myglob; + + sub myref (\[$@%&*]) { print "# $_[0]\n"; return "$_[0]" } + + print "not " unless myref($myvar) =~ /^SCALAR\(/; + print "ok ", $i++, "\n"; + print "not " unless myref(@myarray) =~ /^ARRAY\(/; + print "ok ", $i++, "\n"; + print "not " unless myref(%myhash) =~ /^HASH\(/; + print "ok ", $i++, "\n"; + print "not " unless myref(&mysub) =~ /^CODE\(/; + print "ok ", $i++, "\n"; + print "not " unless myref(*myglob) =~ /^GLOB\(/; + print "ok ", $i++, "\n"; +} diff --git a/t/lib/1_compile.t b/t/lib/1_compile.t index 66ebcbbcd4..10fe381c45 100644 --- a/t/lib/1_compile.t +++ b/t/lib/1_compile.t @@ -10,6 +10,7 @@ use warnings; use Config; my %Core_Modules; +my %Test; unless (open(MANIFEST, "MANIFEST")) { die "$0: failed to open 'MANIFEST': $!\n"; @@ -20,10 +21,20 @@ sub add_by_name { } while (<MANIFEST>) { - next unless m!^lib/(\S+?)\.pm!; - my $module = $1; - $module =~ s!/!::!g; - add_by_name($module); + if (m!^(lib)/(\S+?)\.pm\s!) { + # Collecting modules names from under ext/ would be + # rather painful since the mapping from filenames + # to module names is not 100%. + my ($dir, $module) = ($1, $2); + $module =~ s!/!::!g; + add_by_name($module); + } elsif (m!^(lib|ext)/(\S+?)(?:\.t|/test.pl)\s!) { + my ($dir, $test) = ($1, $2); + $test =~ s!(\w+)/\1$!$1! if $dir eq 'ext'; + $test =~ s!/t/[^/]+$!!; + $test =~ s!/!::!g; + $Test{$test}++; + } } close(MANIFEST); @@ -83,8 +94,12 @@ delete_by_prefix('unicode::'); # Delete all modules which have their own tests. # This makes this test a lot faster. +foreach my $mod (sort keys %Test) { + delete_by_name($mod); +} foreach my $mod (<DATA>) { chomp $mod; + print "### $mod has a test but is in DATA\n" if exists $Test{$mod}; delete_by_name($mod); } @@ -115,67 +130,23 @@ sub compile_module { # Add here modules that have their own test scripts and therefore # need not be test-compiled by 1_compile.t. __DATA__ -AnyDBM_File -Attribute::Handlers -AutoLoader -B -B::Debug -B::Deparse B::ShowLex -B::Stash -Benchmark -CGI +CGI::Apache +CGI::Carp +CGI::Cookie +CGI::Form CGI::Pretty +CGI::Switch CGI::Util -Carp Carp::Heavy -Class::ISA -Class::Struct -CPAN -Cwd -DB_File -Data::Dumper Devel::DProf -Devel::Peek -Devel::SelfStubber -Digest -Digest::MD5 -DirHandle Dumpvalue -Encode -English -Env -Errno -Exporter Exporter::Heavy ExtUtils::Constant ExtUtils::MakeMaker -Fatal -Fcntl -File::Basename -File::CheckTree -File::Compare -File::Copy -File::DosGlob -File::Find -File::Glob -File::Path -File::Spec -File::Spec::Functions -File::Temp -File::stat -FileCache -FileHandle -Filter::Simple Filter::Util::Call -FindBin GDBM_File -Getopt::Long -Getopt::Std -I18N::Langinfo -I18N::LangTags I18N::LangTags::List -I18N::Collate IO::Dir IO::File IO::Handle @@ -186,23 +157,13 @@ IO::Select IO::Socket IO::Socket::INET IO::Socket::UNIX -IPC::Open2 -IPC::Open3 -IPC::SysV -List::Util Locale::Constants Locale::Country Locale::Currency Locale::Language -Locale::Maketext -MIME::Base64 MIME::QuotedPrint Math::BigFloat -Math::BigInt Math::BigInt::Calc -Math::Complex -Math::Trig -Memoize Memoize::AnyDBM_File Memoize::Expire Memoize::ExpireFile @@ -211,15 +172,7 @@ Memoize::NDBM_File Memoize::SDBM_File Memoize::Storable NDBM_File -NEXT -Net::hostent -Net::netent -Net::protoent -Net::servent ODBM_File -Opcode -PerlIO -POSIX Pod::Checker Pod::Find Pod::Text @@ -227,59 +180,20 @@ Pod::Usage SDBM_File Safe Scalar::Util -Search::Dict -SelectSaver -SelfLoader -Socket -Storable -Switch -Symbol -Sys::Hostname Sys::Syslog -Term::ANSIColor -Test -Test::Harness Test::More -Test::Simple Test::ParseWords -Text::Abbrev -Text::Balanced -Text::ParseWords -Text::Soundex Text::Tabs Text::Wrap Thread Tie::Array Tie::Handle Tie::Hash -Tie::RefHash Tie::Scalar -Tie::SubstrHash -Time::HiRes -Time::Local -Time::gmtime -Time::localtime Time::tm -UnicodeCD UNIVERSAL -User::grent -User::pwent -XS::Typemap attributes -attrs -autouse base bytes -charnames -constant -diagnostics -fields -integer -locale ops -overload -strict -subs -utf8 -warnings warnings::register diff --git a/t/lib/MyFilter.pm b/t/lib/FilterTest.pm index e74b10ab02..4e997726d3 100644 --- a/t/lib/MyFilter.pm +++ b/t/lib/FilterTest.pm @@ -1,4 +1,4 @@ -package MyFilter; +package FilterTest; BEGIN { chdir('t') if -d 't'; diff --git a/t/lib/Test/Simple/Catch.pm b/t/lib/Test/Simple/Catch.pm index 2f8c887d49..3460a64dcb 100644 --- a/t/lib/Test/Simple/Catch.pm +++ b/t/lib/Test/Simple/Catch.pm @@ -1,8 +1,8 @@ # For testing Test::Simple; -package Catch; +package Test::Simple::Catch; -my $out = tie *Test::Simple::TESTOUT, 'Catch'; -my $err = tie *Test::Simple::TESTERR, 'Catch'; +my $out = tie *Test::Simple::TESTOUT, __PACKAGE__; +my $err = tie *Test::Simple::TESTERR, __PACKAGE__; # We have to use them to shut up a "used only once" warning. () = (*Test::Simple::TESTOUT, *Test::Simple::TESTERR); diff --git a/t/lib/Test/More/Catch.pm b/t/lib/Test/Simple/Catch/More.pm index aed94682d4..f4dee3f3ad 100644 --- a/t/lib/Test/More/Catch.pm +++ b/t/lib/Test/Simple/Catch/More.pm @@ -1,10 +1,10 @@ # For testing Test::More; -package Catch; +package Test::Simple::Catch::More; -my $out = tie *Test::Simple::TESTOUT, 'Catch'; -tie *Test::More::TESTOUT, 'Catch', $out; -my $err = tie *Test::More::TESTERR, 'Catch'; -tie *Test::Simple::TESTERR, 'Catch', $err; +my $out = tie *Test::Simple::TESTOUT, __PACKAGE__; +tie *Test::More::TESTOUT, __PACKAGE__, $out; +my $err = tie *Test::More::TESTERR, __PACKAGE__; +tie *Test::Simple::TESTERR, __PACKAGE__, $err; # We have to use them to shut up a "used only once" warning. () = (*Test::More::TESTOUT, *Test::More::TESTERR); diff --git a/t/lib/Test/Simple/sample_tests/death.plx b/t/lib/Test/Simple/sample_tests/death.plx index 8796eb2451..ef4ba8c188 100644 --- a/t/lib/Test/Simple/sample_tests/death.plx +++ b/t/lib/Test/Simple/sample_tests/death.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); close STDERR; diff --git a/t/lib/Test/Simple/sample_tests/death_in_eval.plx b/t/lib/Test/Simple/sample_tests/death_in_eval.plx index 969dbb009a..269bffa802 100644 --- a/t/lib/Test/Simple/sample_tests/death_in_eval.plx +++ b/t/lib/Test/Simple/sample_tests/death_in_eval.plx @@ -1,9 +1,9 @@ require Test::Simple; use Carp; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/Test/Simple/sample_tests/extras.plx b/t/lib/Test/Simple/sample_tests/extras.plx index ed2d6abbbf..c9c89520aa 100644 --- a/t/lib/Test/Simple/sample_tests/extras.plx +++ b/t/lib/Test/Simple/sample_tests/extras.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/Test/Simple/sample_tests/five_fail.plx b/t/lib/Test/Simple/sample_tests/five_fail.plx index c95e4100d5..d33b84519b 100644 --- a/t/lib/Test/Simple/sample_tests/five_fail.plx +++ b/t/lib/Test/Simple/sample_tests/five_fail.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/Test/Simple/sample_tests/last_minute_death.plx b/t/lib/Test/Simple/sample_tests/last_minute_death.plx index e1df5b1970..ef86a63c51 100644 --- a/t/lib/Test/Simple/sample_tests/last_minute_death.plx +++ b/t/lib/Test/Simple/sample_tests/last_minute_death.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); close STDERR; diff --git a/t/lib/Test/Simple/sample_tests/one_fail.plx b/t/lib/Test/Simple/sample_tests/one_fail.plx index 1762d65df0..99c720250d 100644 --- a/t/lib/Test/Simple/sample_tests/one_fail.plx +++ b/t/lib/Test/Simple/sample_tests/one_fail.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/Test/Simple/sample_tests/success.plx b/t/lib/Test/Simple/sample_tests/success.plx index eb40a2d7d0..585d6c3d79 100644 --- a/t/lib/Test/Simple/sample_tests/success.plx +++ b/t/lib/Test/Simple/sample_tests/success.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/Test/Simple/sample_tests/too_few.plx b/t/lib/Test/Simple/sample_tests/too_few.plx index 36acac94f6..95af8e903b 100644 --- a/t/lib/Test/Simple/sample_tests/too_few.plx +++ b/t/lib/Test/Simple/sample_tests/too_few.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/Test/Simple/sample_tests/two_fail.plx b/t/lib/Test/Simple/sample_tests/two_fail.plx index 5ddb912dec..e3d92296af 100644 --- a/t/lib/Test/Simple/sample_tests/two_fail.plx +++ b/t/lib/Test/Simple/sample_tests/two_fail.plx @@ -1,8 +1,8 @@ require Test::Simple; -push @INC, 't', '.'; -require Catch; -my($out, $err) = Catch::caught(); +push @INC, 't/lib'; +require Test::Simple::Catch; +my($out, $err) = Test::Simple::Catch::caught(); Test::Simple->import(tests => 5); diff --git a/t/lib/sample-tests/header_at_end_fail b/t/lib/sample-tests/header_at_end_fail new file mode 100644 index 0000000000..9d1667ab19 --- /dev/null +++ b/t/lib/sample-tests/header_at_end_fail @@ -0,0 +1,11 @@ +print <<DUMMY_TEST; +# comments +ok 1 +not ok 2 +ok 3 +ok 4 +# comment +1..4 +# more ignored stuff +# and yet more +DUMMY_TEST diff --git a/t/lib/sample-tests/skip_no_msg b/t/lib/sample-tests/skip_no_msg new file mode 100644 index 0000000000..51d1ed6b43 --- /dev/null +++ b/t/lib/sample-tests/skip_no_msg @@ -0,0 +1,4 @@ +print <<DUMMY; +1..1 +ok 1 # Skip +DUMMY diff --git a/t/lib/sample-tests/todo_inline b/t/lib/sample-tests/todo_inline new file mode 100644 index 0000000000..5b96d68caf --- /dev/null +++ b/t/lib/sample-tests/todo_inline @@ -0,0 +1,6 @@ +print <<DUMMY_TEST; +1..3 +not ok 1 - Foo # TODO Just testing the todo interface. +ok 2 - Unexpected success # TODO Just testing the todo interface. +ok 3 - This is not todo +DUMMY_TEST diff --git a/t/lib/warnings/regcomp b/t/lib/warnings/regcomp index ceca4410d6..b9cbecca9a 100644 --- a/t/lib/warnings/regcomp +++ b/t/lib/warnings/regcomp @@ -47,15 +47,6 @@ $a =~ /(?=a)*/ ; EXPECT (?=a)* matches null string many times in regex; marked by <-- HERE in m/(?=a)* <-- HERE / at - line 4. ######## -# regcomp.c [S_study_chunk] -use warnings 'regexp' ; -$_ = "" ; -/(?=a)?/; -no warnings 'regexp' ; -/(?=a)?/; -EXPECT -Quantifier unexpected on zero-length expression in regex; marked by <-- HERE in m/(?=a)? <-- HERE / at - line 4. -######## # regcomp.c [S_regatom] $x = '\m' ; use warnings 'regexp' ; diff --git a/t/op/64bitint.t b/t/op/64bitint.t index 5ea1f2dbdc..494f9fd14f 100644 --- a/t/op/64bitint.t +++ b/t/op/64bitint.t @@ -17,7 +17,7 @@ BEGIN { use warnings; no warnings qw(overflow portable); -print "1..63\n"; +print "1..67\n"; # as 6 * 6 = 36, the last digit of 6**n will always be six. Hence the last # digit of 16**n will always be six. Hence 16**n - 1 will always end in 5. @@ -379,4 +379,39 @@ if ($q == -9223372036854775806) { print "not ok 63 # 0x8000000000000000 % -9223372036854775807 => $q\n"; } +{ + use integer; + $q = hex "0x123456789abcdef0"; + if ($q == 0x123456789abcdef0 and $q != 0x123456789abcdef1) { + print "ok 64\n"; + } else { + printf "not ok 64 # hex \"0x123456789abcdef0\" = $q (%X)\n", $q; + print "# Should not be floating point\n" if $q =~ tr/e.//; + } + + $q = oct "0x123456789abcdef0"; + if ($q == 0x123456789abcdef0 and $q != 0x123456789abcdef1) { + print "ok 65\n"; + } else { + printf "not ok 65 # oct \"0x123456789abcdef0\" = $q (%X)\n", $q; + print "# Should not be floating point\n" if $q =~ tr/e.//; + } + + $q = oct "765432176543217654321"; + if ($q == 0765432176543217654321 and $q != 0765432176543217654322) { + print "ok 66\n"; + } else { + printf "not ok 66 # oct \"765432176543217654321\" = $q (%o)\n", $q; + print "# Should not be floating point\n" if $q =~ tr/e.//; + } + + $q = oct "0b0101010101010101010101010101010101010101010101010101010101010101"; + if ($q == 0x5555555555555555 and $q != 0x5555555555555556) { + print "ok 67\n"; + } else { + printf "not ok 67 # oct \"0b0101010101010101010101010101010101010101010101010101010101010101\" = $q (%b)\n", $q; + print "# Should not be floating point\n" if $q =~ tr/e.//; + } +} + # eof diff --git a/t/op/crypt.t b/t/op/crypt.t new file mode 100644 index 0000000000..26eb06a580 --- /dev/null +++ b/t/op/crypt.t @@ -0,0 +1,15 @@ +use Test::More tests => 2; + +# Can't assume too much about the string returned by crypt(), +# and about how many bytes of the encrypted (really, hashed) +# string matter. +# +# HISTORICALLY the results started with the first two bytes of the salt, +# followed by 11 bytes from the set [./0-9A-Za-z], and only the first +# eight characters mattered, but those are probably no more safe +# bets, given alternative encryption/hashing schemes like MD5, +# C2 (or higher) security schemes, and non-UNIX platforms. + +ok(substr(crypt("ab", "cd"), 2) ne substr(crypt("ab", "ce"), 2), "salt"); + +ok(crypt("HI", "HO") eq crypt(v4040.4041, "HO"), "Unicode"); diff --git a/t/op/inccode.t b/t/op/inccode.t index 85a235d6de..95ee7c0094 100644 --- a/t/op/inccode.t +++ b/t/op/inccode.t @@ -7,27 +7,34 @@ BEGIN { @INC = '../lib'; } -use Config; +use File::Spec; +use Test::More tests => 30; + +my @tempfiles = (); + +sub get_temp_fh { + my $f = "DummyModule0000"; + 1 while -e ++$f; + push @tempfiles, $f; + open my $fh, ">$f" or die "Can't create $f: $!"; + print $fh "package ".substr($_[0],0,-3)."; 1;"; + close $fh; + open $fh, $f or die "Can't open $f: $!"; + return $fh; +} -BEGIN { - require Test::More; +END { 1 while unlink @tempfiles } - # This test relies on perlio, but the feature being tested does not. - # The dependency should eventually be purged and use something like - # Tie::Handle instead. - if( $Config{useperlio} ) { - Test::More->import(tests => 21); - } - else { - Test::More->import('skip_all'); - } +sub get_addr { + my $str = shift; + $str =~ /(0x[0-9a-f]+)/i; + return $1; } sub fooinc { my ($self, $filename) = @_; if (substr($filename,0,3) eq 'Foo') { - open my $fh, '<', \("package ".substr($filename,0,-3)."; 1;"); - return $fh; + return get_temp_fh($filename); } else { return undef; @@ -40,12 +47,18 @@ ok( !eval { require Bar; 1 }, 'Trying non-magic package' ); ok( eval { require Foo; 1 }, 'require() magic via code ref' ); ok( exists $INC{'Foo.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Foo.pm'}), get_addr(\&fooinc), + ' key is correct in %INC' ); ok( eval "use Foo1; 1;", 'use()' ); ok( exists $INC{'Foo1.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Foo1.pm'}), get_addr(\&fooinc), + ' key is correct in %INC' ); ok( eval { do 'Foo2.pl'; 1 }, 'do()' ); ok( exists $INC{'Foo2.pl'}, ' %INC sees it' ); +is( get_addr($INC{'Foo2.pl'}), get_addr(\&fooinc), + ' key is correct in %INC' ); pop @INC; @@ -53,58 +66,72 @@ pop @INC; sub fooinc2 { my ($self, $filename) = @_; if (substr($filename, 0, length($self->[1])) eq $self->[1]) { - open my $fh, '<', \("package ".substr($filename,0,-3)."; 1;"); - return $fh; + return get_temp_fh($filename); } else { return undef; } } -push @INC, [ \&fooinc2, 'Bar' ]; +my $arrayref = [ \&fooinc2, 'Bar' ]; +push @INC, $arrayref; ok( eval { require Foo; 1; }, 'Originally loaded packages preserved' ); ok( !eval { require Foo3; 1; }, 'Original magic INC purged' ); ok( eval { require Bar; 1 }, 'require() magic via array ref' ); ok( exists $INC{'Bar.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Bar.pm'}), get_addr($arrayref), + ' key is correct in %INC' ); ok( eval "use Bar1; 1;", 'use()' ); ok( exists $INC{'Bar1.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Bar1.pm'}), get_addr($arrayref), + ' key is correct in %INC' ); ok( eval { do 'Bar2.pl'; 1 }, 'do()' ); ok( exists $INC{'Bar2.pl'}, ' %INC sees it' ); +is( get_addr($INC{'Bar2.pl'}), get_addr($arrayref), + ' key is correct in %INC' ); pop @INC; sub FooLoader::INC { my ($self, $filename) = @_; if (substr($filename,0,4) eq 'Quux') { - open my $fh, '<', \("package ".substr($filename,0,-3)."; 1;"); - return $fh; + return get_temp_fh($filename); } else { return undef; } } -push @INC, bless( {}, 'FooLoader' ); +my $href = bless( {}, 'FooLoader' ); +push @INC, $href; ok( eval { require Quux; 1 }, 'require() magic via hash object' ); ok( exists $INC{'Quux.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Quux.pm'}), get_addr($href), + ' key is correct in %INC' ); pop @INC; -push @INC, bless( [], 'FooLoader' ); +my $aref = bless( [], 'FooLoader' ); +push @INC, $aref; ok( eval { require Quux1; 1 }, 'require() magic via array object' ); ok( exists $INC{'Quux1.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Quux1.pm'}), get_addr($aref), + ' key is correct in %INC' ); pop @INC; -push @INC, bless( \(my $x = 1), 'FooLoader' ); +my $sref = bless( \(my $x = 1), 'FooLoader' ); +push @INC, $sref; ok( eval { require Quux2; 1 }, 'require() magic via scalar object' ); ok( exists $INC{'Quux2.pm'}, ' %INC sees it' ); +is( get_addr($INC{'Quux2.pm'}), get_addr($sref), + ' key is correct in %INC' ); pop @INC; diff --git a/t/op/lfs.t b/t/op/lfs.t index 2652555281..8be24f4d82 100644 --- a/t/op/lfs.t +++ b/t/op/lfs.t @@ -1,6 +1,6 @@ # NOTE: this file tests how large files (>2GB) work with perlio (stdio/sfio). # sysopen(), sysseek(), syswrite(), sysread() are tested in t/lib/syslfs.t. -# If you modify/add tests here, remember to update also t/lib/syslfs.t. +# If you modify/add tests here, remember to update also ext/Fcntl/t/syslfs.t. BEGIN { chdir 't' if -d 't'; diff --git a/t/op/oct.t b/t/op/oct.t index fe155d3a2d..06bcf3e402 100755 --- a/t/op/oct.t +++ b/t/op/oct.t @@ -1,56 +1,89 @@ #!./perl -print "1..50\n"; - -print +(oct('0b1_0101') == 0b101_01) ? "ok" : "not ok", " 1\n"; -print +(oct('0b10_101') == 0_2_5) ? "ok" : "not ok", " 2\n"; -print +(oct('0b101_01') == 2_1) ? "ok" : "not ok", " 3\n"; -print +(oct('0b1010_1') == 0x1_5) ? "ok" : "not ok", " 4\n"; - -print +(oct('b1_0101') == 0b10101) ? "ok" : "not ok", " 5\n"; -print +(oct('b10_101') == 025) ? "ok" : "not ok", " 6\n"; -print +(oct('b101_01') == 21) ? "ok" : "not ok", " 7\n"; -print +(oct('b1010_1') == 0x15) ? "ok" : "not ok", " 8\n"; - -print +(oct('01_234') == 0b10_1001_1100) ? "ok" : "not ok", " 9\n"; -print +(oct('012_34') == 01234) ? "ok" : "not ok", " 10\n"; -print +(oct('0123_4') == 668) ? "ok" : "not ok", " 11\n"; -print +(oct('01234') == 0x29c) ? "ok" : "not ok", " 12\n"; - -print +(oct('0x1_234') == 0b10010_00110100) ? "ok" : "not ok", " 13\n"; -print +(oct('0x12_34') == 01_1064) ? "ok" : "not ok", " 14\n"; -print +(oct('0x123_4') == 4660) ? "ok" : "not ok", " 15\n"; -print +(oct('0x1234') == 0x12_34) ? "ok" : "not ok", " 16\n"; - -print +(oct('x1_234') == 0b100100011010_0) ? "ok" : "not ok", " 17\n"; -print +(oct('x12_34') == 0_11064) ? "ok" : "not ok", " 18\n"; -print +(oct('x123_4') == 4660) ? "ok" : "not ok", " 19\n"; -print +(oct('x1234') == 0x_1234) ? "ok" : "not ok", " 20\n"; - -print +(hex('01_234') == 0b_1001000110100) ? "ok" : "not ok", " 21\n"; -print +(hex('012_34') == 011064) ? "ok" : "not ok", " 22\n"; -print +(hex('0123_4') == 4660) ? "ok" : "not ok", " 23\n"; -print +(hex('01234_') == 0x1234) ? "ok" : "not ok", " 24\n"; - -print +(hex('0x_1234') == 0b1001000110100) ? "ok" : "not ok", " 25\n"; -print +(hex('0x1_234') == 011064) ? "ok" : "not ok", " 26\n"; -print +(hex('0x12_34') == 4660) ? "ok" : "not ok", " 27\n"; -print +(hex('0x1234_') == 0x1234) ? "ok" : "not ok", " 28\n"; - -print +(hex('x_1234') == 0b1001000110100) ? "ok" : "not ok", " 29\n"; -print +(hex('x12_34') == 011064) ? "ok" : "not ok", " 30\n"; -print +(hex('x123_4') == 4660) ? "ok" : "not ok", " 31\n"; -print +(hex('x1234_') == 0x1234) ? "ok" : "not ok", " 32\n"; - -print +(oct('0b1111_1111_1111_1111_1111_1111_1111_1111') == 4294967295) ? - "ok" : "not ok", " 33\n"; -print +(oct('037_777_777_777') == 4294967295) ? - "ok" : "not ok", " 34\n"; -print +(oct('0xffff_ffff') == 4294967295) ? - "ok" : "not ok", " 35\n"; - -print +(hex('0xff_ff_ff_ff') == 4294967295) ? - "ok" : "not ok", " 36\n"; +# tests 51 onwards aren't all warnings clean. (intentionally) + +print "1..69\n"; + +my $test = 1; + +sub test ($$$) { + my ($act, $string, $value) = @_; + my $result; + if ($act eq 'oct') { + $result = oct $string; + } elsif ($act eq 'hex') { + $result = hex $string; + } else { + die "Unknown action 'act'"; + } + if ($value == $result) { + if ($^O eq 'VMS' && length $string > 256) { + $string = ''; + } else { + $string = "\"$string\""; + } + print "ok $test # $act $string\n"; + } else { + my ($valstr, $resstr); + if ($act eq 'hex' or $string =~ /x/) { + $valstr = sprintf "0x%X", $value; + $resstr = sprintf "0x%X", $result; + } elsif ($string =~ /b/) { + $valstr = sprintf "0b%b", $value; + $resstr = sprintf "0b%b", $result; + } else { + $valstr = sprintf "0%o", $value; + $resstr = sprintf "0%o", $result; + } + print "not ok $test # $act \"$string\" gives \"$result\" ($resstr), not $value ($valstr)\n"; + } + $test++; +} + +test ('oct', '0b1_0101', 0b101_01); +test ('oct', '0b10_101', 0_2_5); +test ('oct', '0b101_01', 2_1); +test ('oct', '0b1010_1', 0x1_5); + +test ('oct', 'b1_0101', 0b10101); +test ('oct', 'b10_101', 025); +test ('oct', 'b101_01', 21); +test ('oct', 'b1010_1', 0x15); + +test ('oct', '01_234', 0b10_1001_1100); +test ('oct', '012_34', 01234); +test ('oct', '0123_4', 668); +test ('oct', '01234', 0x29c); + +test ('oct', '0x1_234', 0b10010_00110100); +test ('oct', '0x12_34', 01_1064); +test ('oct', '0x123_4', 4660); +test ('oct', '0x1234', 0x12_34); + +test ('oct', 'x1_234', 0b100100011010_0); +test ('oct', 'x12_34', 0_11064); +test ('oct', 'x123_4', 4660); +test ('oct', 'x1234', 0x_1234); + +test ('hex', '01_234', 0b_1001000110100); +test ('hex', '012_34', 011064); +test ('hex', '0123_4', 4660); +test ('hex', '01234_', 0x1234); + +test ('hex', '0x_1234', 0b1001000110100); +test ('hex', '0x1_234', 011064); +test ('hex', '0x12_34', 4660); +test ('hex', '0x1234_', 0x1234); + +test ('hex', 'x_1234', 0b1001000110100); +test ('hex', 'x12_34', 011064); +test ('hex', 'x123_4', 4660); +test ('hex', 'x1234_', 0x1234); + +test ('oct', '0b1111_1111_1111_1111_1111_1111_1111_1111', 4294967295); +test ('oct', '037_777_777_777', 4294967295); +test ('oct', '0xffff_ffff', 4294967295); +test ('hex', '0xff_ff_ff_ff', 4294967295); $_ = "\0_7_7"; print length eq 5 ? "ok" : "not ok", " 37\n"; @@ -78,11 +111,37 @@ else { print "\x2F_" eq "/_" ? "ok" : "not ok", " 44\n"; } -print +(oct('0b'.( '0'x10).'1_0101') == 0b101_01) ? "ok" : "not ok", " 45\n"; -print +(oct('0b'.( '0'x100).'1_0101') == 0b101_01) ? "ok" : "not ok", " 46\n"; -print +(oct('0b'.('0'x1000).'1_0101') == 0b101_01) ? "ok" : "not ok", " 47\n"; - -print +(hex(( '0'x10).'01234') == 0x1234) ? "ok" : "not ok", " 48\n"; -print +(hex(( '0'x100).'01234') == 0x1234) ? "ok" : "not ok", " 49\n"; -print +(hex(('0'x1000).'01234') == 0x1234) ? "ok" : "not ok", " 50\n"; +$test = 45; +test ('oct', '0b'.( '0'x10).'1_0101', 0b101_01); +test ('oct', '0b'.( '0'x100).'1_0101', 0b101_01); +test ('oct', '0b'.('0'x1000).'1_0101', 0b101_01); + +test ('hex', ( '0'x10).'01234', 0x1234); +test ('hex', ( '0'x100).'01234', 0x1234); +test ('hex', ('0'x1000).'01234', 0x1234); + +# Things that perl 5.6.1 and 5.7.2 did wrong (plus some they got right) +test ('oct', "b00b0101", 0); +test ('oct', "bb0101", 0); +test ('oct', "0bb0101", 0); + +test ('oct', "0x0x3A", 0); +test ('oct', "0xx3A", 0); +test ('oct', "x0x3A", 0); +test ('oct', "xx3A", 0); +test ('oct', "0x3A", 0x3A); +test ('oct', "x3A", 0x3A); + +test ('oct', "0x0x4", 0); +test ('oct', "0xx4", 0); +test ('oct', "x0x4", 0); +test ('oct', "xx4", 0); +test ('oct', "0x4", 4); +test ('oct', "x4", 4); + +test ('hex', "0x3A", 0x3A); +test ('hex', "x3A", 0x3A); + +test ('hex', "0x4", 4); +test ('hex', "x4", 4); diff --git a/t/op/override.t b/t/op/override.t index d24bdee31a..db94ed0495 100755 --- a/t/op/override.t +++ b/t/op/override.t @@ -47,7 +47,7 @@ print "not " unless $r eq "5.6"; print "ok 6\n"; require v5.6; -print "not " unless $r == 5.006 && $r eq "\x05\x06"; +print "not " unless abs($r - 5.006) < 0.001 && $r eq "\x05\x06"; print "ok 7\n"; eval "use Foo"; diff --git a/t/op/pack.t b/t/op/pack.t index 1c6222efe7..8d327466fc 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -26,7 +26,7 @@ sub ok { } -print "1..161\n"; +print "1..169\n"; # Note: All test numbers in comments are off by 1 after the comment below.. @@ -457,7 +457,46 @@ print 'not ' unless v1.20.300.4000 ne sprintf "%vd", pack("C0U*",1,20,300,4000); print "ok $test\n"; $test++; -# 160 +# 161 print "not " unless join(" ", unpack("C*", chr(0x1e2))) eq ((ord(A) == 193) ? "156 67" : "199 162"); print "ok $test\n"; $test++; + +# 162: does pack U create Unicode? +print "not " unless ord(pack('U', 300)) == 300; +print "ok $test\n"; $test++; + +# 163: does unpack U deref Unicode? +print "not " unless (unpack('U', chr(300)))[0] == 300; +print "ok $test\n"; $test++; + +# 164: is unpack U the reverse of pack U for Unicode string? +print "not " + unless "@{[unpack('U*', pack('U*', 100, 200, 300))]}" eq "100 200 300"; +print "ok $test\n"; $test++; + +# 165: is unpack U the reverse of pack U for byte string? +print "not " + unless "@{[unpack('U*', pack('U*', 100, 200))]}" eq "100 200"; +print "ok $test\n"; $test++; + +# 166: does unpack C unravel pack U? +print "not " unless "@{[unpack('C*', pack('U*', 100, 200))]}" eq "100 195 136"; +print "ok $test\n"; $test++; + +# 167: does pack U0C create Unicode? +print "not " unless "@{[pack('U0C*', 100, 195, 136)]}" eq v100.v200; +print "ok $test\n"; $test++; + +# 168: does pack C0U create characters? +print "not " unless "@{[pack('C0U*', 100, 200)]}" eq pack("C*", 100, 195, 136); +print "ok $test\n"; $test++; + +# 169: does unpack U0U on byte data warn? +{ + local $SIG{__WARN__} = sub { $@ = "@_" }; + my @null = unpack('U0U', chr(255)); + print "not " unless $@ =~ /^Malformed UTF-8 character /; + print "ok $test\n"; $test++; +} + diff --git a/t/op/pat.t b/t/op/pat.t index 2e8922523c..23d9c85f2b 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -6,7 +6,7 @@ $| = 1; -print "1..686\n"; +print "1..714\n"; BEGIN { chdir 't' if -d 't'; @@ -2008,3 +2008,113 @@ print "ok 683\n" if @a == 9 && "@a" eq "f o o \n $a $b b a r"; print "not " unless length($y) == 2 && $y eq $x; print "ok 686\n"; } + +my $test = 687; + +# Force scalar context on the patern match +sub ok ($$) { + my($ok, $name) = @_; + + printf "%sok %d - %s\n", ($ok ? "" : "not "), $test, $name; + + printf "# Failed test at line %d\n", (caller)[2] unless $ok; + + $test++; + return $ok; +} + +{ + # Check that \x## works. 5.6.1 and 5.005_03 fail some of these. + $x = "\x4e" . "E"; + ok ($x =~ /^\x4EE$/, "Check only 2 bytes of hex are matched."); + + $x = "\x4e" . "i"; + ok ($x =~ /^\x4Ei$/, "Check that invalid hex digit stops it (2)"); + + $x = "\x4" . "j"; + ok ($x =~ /^\x4j$/, "Check that invalid hex digit stops it (1)"); + + $x = "\x0" . "k"; + ok ($x =~ /^\xk$/, "Check that invalid hex digit stops it (0)"); + + $x = "\x0" . "x"; + ok ($x =~ /^\xx$/, "\\xx isn't to be treated as \\0"); + + $x = "\x0" . "xa"; + ok ($x =~ /^\xxa$/, "\\xxa isn't to be treated as \\xa"); + + $x = "\x9" . "_b"; + ok ($x =~ /^\x9_b$/, "\\x9_b isn't to be treated as \\x9b"); + + print "# and now again in [] ranges\n"; + + $x = "\x4e" . "E"; + ok ($x =~ /^[\x4EE]{2}$/, "Check only 2 bytes of hex are matched."); + + $x = "\x4e" . "i"; + ok ($x =~ /^[\x4Ei]{2}$/, "Check that invalid hex digit stops it (2)"); + + $x = "\x4" . "j"; + ok ($x =~ /^[\x4j]{2}$/, "Check that invalid hex digit stops it (1)"); + + $x = "\x0" . "k"; + ok ($x =~ /^[\xk]{2}$/, "Check that invalid hex digit stops it (0)"); + + $x = "\x0" . "x"; + ok ($x =~ /^[\xx]{2}$/, "\\xx isn't to be treated as \\0"); + + $x = "\x0" . "xa"; + ok ($x =~ /^[\xxa]{3}$/, "\\xxa isn't to be treated as \\xa"); + + $x = "\x9" . "_b"; + ok ($x =~ /^[\x9_b]{3}$/, "\\x9_b isn't to be treated as \\x9b"); + +} + +{ + # Check that \x{##} works. 5.6.1 fails quite a few of these. + + $x = "\x9b"; + ok ($x =~ /^\x{9_b}$/, "\\x{9_b} is to be treated as \\x9b"); + + $x = "\x9b" . "y"; + ok ($x =~ /^\x{9_b}y$/, "\\x{9_b} is to be treated as \\x9b (again)"); + + $x = "\x9b" . "y"; + ok ($x =~ /^\x{9b_}y$/, "\\x{9b_} is to be treated as \\x9b"); + + $x = "\x9b" . "y"; + ok ($x =~ /^\x{9_bq}y$/, "\\x{9_bc} is to be treated as \\x9b"); + + $x = "\x0" . "y"; + ok ($x =~ /^\x{x9b}y$/, "\\x{x9b} is to be treated as \\x0"); + + $x = "\x0" . "y"; + ok ($x =~ /^\x{0x9b}y$/, "\\x{0x9b} is to be treated as \\x0"); + + $x = "\x9b" . "y"; + ok ($x =~ /^\x{09b}y$/, "\\x{09b} is to be treated as \\x9b"); + + print "# and now again in [] ranges\n"; + + $x = "\x9b"; + ok ($x =~ /^[\x{9_b}]$/, "\\x{9_b} is to be treated as \\x9b"); + + $x = "\x9b" . "y"; + ok ($x =~ /^[\x{9_b}y]{2}$/, "\\x{9_b} is to be treated as \\x9b (again)"); + + $x = "\x9b" . "y"; + ok ($x =~ /^[\x{9b_}y]{2}$/, "\\x{9b_} is to be treated as \\x9b"); + + $x = "\x9b" . "y"; + ok ($x =~ /^[\x{9_bq}y]{2}$/, "\\x{9_bc} is to be treated as \\x9b"); + + $x = "\x0" . "y"; + ok ($x =~ /^[\x{x9b}y]{2}$/, "\\x{x9b} is to be treated as \\x0"); + + $x = "\x0" . "y"; + ok ($x =~ /^[\x{0x9b}y]{2}$/, "\\x{0x9b} is to be treated as \\x0"); + + $x = "\x9b" . "y"; + ok ($x =~ /^[\x{09b}y]{2}$/, "\\x{09b} is to be treated as \\x9b"); +} diff --git a/t/op/qq.t b/t/op/qq.t new file mode 100644 index 0000000000..651cf18a2e --- /dev/null +++ b/t/op/qq.t @@ -0,0 +1,63 @@ +#!./perl + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +print q(1..21 +); + +# This is() function is written to avoid "" +my $test = 1; +sub is { + my($left, $right) = @_; + + if ($left eq $right) { + printf 'ok %d +', $test++; + return 1; + } + foreach ($left, $right) { + # Comment out these regexps to map non-printables to ord if the perl under + # test is so broken that it's not helping + s/([^-+A-Za-z_0-9])/sprintf q{'.chr(%d).'}, ord $1/ge; + $_ = sprintf q('%s'), $_; + s/^''\.//; + s/\.''$//; + } + printf q(not ok %d - got %s expected %s +), $test++, $left, $right; + + printf q(# Failed test at line %d +), (caller)[2]; + + return 0; +} + +is ("\x53", chr 83); +is ("\x4EE", chr (78) . 'E'); +is ("\x4i", chr (4) . 'i'); # This will warn +is ("\xh", chr (0) . 'h'); # This will warn +is ("\xx", chr (0) . 'x'); # This will warn +is ("\xx9", chr (0) . 'x9'); # This will warn. \x9 is tab in EBCDIC too? +is ("\x9_E", chr (9) . '_E'); # This will warn + +is ("\x{4E}", chr 78); +is ("\x{6_9}", chr 105); +is ("\x{_6_3}", chr 99); +is ("\x{_6B}", chr 107); + +is ("\x{9__0}", chr 9); # multiple underscores not allowed. +is ("\x{77_}", chr 119); # trailing underscore warns. +is ("\x{6FQ}z", chr (111) . 'z'); + +is ("\x{0x4E}", chr 0); +is ("\x{x4E}", chr 0); + +is ("\x{0065}", chr 101); +is ("\x{000000000000000000000000000000000000000000000000000000000000000072}", + chr 114); +is ("\x{0_06_5}", chr 101); +is ("\x{1234}", chr 4660); +is ("\x{98765432}", chr 2557891634); diff --git a/t/op/rand.t b/t/op/rand.t index e365e597b4..44bf0ff2e4 100755 --- a/t/op/rand.t +++ b/t/op/rand.t @@ -22,14 +22,10 @@ BEGIN { use strict; use Config; +use Test::More tests => 8; -print "1..11\n"; -srand; # Shouldn't need this with 5.004... - # But I'll include it now and test for - # whether we needed it later. - -my $reps = 1000; # How many times to try rand each time. +my $reps = 10000; # How many times to try rand each time. # May be changed, but should be over 500. # The more the better! (But slower.) @@ -74,8 +70,6 @@ EOM } - # Hints for TEST 1 - # # This test checks for one of Perl's most frequent # mis-configurations. Your system's documentation # for rand(2) should tell you what value you need @@ -85,13 +79,16 @@ EOM # reason that the diagnostic message might get the # wrong value is that Config.pm is incorrect.) # - if ($max <= 0 or $max >= (2 ** $randbits)) {# Just in case... - print "# max=[$max] min=[$min]\nnot ok 1\n"; - print "# This perl was compiled with randbits=$randbits\n"; - print "# which is _way_ off. Or maybe your system rand is broken,\n"; - print "# or your C compiler can't multiply, or maybe Martians\n"; - print "# have taken over your computer. For starters, see about\n"; - print "# trying a better value for randbits, probably smaller.\n"; + unless (ok( !$max <= 0 or $max >= (2 ** $randbits))) {# Just in case... + print <<DIAG; +# max=[$max] min=[$min] +# This perl was compiled with randbits=$randbits +# which is _way_ off. Or maybe your system rand is broken, +# or your C compiler can't multiply, or maybe Martians +# have taken over your computer. For starters, see about +# trying a better value for randbits, probably smaller. +DIAG + # If that isn't the problem, we'll have # to put d_martians into Config.pm print "# Skipping remaining tests until randbits is fixed.\n"; @@ -100,34 +97,27 @@ EOM $off = log($max) / log(2); # log2 $off = int($off) + ($off > 0); # Next more positive int - if ($off) { + unless (is( $off, 0 )) { $shouldbe = $Config{randbits} + $off; - print "# max=[$max] min=[$min]\nnot ok 1\n"; + print "# max=[$max] min=[$min]\n"; print "# This perl was compiled with randbits=$randbits on $^O.\n"; print "# Consider using randbits=$shouldbe instead.\n"; # And skip the remaining tests; they would be pointless now. print "# Skipping remaining tests until randbits is fixed.\n"; exit; - } else { - print "ok 1\n"; } - # Hints for TEST 2 - # + # This should always be true: 0 <= rand(1) < 1 # If this test is failing, something is seriously wrong, # either in perl or your system's rand function. # - if ($min < 0 or $max >= 1) { # Slightly redundant... - print "not ok 2\n"; + unless (ok( !($min < 0 or $max >= 1) )) { # Slightly redundant... print "# min too low\n" if $min < 0; print "# max too high\n" if $max >= 1; - } else { - print "ok 2\n"; } - # Hints for TEST 3 - # + # This is just a crude test. The average number produced # by rand should be about one-half. But once in a while # it will be relatively far away. Note: This test will @@ -135,14 +125,11 @@ EOM # See the hints for test 4 to see why. # $sum /= $reps; - if ($sum < 0.4 or $sum > 0.6) { - print "not ok 3\n# Average random number is far from 0.5\n"; - } else { - print "ok 3\n"; + unless (ok( !($sum < 0.4 or $sum > 0.6) )) { + print "# Average random number is far from 0.5\n"; } - # Hints for TEST 4 - # + # NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE # This test will fail .1% of the time on a normal system. # also @@ -189,27 +176,24 @@ EOM # (eight bits per rep) $dev = abs ($bits - $reps * 4) / sqrt($reps * 2); + ok( $dev < 3.3 ); + if ($dev < 1.96) { - print "ok 4\n"; # 95% of the time. print "# Your rand seems fine. If this test failed\n"; print "# previously, you may want to run it again.\n"; } elsif ($dev < 2.575) { - print "ok 4\n# In here about 4% of the time. Hmmm...\n"; print "# This is ok, but suspicious. But it will happen\n"; print "# one time out of 25, more or less.\n"; print "# You should run this test again to be sure.\n"; } elsif ($dev < 3.3) { - print "ok 4\n# In this range about 1% of the time.\n"; print "# This is very suspicious. It will happen only\n"; print "# about one time out of 100, more or less.\n"; print "# You should run this test again to be sure.\n"; } elsif ($dev < 3.9) { - print "not ok 4\n# In this range very rarely.\n"; print "# This is VERY suspicious. It will happen only\n"; print "# about one time out of 1000, more or less.\n"; print "# You should run this test again to be sure.\n"; } else { - print "not ok 4\n# Seriously whacked.\n"; print "# This is VERY VERY suspicious.\n"; print "# Your rand seems to be bogus.\n"; } @@ -218,57 +202,6 @@ EOM printf "# information on why this might fail. [ %.3f ]\n", $dev; } -{ - srand; # These three lines are for test 7 - my $time = time; # It's just faster to do them here. - my $rand = join ", ", rand, rand, rand; - - # Hints for TEST 5 - # - # This test checks that the argument to srand actually - # sets the seed for generating random numbers. - # - srand(3.14159); - my $r = rand; - srand(3.14159); - if (rand != $r) { - print "not ok 5\n"; - print "# srand is not consistent.\n"; - } else { - print "ok 5\n"; - } - - # Hints for TEST 6 - # - # This test just checks that the previous one didn't - # give us false confidence! - # - if (rand == $r) { - print "not ok 6\n"; - print "# rand is now unchanging!\n"; - } else { - print "ok 6\n"; - } - - # Hints for TEST 7 - # - # This checks that srand without arguments gives - # different sequences each time. Note: You shouldn't - # be calling srand more than once unless you know - # what you're doing! But if this fails on your - # system, run perlbug and let the developers know - # what other sources of randomness srand should - # tap into. - # - while ($time == time) { } # Wait for new second, just in case. - srand; - if ((join ", ", rand, rand, rand) eq $rand) { - print "not ok 7\n"; - print "# srand without args isn't varying.\n"; - } else { - print "ok 7\n"; - } -} # Now, let's see whether rand accepts its argument { @@ -280,23 +213,17 @@ EOM $min = $n if $n < $min; } - # Hints for TEST 8 - # # This test checks to see that rand(100) really falls # within the range 0 - 100, and that the numbers produced # have a reasonably-large range among them. # - if ($min < 0 or $max >= 100 or ($max - $min) < 65) { - print "not ok 8\n"; + unless ( ok( !($min < 0 or $max >= 100 or ($max - $min) < 65) ) ) { print "# min too low\n" if $min < 0; print "# max too high\n" if $max >= 100; print "# range too narrow\n" if ($max - $min) < 65; - } else { - print "ok 8\n"; } - # Hints for TEST 9 - # + # This test checks that rand without an argument # is equivalent to rand(1). # @@ -304,57 +231,12 @@ EOM srand 12345; my $r = rand; srand 12345; - if (rand(1) == $r) { - print "ok 9\n"; - } else { - print "not ok 9\n"; - print "# rand without arguments isn't rand(1)!\n"; - } + is(rand(1), $r, 'rand() without args is rand(1)'); + - # Hints for TEST 10 - # # This checks that rand without an argument is not # rand($_). (In case somebody got overzealous.) # - if ($r >= 1) { - print "not ok 10\n"; - print "# rand without arguments isn't under 1!\n"; - } else { - print "ok 10\n"; - } + ok($r < 1, 'rand() without args is under 1'); } -# Hints for TEST 11 -# -# This test checks whether Perl called srand for you. This should -# be the case in version 5.004 and later. Note: You must still -# call srand if your code might ever be run on a pre-5.004 system! -# -AUTOSRAND: -{ - unless ($Config{d_fork}) { - # Skip this test. It's not likely to be system-specific, anyway. - print "ok 11\n# Skipping this test on this platform.\n"; - last; - } - - my($pid, $first); - for (1..5) { - my $PERL = (($^O eq 'VMS') ? "MCR $^X" - : ($^O eq 'MSWin32') ? '.\perl' - : ($^O eq 'NetWare') ? 'perl' - : './perl'); - $pid = open PERL, qq[$PERL -e "print rand"|]; - die "Couldn't pipe from perl: $!" unless defined $pid; - if (defined $first) { - if ($first ne <PERL>) { - print "ok 11\n"; - last AUTOSRAND; - } - } else { - $first = <PERL>; - } - close PERL or die "perl returned error code $?"; - } - print "not ok 11\n# srand isn't being autocalled.\n"; -} diff --git a/t/op/srand.t b/t/op/srand.t new file mode 100644 index 0000000000..bbd0e54845 --- /dev/null +++ b/t/op/srand.t @@ -0,0 +1,51 @@ +#!./perl -w + +# Test srand. + +use strict; +use Test::More tests => 4; + +# Generate a load of random numbers. +# int() avoids possible floating point error. +sub mk_rand { map int rand 10000, 1..100; } + + +# Check that rand() is deterministic. +srand(1138); +my @first_run = mk_rand; + +srand(1138); +my @second_run = mk_rand; + +ok( eq_array(\@first_run, \@second_run), 'srand(), same arg, same rands' ); + + +# Check that different seeds provide different random numbers +srand(31337); +@first_run = mk_rand; + +srand(1138); +@second_run = mk_rand; + +ok( !eq_array(\@first_run, \@second_run), + 'srand(), different arg, different rands' ); + + +# Check that srand() isn't affected by $_ +{ + local $_ = 42; + srand(); + @first_run = mk_rand; + + srand(42); + @second_run = mk_rand; + + ok( !eq_array(\@first_run, \@second_run), + 'srand(), no arg, not affected by $_'); +} + +# This test checks whether Perl called srand for you. +@first_run = `$^X -le "print int rand 100 for 1..100"`; +@second_run = `$^X -le "print int rand 100 for 1..100"`; + +ok( !eq_array(\@first_run, \@second_run), 'srand() called automatically'); diff --git a/t/op/time.t b/t/op/time.t index caf2c14a6c..870a8dcf03 100755 --- a/t/op/time.t +++ b/t/op/time.t @@ -2,8 +2,27 @@ # $RCSfile: time.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:32 $ -if ($does_gmtime = gmtime(time)) { print "1..6\n" } -else { print "1..3\n" } +if ( $does_gmtime = gmtime(time) ) { + print "1..7\n" +} +else { + print "1..4\n" +} + + +my $test = 1; +sub ok ($$) { + my($ok, $name) = @_; + + # You have to do it this way or VMS will get confused. + print $ok ? "ok $test - $name\n" : "not ok $test - $name\n"; + + printf "# Failed test at line %d\n", (caller)[2] unless $ok; + + $test++; + return $ok; +} + ($beguser,$begsys) = times; @@ -11,7 +30,7 @@ $beg = time; while (($now = time) == $beg) { sleep 1 } -if ($now > $beg && $now - $beg < 10){print "ok 1\n";} else {print "not ok 1\n";} +ok($now > $beg && $now - $beg < 10, 'very basic time test'); for ($i = 0; $i < 100000; $i++) { ($nowuser, $nowsys) = times; @@ -20,34 +39,37 @@ for ($i = 0; $i < 100000; $i++) { last if time - $beg > 20; } -if ($i >= 200000) {print "ok 2\n";} else {print "not ok 2\n";} +ok($i >= 200000, 'very basic times test'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($beg); ($xsec,$foo) = localtime($now); $localyday = $yday; -if ($sec != $xsec && $mday && $year) - {print "ok 3\n";} -else - {print "not ok 3\n";} +ok($sec != $xsec && $mday && $year, 'localtime() list context'); + +ok(localtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ] + (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ] + ([ \d]\d)\ (\d\d):(\d\d):(\d\d)\ (\d{4})$ + /x, + 'localtime(), scalar context' + ); exit 0 unless $does_gmtime; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($beg); ($xsec,$foo) = localtime($now); -if ($sec != $xsec && $mday && $year) - {print "ok 4\n";} -else - {print "not ok 4\n";} +ok($sec != $xsec && $mday && $year, 'gmtime() list context'); + +my $day_diff = $localyday - $yday; +ok( grep({ $day_diff == $_ } (0, 1, -1, 364, 365, -364, -365)), + 'gmtime() and localtime() agree what day of year'); -if (index(" :0:1:-1:364:365:-364:-365:",':' . ($localyday - $yday) . ':') > 0) - {print "ok 5\n";} -else - {print "not ok 5\n";} # This could be stricter. -if (gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([ \d]\d) (\d\d):(\d\d):(\d\d) (\d\d\d\d)$/) - {print "ok 6\n";} -else - {print "not ok 6\n";} +ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ] + (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[ ] + ([ \d]\d)\ (\d\d):(\d\d):(\d\d)\ (\d{4})$ + /x, + 'gmtime(), scalar context' + ); diff --git a/t/op/utf8decode.t b/t/op/utf8decode.t index cc2b26aaf3..499049aab9 100755 --- a/t/op/utf8decode.t +++ b/t/op/utf8decode.t @@ -136,24 +136,21 @@ __EOMK__ # 104..181 { - my $WARNCNT; my $id; - local $SIG{__WARN__} = - sub { - print "# $id: @_"; - $WARNCNT++; - $WARNMSG = "@_"; - }; + local $SIG{__WARN__} = sub { + print "# $id: @_"; + $@ = "@_"; + }; sub moan { print "$id: @_"; } - sub test_unpack_U { - $WARNCNT = 0; - $WARNMSG = ""; - unpack('U*', $_[0]); + sub warn_unpack_U { + $@ = ''; + my @null = unpack('U0U*', $_[0]); + return $@; } for (@MK) { @@ -161,7 +158,7 @@ __EOMK__ # print "# $_\n"; } elsif (/^(\d+\.\d+\.\d+[bu]?)\s+([yn])\s+"(.+)"\s+([0-9a-f]{1,8}|-)\s+(\d+)\s+([0-9a-f]{2}(?::[0-9a-f]{2})*)(?:\s+((?:\d+|-)(?:\s+(.+))?))?$/) { $id = $1; - my ($okay, $bytes, $Unicode, $byteslen, $hex, $charslen, $error) = + my ($okay, $bytes, $Unicode, $byteslen, $hex, $charslen, $experr) = ($2, $3, $4, $5, $6, $7, $8); my @hex = split(/:/, $hex); unless (@hex == $byteslen) { @@ -175,20 +172,19 @@ __EOMK__ moan "bytes length() ($bytesbyteslen) not equal to $byteslen\n"; } } + my $warn = warn_unpack_U($bytes); if ($okay eq 'y') { - test_unpack_U($bytes); - if ($WARNCNT) { - moan "unpack('U*') false negative\n"; + if ($warn) { + moan "unpack('U0U*') false negative\n"; print "not "; } } elsif ($okay eq 'n') { - test_unpack_U($bytes); - if ($WARNCNT == 0 || ($error ne '' && $WARNMSG !~ /$error/)) { - moan "unpack('U*') false positive\n"; + if (not $warn || ($experr ne '' && $warn !~ /$experr/)) { + moan "unpack('U0U*') false positive\n"; print "not "; } } - print "ok $test\n"; + print "ok $test # $id $okay\n"; $test++; } else { moan "unknown format\n"; diff --git a/t/op/ver.t b/t/op/ver.t index 58408b664a..4ccc84cba1 100755 --- a/t/op/ver.t +++ b/t/op/ver.t @@ -3,50 +3,42 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN }; } -print "1..39\n"; +$DOWARN = 1; # enable run-time warnings now -my $test = 1; +use Config; +$tests = $Config{'uvsize'} == 8 ? 47 : 44; -sub okeq { - my $ok = $_[0] eq $_[1];; - print "not " unless $ok; - print "ok ", $test++; - print " # $_[2]" if !$ok && @_ == 3; - print "\n"; -} +require Test::More; +Test::More->import( tests => $tests ); -sub skip { print "ok ", $test++, " # Skip: $_[0]\n" } +eval { use v5.5.640; }; +is( $@, '', "use v5.5.640; $@"); -use v5.5.640; -require v5.5.640; -print "ok $test\n"; ++$test; +require_ok('v5.5.640'); # printing characters should work if (ord("\t") == 9) { # ASCII - print v111; - print v107.32; - print "$test\n"; ++$test; + is('ok ',v111.107.32,'ASCII printing characters'); # hash keys too $h{v111.107} = "ok"; - print "$h{ok} $test\n"; ++$test; + is('ok',$h{v111.107},'ASCII hash keys'); } else { # EBCDIC - print v150; - print v146.64; - print "$test\n"; ++$test; + is('ok ',v150.146.64,'EBCDIC printing characters'); # hash keys too $h{v150.146} = "ok"; - print "$h{ok} $test\n"; ++$test; + is('ok',$h{v111.107},'ASCII hash keys'); } # poetry optimization should also sub v77 { "ok" } $x = v77; -print "$x $test\n"; ++$test; +is('ok',$x,'poetry optimization'); # but not when dots are involved if (ord("\t") == 9) { # ASCII @@ -55,15 +47,16 @@ if (ord("\t") == 9) { # ASCII else { $x = v212.213.214; } -okeq($x, "MNO"); +is($x, 'MNO','poetry optimization with dots'); -okeq(v1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}"); +is(v1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}",'compare embedded \x{} string'); # # now do the same without the "v" -use 5.5.640; -require 5.5.640; -print "ok $test\n"; ++$test; +eval { use 5.5.640; }; +is( $@, '', "use 5.5.640; $@"); + +require_ok('5.5.640'); # hash keys too if (ord("\t") == 9) { # ASCII @@ -72,7 +65,7 @@ if (ord("\t") == 9) { # ASCII else { $h{150.146.64} = "ok"; } -print "$h{ok } $test\n"; ++$test; +is('ok',$h{ok },'hash keys w/o v'); if (ord("\t") == 9) { # ASCII $x = 77.78.79; @@ -80,131 +73,117 @@ if (ord("\t") == 9) { # ASCII else { $x = 212.213.214; } -okeq($x, "MNO"); +is($x, 'MNO','poetry optimization with dots w/o v'); -okeq(1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}"); +is(1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}",'compare embedded \x{} string w/o v'); # test sprintf("%vd"...) etc if (ord("\t") == 9) { # ASCII - okeq(sprintf("%vd", "Perl"), '80.101.114.108'); + is(sprintf("%vd", "Perl"), '80.101.114.108', 'ASCII sprintf("%vd", "Perl")'); } else { - okeq(sprintf("%vd", "Perl"), '215.133.153.147'); + is(sprintf("%vd", "Perl"), '215.133.153.147', 'EBCDIC sprintf("%vd", "Perl")'); } -okeq(sprintf("%vd", v1.22.333.4444), '1.22.333.4444'); +is(sprintf("%vd", v1.22.333.4444), '1.22.333.4444', 'sprintf("%vd", v1.22.333.4444)'); if (ord("\t") == 9) { # ASCII - okeq(sprintf("%vx", "Perl"), '50.65.72.6c'); + is(sprintf("%vx", "Perl"), '50.65.72.6c', 'ASCII sprintf("%vx", "Perl")'); } else { - okeq(sprintf("%vx", "Perl"), 'd7.85.99.93'); + is(sprintf("%vx", "Perl"), 'd7.85.99.93', 'EBCDIC sprintf("%vx", "Perl")'); } -okeq(sprintf("%vX", 1.22.333.4444), '1.16.14D.115C'); +is(sprintf("%vX", 1.22.333.4444), '1.16.14D.115C','ASCII sprintf("%vX", 1.22.333.4444)'); if (ord("\t") == 9) { # ASCII - okeq(sprintf("%#*vo", ":", "Perl"), '0120:0145:0162:0154'); + is(sprintf("%#*vo", ":", "Perl"), '0120:0145:0162:0154', 'ASCII sprintf("%vo", "Perl")'); } else { - okeq(sprintf("%#*vo", ":", "Perl"), '0327:0205:0231:0223'); + is(sprintf("%#*vo", ":", "Perl"), '0327:0205:0231:0223', 'EBCDIC sprintf("%vo", "Perl")'); } -okeq(sprintf("%*vb", "##", v1.22.333.4444), - '1##10110##101001101##1000101011100'); +is(sprintf("%*vb", "##", v1.22.333.4444), + '1##10110##101001101##1000101011100', 'sprintf("%vb", 1.22.333.4444)'); -okeq(sprintf("%vd", join("", map { chr } +is(sprintf("%vd", join("", map { chr } unpack 'U*', pack('U*',2001,2002,2003))), - '2001.2002.2003'); + '2001.2002.2003','unpack/pack U*'); { use bytes; if (ord("\t") == 9) { # ASCII - okeq(sprintf("%vd", "Perl"), '80.101.114.108'); + is(sprintf("%vd", "Perl"), '80.101.114.108', 'ASCII sprintf("%vd", "Perl") w/use bytes'); } else { - okeq(sprintf("%vd", "Perl"), '215.133.153.147'); + is(sprintf("%vd", "Perl"), '215.133.153.147', 'EBCDIC sprintf("%vd", "Perl") w/use bytes'); } if (ord("\t") == 9) { # ASCII - okeq(sprintf("%vd", 1.22.333.4444), '1.22.197.141.225.133.156'); + is(sprintf("%vd", 1.22.333.4444), '1.22.197.141.225.133.156', 'ASCII sprintf("%vd", v1.22.333.4444 w/use bytes'); } else { - okeq(sprintf("%vd", 1.22.333.4444), '1.22.142.84.187.81.112'); + is(sprintf("%vd", 1.22.333.4444), '1.22.142.84.187.81.112', 'EBCDIC sprintf("%vd", v1.22.333.4444 w/use bytes'); } if (ord("\t") == 9) { # ASCII - okeq(sprintf("%vx", "Perl"), '50.65.72.6c'); + is(sprintf("%vx", "Perl"), '50.65.72.6c', 'ASCII sprintf("%vx", "Perl")'); } else { - okeq(sprintf("%vx", "Perl"), 'd7.85.99.93'); + is(sprintf("%vx", "Perl"), 'd7.85.99.93', 'EBCDIC sprintf("%vx", "Perl")'); } if (ord("\t") == 9) { # ASCII - okeq(sprintf("%vX", v1.22.333.4444), '1.16.C5.8D.E1.85.9C'); + is(sprintf("%vX", v1.22.333.4444), '1.16.C5.8D.E1.85.9C', 'ASCII sprintf("%vX", v1.22.333.4444)'); } else { - okeq(sprintf("%vX", v1.22.333.4444), '1.16.8E.54.BB.51.70'); + is(sprintf("%vX", v1.22.333.4444), '1.16.8E.54.BB.51.70', 'EBCDIC sprintf("%vX", v1.22.333.4444)'); } if (ord("\t") == 9) { # ASCII - okeq(sprintf("%#*vo", ":", "Perl"), '0120:0145:0162:0154'); + is(sprintf("%#*vo", ":", "Perl"), '0120:0145:0162:0154', 'ASCII sprintf("%#*vo", ":", "Perl")'); } else { - okeq(sprintf("%#*vo", ":", "Perl"), '0327:0205:0231:0223'); + is(sprintf("%#*vo", ":", "Perl"), '0327:0205:0231:0223', 'EBCDIC sprintf("%#*vo", ":", "Perl")'); } if (ord("\t") == 9) { # ASCII - okeq(sprintf("%*vb", "##", v1.22.333.4444), - '1##10110##11000101##10001101##11100001##10000101##10011100'); + is(sprintf("%*vb", "##", v1.22.333.4444), + '1##10110##11000101##10001101##11100001##10000101##10011100', + 'ASCII sprintf("%*vb", "##", v1.22.333.4444)'); } else { - okeq(sprintf("%*vb", "##", v1.22.333.4444), - '1##10110##10001110##1010100##10111011##1010001##1110000'); + is(sprintf("%*vb", "##", v1.22.333.4444), + '1##10110##10001110##1010100##10111011##1010001##1110000', + 'EBCDIC sprintf("%*vb", "##", v1.22.333.4444)'); } } { - # 24..28 - # bug id 20000323.056 - print "not " unless "\x{41}" eq +v65; - print "ok $test\n"; - $test++; - - print "not " unless "\x41" eq +v65; - print "ok $test\n"; - $test++; - - print "not " unless "\x{c8}" eq +v200; - print "ok $test\n"; - $test++; - - print "not " unless "\xc8" eq +v200; - print "ok $test\n"; - $test++; - - print "not " unless "\x{221b}" eq v8731; - print "ok $test\n"; - $test++; + is( "\x{41}", +v65, 'bug id 20000323.056'); + is( "\x41", +v65, 'bug id 20000323.056'); + is( "\x{c8}", +v200, 'bug id 20000323.056'); + is( "\xc8", +v200, 'bug id 20000323.056'); + is( "\x{221b}", +v8731, 'bug id 20000323.056'); } # See if the things Camel-III says are true: 29..33 # Chapter 2 pp67/68 my $vs = v1.20.300.4000; -okeq($vs,"\x{1}\x{14}\x{12c}\x{fa0}","v-string ne \\x{}"); -okeq($vs,chr(1).chr(20).chr(300).chr(4000),"v-string ne chr()"); -okeq('foo',((chr(193) eq 'A') ? v134.150.150 : v102.111.111),"v-string ne ''"); +is($vs,"\x{1}\x{14}\x{12c}\x{fa0}","v-string ne \\x{}"); +is($vs,chr(1).chr(20).chr(300).chr(4000),"v-string ne chr()"); +is('foo',((chr(193) eq 'A') ? v134.150.150 : v102.111.111),"v-string ne ''"); # Chapter 15, pp403 # See if sane addr and gethostbyaddr() work eval { require Socket; gethostbyaddr(v127.0.0.1, Socket::AF_INET) }; if ($@) { - # No - so don't test insane fails. + # No - so do not test insane fails. $@ =~ s/\n/\n# /g; skip("No Socket::AF_INET # $@"); } @@ -212,27 +191,38 @@ else { my $ip = v2004.148.0.1; my $host; eval { $host = gethostbyaddr($ip,Socket::AF_INET) }; - okeq($@ =~ /Wide character/,1,"Non-bytes leak to gethostbyaddr"); + ok($@ =~ /Wide character/,"Non-bytes leak to gethostbyaddr"); } # Chapter 28, pp671 -okeq(v5.6.0 lt v5.7.0,1,"v5.6.0 lt v5.7.0 fails"); - -# 34..37: part of 20000323.059 -okeq(v200,chr(200),"v200 ne chr(200)"); -okeq(v200,+v200,"v200 ne +v200"); -okeq(v200,eval("v200"),'v200 ne "v200"'); -okeq(v200,eval("+v200"),'v200 ne eval("+v200")'); - -# There have been no actual tests for $] itself until now -my ($REVISION,$VERSION,$SUBVERSION) = split '\.', sprintf("%vd",$^V); -my $v = sprintf("%d.%.3d%.3d",$REVISION,$VERSION,$SUBVERSION); -okeq($v,"$]","\$^V and \$] do not match (string)"); -$v = $REVISION+$VERSION/1000+$SUBVERSION/1000000; -if ( $v == $] ) { - print "ok $test"; +ok(v5.6.0 lt v5.7.0, "v5.6.0 lt v5.7.0"); + +# part of 20000323.059 +is(v200, chr(200), "v200 eq chr(200)" ); +is(v200, +v200, "v200 eq +v200" ); +is(v200, eval( "v200"), 'v200 eq "v200"' ); +is(v200, eval("+v200"), 'v200 eq eval("+v200")' ); + +# Tests for string/numeric value of $] itself +my ($revision,$version,$subversion) = split '\.', sprintf("%vd",$^V); + +my $v = sprintf("%d.%.3d%.3d",$revision,$version,$subversion); + +ok( $v eq "$]", "\$^V eq \$] (string)"); + +$v = $revision + $version/1000 + $subversion/1000000; + +ok( $v == $], "\$^V == \$] (numeric)" ); + +# [ID 20010902.001] check if v-strings handle full UV range or not +if ( $Config{'uvsize'} >= 4 ) { + is( sprintf("%vd", v2147483647.2147483648), '2147483647.2147483648', 'v-string > IV_MAX[32-bit]' ); + is( sprintf("%vd", v3141592653), '3141592653', 'IV_MAX < v-string < UV_MAX[32-bit]'); + is( sprintf("%vd", v4294967295), '4294967295', 'v-string == UV_MAX[32-bit] - 1'); } -else { - print "not ok $test \# \$^V and \$] do not match (numerically)"; + +if ( $Config{'uvsize'} >= 8 ) { + is( sprintf("%vd", v9223372036854775807.9223372036854775808), '9223372036854775807.9223372036854775808', 'v-string > IV_MAX[64-bit]' ); + is( sprintf("%vd", v17446744073709551615), '17446744073709551615', 'IV_MAX < v-string < UV_MAX[64-bit]'); + is( sprintf("%vd", v18446744073709551615), '18446744073709551615', 'v-string == UV_MAX[64-bit] - 1'); } -$test++; #in case anyone is adding more tests diff --git a/t/run/kill_perl.t b/t/run/kill_perl.t index aa7a4a9d45..225208e7f6 100644 --- a/t/run/kill_perl.t +++ b/t/run/kill_perl.t @@ -89,7 +89,13 @@ foreach my $prog (@prgs) { # various yaccs may or may not capitalize 'syntax'. $results =~ s/^(syntax|parse) error/syntax error/mig; - $results =~ s/\n\n/\n/ if $^O eq 'VMS'; # pipes double these sometimes + if ($^O eq 'VMS') { + # some tests will trigger VMS messages that won't be expected + $results =~ s/\n?%[A-Z]+-[SIWEF]-[A-Z]+,.*//; + + # pipes double these sometimes + $results =~ s/\n\n/\n/g; + } $expected =~ s/\n+$//; my $ok = $results eq $expected; @@ -718,8 +724,6 @@ EXPECT ######## -w "x" =~ /(\G?x)?/; # core dump in 20000716.007 -EXPECT -Quantifier unexpected on zero-length expression in regex; marked by <-- HERE in m/(\G?x)? <-- HERE / at - line 2. ######## # Bug 20010515.004 my @h = 1 .. 10; @@ -788,3 +792,13 @@ EXPECT EXPECT Can't modify constant item in list assignment at - line 1, near ");" Execution of - aborted due to compilation errors. +######## tying a bareword causes a segfault in 5.6.1 +tie FOO, "Foo"; +EXPECT +Can't modify constant item in tie at - line 1, near ""Foo";" +Execution of - aborted due to compilation errors. +######## undefing constant causes a segfault in 5.6.1 [ID 20010906.019] +undef foo; +EXPECT +Can't modify constant item in undef operator at - line 1, near "foo;" +Execution of - aborted due to compilation errors. |