summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-05-29 18:41:19 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-05-29 18:41:19 +0000
commita0f7c5349d9cbdebc03bb61d0662902819c72b0d (patch)
tree6bea7aec0b362bf7f11c510133b32a0b5cb1da45 /t
parent00aadd7184751f37937d2ec7edb2b9d1c8a55e0e (diff)
parent55bceba65f83da05702b3603a0967b74e0c73135 (diff)
downloadperl-a0f7c5349d9cbdebc03bb61d0662902819c72b0d.tar.gz
Post weekend integrate mainline (fails one test pragma/autouse).
p4raw-id: //depot/perlio@10299
Diffstat (limited to 't')
-rwxr-xr-xt/TEST32
-rwxr-xr-xt/io/utf8.t2
-rw-r--r--t/lib/1_compile.t20
-rw-r--r--t/lib/Test/fail.t93
-rw-r--r--t/lib/Test/mix.t17
-rw-r--r--t/lib/Test/onfail.t31
-rw-r--r--t/lib/Test/qr.t13
-rw-r--r--t/lib/Test/skip.t40
-rw-r--r--t/lib/Test/success.t11
-rw-r--r--t/lib/Test/todo.t13
-rw-r--r--t/lib/carp.t53
-rw-r--r--t/lib/charnames.t2
-rw-r--r--t/lib/extutils.t229
-rw-r--r--t/lib/filestat.t70
-rw-r--r--t/lib/i18n-langtags.t45
-rw-r--r--t/lib/lc-language.t2
-rw-r--r--t/lib/lc-maketext.t37
-rw-r--r--t/lib/net-nent.t36
-rw-r--r--t/lib/net-pent.t38
-rw-r--r--t/lib/net-sent.t38
-rw-r--r--t/lib/perlio.t90
-rw-r--r--t/lib/sigaction.t2
-rw-r--r--t/lib/test-harness.t34
-rw-r--r--t/lib/time-gmtime.t57
-rw-r--r--t/lib/time-localtime.t57
-rw-r--r--t/lib/time-piece.t4
-rw-r--r--t/lib/user-grent.t44
-rw-r--r--t/lib/user-pwent.t63
-rw-r--r--t/op/gmagic.t83
-rwxr-xr-xt/op/misc.t12
-rwxr-xr-xt/op/regexp.t4
-rwxr-xr-xt/op/splice.t8
-rwxr-xr-xt/op/taint.t21
-rwxr-xr-xt/op/ver.t16
-rw-r--r--t/pragma/autouse.t53
-rwxr-xr-xt/pragma/locale.t50
-rw-r--r--t/pragma/warn/pp_hot15
37 files changed, 1383 insertions, 52 deletions
diff --git a/t/TEST b/t/TEST
index 702409e467..8f60c8701c 100755
--- a/t/TEST
+++ b/t/TEST
@@ -44,12 +44,34 @@ $ENV{PERL_DESTRUCT_LEVEL} = 2 unless exists $ENV{PERL_DESTRUCT_LEVEL};
$ENV{EMXSHELL} = 'sh'; # For OS/2
-if ($#ARGV == -1) {
- @ARGV = split(/[ \n]/,
- `echo base/*.t comp/*.t cmd/*.t run/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t pod/*.t`);
+
+# Roll your own File::Find!
+use TestInit;
+use File::Spec;
+my $curdir = File::Spec->curdir;
+my $updir = File::Spec->updir;
+
+sub _find_tests {
+ my($dir) = @_;
+ opendir DIR, $dir || die "Trouble opening $dir: $!";
+ foreach my $f (readdir DIR) {
+ next if $f eq $curdir or $f eq $updir;
+
+ my $fullpath = File::Spec->catdir($dir, $f);
+
+ _find_tests($fullpath) if -d $fullpath;
+ push @ARGV, $fullpath if $f =~ /\.t$/;
+ }
+}
+
+unless (@ARGV) {
+ foreach my $dir (qw(base comp cmd run io op pragma lib pod)) {
+ _find_tests($dir);
+ }
}
# %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
+%infinite = ();
if ($deparse) {
_testprogs('deparse', @ARGV);
@@ -170,8 +192,9 @@ EOT
print $_;
}
unless (/^#/) {
- if (/^1\.\.([0-9]+)/) {
+ if (/^1\.\.([0-9]+)( todo ([\d ]+))?/) {
$max = $1;
+ %todo = map { $_ => 1 } split / /, $3 if $3;
$totmax += $max;
$files += 1;
$next = 1;
@@ -183,6 +206,7 @@ EOT
{
my($not, $num, $extra) = ($1, $2, $3);
my($istodo) = $extra =~ /^\s*#\s*TODO/ if $extra;
+ $istodo = 1 if $todo{$num};
if( $not && !$istodo ) {
$ok = 0;
diff --git a/t/io/utf8.t b/t/io/utf8.t
index ac5cde7a6e..fee0fe6ace 100755
--- a/t/io/utf8.t
+++ b/t/io/utf8.t
@@ -9,6 +9,8 @@ BEGIN {
}
}
+no utf8; # so that the naked 8-bit chars won't gripe under use utf8
+
$| = 1;
my $total_tests = 25;
if (ord('A') == 193) { $total_tests = 24; } # EBCDIC platforms do not warn on UTF-8
diff --git a/t/lib/1_compile.t b/t/lib/1_compile.t
index 2190e35321..eb2d70bc7e 100644
--- a/t/lib/1_compile.t
+++ b/t/lib/1_compile.t
@@ -106,6 +106,8 @@ sub compile_module {
return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
}
+# Add here modules that have their own test scripts and therefore
+# need not be test-compiled by 1_compile.t.
__DATA__
AnyDBM_File
AutoLoader
@@ -119,6 +121,7 @@ CGI
CGI::Pretty
CGI::Util
Carp
+Carp::Heavy
Class::ISA
Class::Struct
CPAN
@@ -138,6 +141,8 @@ Env
Errno
Exporter
Exporter::Heavy
+ExtUtils::Constant
+ExtUtils::MakeMaker
Fatal
Fcntl
File::Basename
@@ -150,6 +155,7 @@ File::Path
File::Spec
File::Spec::Functions
File::Temp
+File::stat
FileCache
FileHandle
Filter::Simple
@@ -158,7 +164,8 @@ FindBin
GDBM_File
Getopt::Long
Getopt::Std
-I18N:Collate
+I18N::LangTags
+I18N::Collate
IO::Dir
IO::File
IO::Handle
@@ -177,6 +184,7 @@ Locale::Constants
Locale::Country
Locale::Currency
Locale::Language
+Locale::Maketext
MIME::Base64
MIME::QuotedPrint
Math::BigFloat
@@ -186,8 +194,12 @@ Math::Trig
NDBM_File
NEXT
Net::hostent
+Net::netent
+Net::protoent
+Net::servent
ODBM_File
Opcode
+PerlIO
POSIX
Pod::Checker
Pod::Find
@@ -225,9 +237,15 @@ Tie::SubstrHash
Time::HiRes
Time::Local
Time::Piece
+Time::gmtime
+Time::localtime
+Time::tm
UNIVERSAL
+User::grent
+User::pwent
XS::Typemap
attrs
+autouse
base
bytes
charnames
diff --git a/t/lib/Test/fail.t b/t/lib/Test/fail.t
new file mode 100644
index 0000000000..b431502b8a
--- /dev/null
+++ b/t/lib/Test/fail.t
@@ -0,0 +1,93 @@
+# -*-perl-*-
+use strict;
+use vars qw($Expect);
+use Test qw($TESTOUT $ntest ok skip plan);
+plan tests => 14;
+
+open F, ">fails";
+$TESTOUT = *F{IO};
+
+my $r=0;
+{
+ # Shut up deprecated usage warning.
+ local $^W = 0;
+ $r |= skip(0,0);
+}
+$r |= ok(0);
+$r |= ok(0,1);
+$r |= ok(sub { 1+1 }, 3);
+$r |= ok(sub { 1+1 }, sub { 2 * 0});
+
+my @list = (0,0);
+$r |= ok @list, 1, "\@list=".join(',',@list);
+$r |= ok @list, 1, sub { "\@list=".join ',',@list };
+$r |= ok 'segmentation fault', '/bongo/';
+
+for (1..2) { $r |= ok(0); }
+
+$r |= ok(1, undef);
+$r |= ok(undef, 1);
+
+ok($r); # (failure==success :-)
+
+close F;
+$TESTOUT = *STDOUT{IO};
+$ntest = 1;
+
+open F, "fails";
+my $O;
+while (<F>) { $O .= $_; }
+close F;
+unlink "fails";
+
+ok join(' ', map { m/(\d+)/; $1 } grep /^not ok/, split /\n+/, $O),
+ join(' ', 1..13);
+
+my @got = split /not ok \d+\n/, $O;
+shift @got;
+
+$Expect =~ s/\n+$//;
+my @expect = split /\n\n/, $Expect;
+
+for (my $x=0; $x < @got; $x++) {
+ ok $got[$x], $expect[$x]."\n";
+}
+
+
+BEGIN {
+ $Expect = <<"EXPECT";
+# Failed test 1 in $0 at line 14
+
+# Failed test 2 in $0 at line 16
+
+# Test 3 got: '0' ($0 at line 17)
+# Expected: '1'
+
+# Test 4 got: '2' ($0 at line 18)
+# Expected: '3'
+
+# Test 5 got: '2' ($0 at line 19)
+# Expected: '0'
+
+# Test 6 got: '2' ($0 at line 22)
+# Expected: '1' (\@list=0,0)
+
+# Test 7 got: '2' ($0 at line 23)
+# Expected: '1' (\@list=0,0)
+
+# Test 8 got: 'segmentation fault' ($0 at line 24)
+# Expected: qr{bongo}
+
+# Failed test 9 in $0 at line 26
+
+# Failed test 10 in $0 at line 26 fail #2
+
+# Failed test 11 in $0 at line 28
+
+# Test 12 got: <UNDEF> ($0 at line 29)
+# Expected: '1'
+
+# Failed test 13 in $0 at line 31
+EXPECT
+
+}
diff --git a/t/lib/Test/mix.t b/t/lib/Test/mix.t
new file mode 100644
index 0000000000..d911689845
--- /dev/null
+++ b/t/lib/Test/mix.t
@@ -0,0 +1,17 @@
+# -*-perl-*-
+use strict;
+use Test;
+BEGIN { plan tests => 4, todo => [2,3] }
+
+ok(sub {
+ my $r = 0;
+ for (my $x=0; $x < 10; $x++) {
+ $r += $x*($r+1);
+ }
+ $r
+ }, 3628799);
+
+ok(0);
+ok(1);
+
+skip(1,0);
diff --git a/t/lib/Test/onfail.t b/t/lib/Test/onfail.t
new file mode 100644
index 0000000000..dce4373401
--- /dev/null
+++ b/t/lib/Test/onfail.t
@@ -0,0 +1,31 @@
+# -*-perl-*-
+
+use strict;
+use Test qw($ntest plan ok $TESTOUT);
+use vars qw($mycnt);
+
+BEGIN { plan test => 6, onfail => \&myfail }
+
+$mycnt = 0;
+
+my $why = "zero != one";
+# sneak in a test that Test::Harness wont see
+open J, ">junk";
+$TESTOUT = *J{IO};
+ok(0, 1, $why);
+$TESTOUT = *STDOUT{IO};
+close J;
+unlink "junk";
+$ntest = 1;
+
+sub myfail {
+ my ($f) = @_;
+ ok(@$f, 1);
+
+ my $t = $$f[0];
+ ok($$t{diagnostic}, $why);
+ ok($$t{'package'}, 'main');
+ ok($$t{repetition}, 1);
+ ok($$t{result}, 0);
+ ok($$t{expected}, 1);
+}
diff --git a/t/lib/Test/qr.t b/t/lib/Test/qr.t
new file mode 100644
index 0000000000..ea40f87308
--- /dev/null
+++ b/t/lib/Test/qr.t
@@ -0,0 +1,13 @@
+#!./perl -w
+
+use strict;
+BEGIN {
+ if ($] < 5.005) {
+ print "1..0\n";
+ print "ok 1 # skipped; this test requires at least perl 5.005\n";
+ exit;
+ }
+}
+use Test; plan tests => 1;
+
+ok 'abc', qr/b/;
diff --git a/t/lib/Test/skip.t b/t/lib/Test/skip.t
new file mode 100644
index 0000000000..7db35e65dc
--- /dev/null
+++ b/t/lib/Test/skip.t
@@ -0,0 +1,40 @@
+# -*-perl-*-
+use strict;
+use Test qw($TESTOUT $ntest plan ok skip); plan tests => 6;
+
+open F, ">skips" or die "open skips: $!";
+$TESTOUT = *F{IO};
+
+skip(1, 0); #should skip
+
+my $skipped=1;
+skip('hop', sub { $skipped = 0 });
+skip(sub {'jump'}, sub { $skipped = 0 });
+skip('skipping stones is more fun', sub { $skipped = 0 });
+
+close F;
+
+$TESTOUT = *STDOUT{IO};
+$ntest = 1;
+open F, "skips" or die "open skips: $!";
+
+ok $skipped, 1, 'not skipped?';
+
+my @T = <F>;
+chop @T;
+my @expect = split /\n+/, join('',<DATA>);
+ok @T, 4;
+for (my $x=0; $x < @T; $x++) {
+ ok $T[$x], $expect[$x];
+}
+
+END { close F; unlink "skips" }
+
+__DATA__
+ok 1 # skip
+
+ok 2 # skip hop
+
+ok 3 # skip jump
+
+ok 4 # skip skipping stones is more fun
diff --git a/t/lib/Test/success.t b/t/lib/Test/success.t
new file mode 100644
index 0000000000..a580f0a567
--- /dev/null
+++ b/t/lib/Test/success.t
@@ -0,0 +1,11 @@
+# -*-perl-*-
+use strict;
+use Test;
+BEGIN { plan tests => 11 }
+
+ok(ok(1));
+ok(ok('fixed', 'fixed'));
+ok(skip(1,0));
+ok(undef, undef);
+ok(ok 'the brown fox jumped over the lazy dog', '/lazy/');
+ok(ok 'the brown fox jumped over the lazy dog', 'm,fox,');
diff --git a/t/lib/Test/todo.t b/t/lib/Test/todo.t
new file mode 100644
index 0000000000..ae02a04f6b
--- /dev/null
+++ b/t/lib/Test/todo.t
@@ -0,0 +1,13 @@
+# -*-perl-*-
+use strict;
+use Test;
+BEGIN {
+ my $tests = 5;
+ plan tests => $tests, todo => [1..$tests];
+}
+
+ok(0);
+ok(1);
+ok(0,1);
+ok(0,1,"need more tuits");
+ok(1,1);
diff --git a/t/lib/carp.t b/t/lib/carp.t
new file mode 100644
index 0000000000..a318c19751
--- /dev/null
+++ b/t/lib/carp.t
@@ -0,0 +1,53 @@
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use Carp qw(carp cluck croak confess);
+
+print "1..7\n";
+
+print "ok 1\n";
+
+$SIG{__WARN__} = sub {
+ print "ok $1\n"
+ if $_[0] =~ m!ok (\d+)$! };
+
+carp "ok 2\n";
+
+$SIG{__WARN__} = sub {
+ print "ok $1\n"
+ if $_[0] =~ m!(\d+) at .+\b(?i:carp\.t) line \d+$! };
+
+carp 3;
+
+sub sub_4 {
+
+$SIG{__WARN__} = sub {
+ print "ok $1\n"
+ if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\tmain::sub_4\(\) called at .+\b(?i:carp\.t) line \d+$! };
+
+cluck 4;
+
+}
+
+sub_4;
+
+$SIG{__DIE__} = sub {
+ print "ok $1\n"
+ if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\teval \Q{...}\E called at .+\b(?i:carp\.t) line \d+$! };
+
+eval { croak 5 };
+
+sub sub_6 {
+ $SIG{__DIE__} = sub {
+ print "ok $1\n"
+ if $_[0] =~ m!^(\d+) at .+\b(?i:carp\.t) line \d+\n\teval \Q{...}\E called at .+\b(?i:carp\.t) line \d+\n\tmain::sub_6\(\) called at .+\b(?i:carp\.t) line \d+$! };
+
+ eval { confess 6 };
+}
+
+sub_6;
+
+print "ok 7\n";
+
diff --git a/t/lib/charnames.t b/t/lib/charnames.t
index 07c91e6682..124dad0971 100644
--- a/t/lib/charnames.t
+++ b/t/lib/charnames.t
@@ -117,6 +117,8 @@ sub to_bytes {
{
# 20001114.001
+ no utf8; # so that the naked 8-bit character won't gripe under use utf8
+
if (ord("Ä") == 0xc4) { # Try to do this only on Latin-1.
use charnames ':full';
my $text = "\N{LATIN CAPITAL LETTER A WITH DIAERESIS}";
diff --git a/t/lib/extutils.t b/t/lib/extutils.t
new file mode 100644
index 0000000000..cc34740b42
--- /dev/null
+++ b/t/lib/extutils.t
@@ -0,0 +1,229 @@
+#!./perl -w
+
+print "1..10\n";
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use warnings;
+use strict;
+use ExtUtils::MakeMaker;
+use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
+use Config;
+
+my $runperl = $^X;
+
+$| = 1;
+
+my $dir = "ext-$$";
+my @files;
+
+print "# $dir being created...\n";
+mkdir $dir, 0777 or die "mkdir: $!\n";
+
+use File::Spec::Functions;
+
+END {
+ use File::Path;
+ print "# $dir being removed...\n";
+ rmtree($dir);
+}
+
+my @names = ("THREE", {name=>"OK4", type=>"PV",},
+ {name=>"OK5", type=>"PVN",
+ value=>['"not ok 5\\n\\0ok 5\\n"', 15]},
+ {name => "FARTHING", type=>"NV"},
+ {name => "NOT_ZERO", type=>"UV", value=>"~(UV)0"});
+
+my @names_only = map {(ref $_) ? $_->{name} : $_} @names;
+
+my $package = "ExtTest";
+################ Header
+my $header = catfile($dir, "test.h");
+push @files, "test.h";
+open FH, ">$header" or die "open >$header: $!\n";
+print FH <<'EOT';
+#define THREE 3
+#define OK4 "ok 4\n"
+#define OK5 1
+#define FARTHING 0.25
+#define NOT_ZERO 1
+EOT
+close FH or die "close $header: $!\n";
+
+################ XS
+my $xs = catfile($dir, "$package.xs");
+push @files, "$package.xs";
+open FH, ">$xs" or die "open >$xs: $!\n";
+
+print FH <<'EOT';
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+EOT
+
+print FH "#include \"test.h\"\n\n";
+print FH constant_types(); # macro defs
+my $types = {};
+foreach (C_constant (undef, "IV", $types, undef, undef, @names) ) {
+ print FH $_, "\n"; # C constant subs
+}
+print FH "MODULE = $package PACKAGE = $package\n";
+print FH "PROTOTYPES: ENABLE\n";
+print FH XS_constant ($package, $types); # XS for ExtTest::constant
+close FH or die "close $xs: $!\n";
+
+################ PM
+my $pm = catfile($dir, "$package.pm");
+push @files, "$package.pm";
+open FH, ">$pm" or die "open >$pm: $!\n";
+print FH "package $package;\n";
+print FH "use $];\n";
+
+print FH <<'EOT';
+
+use strict;
+use warnings;
+use Carp;
+
+require Exporter;
+require DynaLoader;
+use AutoLoader;
+use vars qw ($VERSION @ISA @EXPORT_OK);
+
+$VERSION = '0.01';
+@ISA = qw(Exporter DynaLoader);
+@EXPORT_OK = qw(
+EOT
+
+print FH "\t$_\n" foreach (@names_only);
+print FH ");\n";
+print FH autoload ($package, $]);
+print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
+close FH or die "close $pm: $!\n";
+
+################ test.pl
+my $testpl = catfile($dir, "test.pl");
+push @files, "test.pl";
+open FH, ">$testpl" or die "open >$testpl: $!\n";
+
+print FH "use $package qw(@names_only);\n";
+print FH <<'EOT';
+
+my $three = THREE;
+if ($three == 3) {
+ print "ok 3\n";
+} else {
+ print "not ok 3 # $three\n";
+}
+
+print OK4;
+
+$_ = OK5;
+s/.*\0//s;
+print;
+
+my $farthing = FARTHING;
+if ($farthing == 0.25) {
+ print "ok 6\n";
+} else {
+ print "not ok 6 # $farthing\n";
+}
+
+my $not_zero = NOT_ZERO;
+if ($not_zero > 0 && $not_zero == ~0) {
+ print "ok 7\n";
+} else {
+ print "not ok 7 # \$not_zero=$not_zero ~0=" . (~0) . "\n";
+}
+
+
+EOT
+
+close FH or die "close $testpl: $!\n";
+
+################ dummy Makefile.PL
+# Keep the dependancy in the Makefile happy
+my $makefilePL = catfile($dir, "Makefile.PL");
+push @files, "Makefile.PL";
+open FH, ">$makefilePL" or die "open >$makefilePL: $!\n";
+close FH or die "close $makefilePL: $!\n";
+
+chdir $dir or die $!; push @INC, '../../lib';
+END {chdir ".." or warn $!};
+
+# Grr. MakeMaker hardwired to write its message to STDOUT.
+print "# ";
+WriteMakefile(
+ 'NAME' => $package,
+ 'VERSION_FROM' => "$package.pm", # finds $VERSION
+ ($] >= 5.005 ?
+ (#ABSTRACT_FROM => "$package.pm", # XXX add this
+ AUTHOR => $0) : ())
+ );
+if (-f "Makefile") {
+ print "ok 1\n";
+} else {
+ print "not ok 1\n";
+}
+push @files, "Makefile.old"; # Renamed by make clean
+
+my $make = $Config{make};
+
+$make = $ENV{MAKE} if exists $ENV{MAKE};
+
+my $makeout;
+
+print "# make = '$make'\n";
+$makeout = `$make`;
+if ($?) {
+ print "not ok 2 # $make failed: $?\n";
+ exit($?);
+} else {
+ print "ok 2\n";
+}
+
+my $maketest = "$make test";
+print "# make = '$maketest'\n";
+$makeout = `$maketest`;
+if ($?) {
+ print "not ok 8 # $make failed: $?\n";
+} else {
+ # Perl babblings
+ $makeout =~ s/^\s*PERL_DL_NONLAZY=.+?\n//m;
+
+ # GNU make babblings
+ $makeout =~ s/^\w*?make.+?(?:entering|leaving) directory.+?\n//mig;
+
+ print $makeout;
+ print "ok 8\n";
+}
+
+my $makeclean = "$make clean";
+print "# make = '$makeclean'\n";
+$makeout = `$makeclean`;
+if ($?) {
+ print "not ok 9 # $make failed: $?\n";
+} else {
+ print "ok 9\n";
+}
+
+foreach (@files) {
+ unlink $_ or warn "unlink $_: $!";
+}
+
+my $fail;
+opendir DIR, "." or die "opendir '.': $!";
+while (defined (my $entry = readdir DIR)) {
+ next if $entry =~ /^\.\.?$/;
+ print "# Extra file '$entry'\n";
+ $fail = 1;
+}
+closedir DIR or warn "closedir '.': $!";
+if ($fail) {
+ print "not ok 10\n";
+} else {
+ print "ok 10\n";
+}
diff --git a/t/lib/filestat.t b/t/lib/filestat.t
new file mode 100644
index 0000000000..ac6d95f745
--- /dev/null
+++ b/t/lib/filestat.t
@@ -0,0 +1,70 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $hasst;
+ eval { my @n = stat "TEST" };
+ $hasst = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($hasst) { print "1..0 # Skip: no stat\n"; exit 0 }
+ use Config;
+ $hasst = 0 unless $Config{'i_sysstat'} eq 'define';
+ unless ($hasst) { print "1..0 # Skip: no sys/stat.h\n"; exit 0 }
+}
+
+BEGIN {
+ our @stat = stat "TEST"; # This is the function stat.
+ unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 }
+}
+
+print "1..14\n";
+
+use File::stat;
+
+print "ok 1\n";
+
+my $stat = stat "TEST"; # This is the OO stat.
+
+print "not " unless $stat->dev == $stat[ 0];
+print "ok 2\n";
+
+print "not " unless $stat->ino == $stat[ 1];
+print "ok 3\n";
+
+print "not " unless $stat->mode == $stat[ 2];
+print "ok 4\n";
+
+print "not " unless $stat->nlink == $stat[ 3];
+print "ok 5\n";
+
+print "not " unless $stat->uid == $stat[ 4];
+print "ok 6\n";
+
+print "not " unless $stat->gid == $stat[ 5];
+print "ok 7\n";
+
+print "not " unless $stat->rdev == $stat[ 6];
+print "ok 8\n";
+
+print "not " unless $stat->size == $stat[ 7];
+print "ok 9\n";
+
+print "not " unless $stat->atime == $stat[ 8];
+print "ok 10\n";
+
+print "not " unless $stat->mtime == $stat[ 9];
+print "ok 11\n";
+
+print "not " unless $stat->ctime == $stat[10];
+print "ok 12\n";
+
+print "not " unless $stat->blksize == $stat[11];
+print "ok 13\n";
+
+print "not " unless $stat->blocks == $stat[12];
+print "ok 14\n";
+
+# Testing pretty much anything else is unportable.
diff --git a/t/lib/i18n-langtags.t b/t/lib/i18n-langtags.t
new file mode 100644
index 0000000000..06c178ef27
--- /dev/null
+++ b/t/lib/i18n-langtags.t
@@ -0,0 +1,45 @@
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+######################### We start with some black magic to print on failure.
+require 5;
+
+use strict;
+use Test;
+BEGIN { plan tests => 23 };
+BEGIN { ok 1 }
+use I18N::LangTags qw(is_language_tag same_language_tag
+ extract_language_tags super_languages
+ similarity_language_tag is_dialect_of
+ locale2language_tag alternate_language_tags
+ encode_language_tag
+ );
+
+ok !is_language_tag('');
+ok is_language_tag('fr');
+ok is_language_tag('fr-ca');
+ok is_language_tag('fr-CA');
+ok !is_language_tag('fr-CA-');
+ok !is_language_tag('fr_CA');
+ok is_language_tag('fr-ca-joual');
+ok !is_language_tag('frca');
+ok is_language_tag('nav');
+ok is_language_tag('nav-shiprock');
+ok !is_language_tag('nav-ceremonial'); # subtag too long
+ok !is_language_tag('x');
+ok !is_language_tag('i');
+ok is_language_tag('i-borg'); # NB: fictitious tag
+ok is_language_tag('x-borg');
+ok is_language_tag('x-borg-prot5123');
+ok same_language_tag('x-borg-prot5123', 'i-BORG-Prot5123' );
+ok !same_language_tag('en', 'en-us' );
+
+ok 0 == similarity_language_tag('en-ca', 'fr-ca');
+ok 1 == similarity_language_tag('en-ca', 'en-us');
+ok 2 == similarity_language_tag('en-us-southern', 'en-us-western');
+ok 2 == similarity_language_tag('en-us-southern', 'en-us');
+
+# print "So there!\n";
+
diff --git a/t/lib/lc-language.t b/t/lib/lc-language.t
index 6a70b79ef9..9facd3509d 100644
--- a/t/lib/lc-language.t
+++ b/t/lib/lc-language.t
@@ -10,6 +10,8 @@ BEGIN {
use Locale::Language;
+no utf8; # so that the naked 8-bit characters won't gripe under use utf8
+
#-----------------------------------------------------------------------
# This is an array of tests. Each test is eval'd as an expression.
# If it evaluates to FALSE, then "not ok N" is printed for the test,
diff --git a/t/lib/lc-maketext.t b/t/lib/lc-maketext.t
new file mode 100644
index 0000000000..743d8eecbd
--- /dev/null
+++ b/t/lib/lc-maketext.t
@@ -0,0 +1,37 @@
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN { $| = 1; print "1..3\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use Locale::Maketext 1.01;
+print "# Perl v$], Locale::Maketext v$Locale::Maketext::VERSION\n";
+$loaded = 1;
+print "ok 1\n";
+{
+ package Woozle;
+ @ISA = ('Locale::Maketext');
+ sub dubbil { return $_[1] * 2 }
+}
+{
+ package Woozle::elx;
+ @ISA = ('Woozle');
+ %Lexicon = (
+ 'd2' => 'hum [dubbil,_1]',
+ );
+}
+
+$lh = Woozle->get_handle('elx');
+if($lh) {
+ print "ok 2\n";
+ my $x = $lh->maketext('d2', 7);
+ if($x eq "hum 14") {
+ print "ok 3\n";
+ } else {
+ print "not ok 3\n (got \"$x\")\n";
+ }
+} else {
+ print "not ok 2\n";
+}
+#Shazam!
diff --git a/t/lib/net-nent.t b/t/lib/net-nent.t
new file mode 100644
index 0000000000..e73122ccc4
--- /dev/null
+++ b/t/lib/net-nent.t
@@ -0,0 +1,36 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $hasne;
+ eval { my @n = getnetbyname "loopback" };
+ $hasne = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($hasne) { print "1..0 # Skip: no getnetbyname\n"; exit 0 }
+ use Config;
+ $hasne = 0 unless $Config{'i_netdb'} eq 'define';
+ unless ($hasne) { print "1..0 # Skip: no netdb.h\n"; exit 0 }
+}
+
+BEGIN {
+ our @netent = getnetbyname "loopback"; # This is the function getnetbyname.
+ unless (@netent) { print "1..0 # Skip: no loopback net\n"; exit 0 }
+}
+
+print "1..2\n";
+
+use Net::netent;
+
+print "ok 1\n";
+
+my $netent = getnetbyname "loopback"; # This is the OO getnetbyname.
+
+print "not " unless $netent->name eq $netent[0];
+print "ok 2\n";
+
+# Testing pretty much anything else is unportable;
+# e.g. the canonical name of the "loopback" net may be "loop".
+
diff --git a/t/lib/net-pent.t b/t/lib/net-pent.t
new file mode 100644
index 0000000000..6c5a1547b3
--- /dev/null
+++ b/t/lib/net-pent.t
@@ -0,0 +1,38 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $haspe;
+ eval { my @n = getprotobyname "tcp" };
+ $haspe = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($haspe) { print "1..0 # Skip: no getprotobyname\n"; exit 0 }
+ use Config;
+ $haspe = 0 unless $Config{'i_netdb'} eq 'define';
+ unless ($haspe) { print "1..0 # Skip: no netdb.h\n"; exit 0 }
+}
+
+BEGIN {
+ our @protoent = getprotobyname "tcp"; # This is the function getprotobyname.
+ unless (@protoent) { print "1..0 # Skip: no tcp protocol\n"; exit 0 }
+}
+
+print "1..3\n";
+
+use Net::protoent;
+
+print "ok 1\n";
+
+my $protoent = getprotobyname "tcp"; # This is the OO getprotobyname.
+
+print "not " unless $protoent->name eq $protoent[0];
+print "ok 2\n";
+
+print "not " unless $protoent->proto == $protoent[2];
+print "ok 3\n";
+
+# Testing pretty much anything else is unportable.
+
diff --git a/t/lib/net-sent.t b/t/lib/net-sent.t
new file mode 100644
index 0000000000..ef4a04dee8
--- /dev/null
+++ b/t/lib/net-sent.t
@@ -0,0 +1,38 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $hasse;
+ eval { my @n = getservbyname "echo", "tcp" };
+ $hasse = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($hasse) { print "1..0 # Skip: no getservbyname\n"; exit 0 }
+ use Config;
+ $hasse = 0 unless $Config{'i_netdb'} eq 'define';
+ unless ($hasse) { print "1..0 # Skip: no netdb.h\n"; exit 0 }
+}
+
+BEGIN {
+ our @servent = getservbyname "echo", "tcp"; # This is the function getservbyname.
+ unless (@servent) { print "1..0 # Skip: no echo service\n"; exit 0 }
+}
+
+print "1..3\n";
+
+use Net::servent;
+
+print "ok 1\n";
+
+my $servent = getservbyname "echo", "tcp"; # This is the OO getservbyname.
+
+print "not " unless $servent->name eq $servent[0];
+print "ok 2\n";
+
+print "not " unless $servent->port == $servent[2];
+print "ok 3\n";
+
+# Testing pretty much anything else is unportable.
+
diff --git a/t/lib/perlio.t b/t/lib/perlio.t
new file mode 100644
index 0000000000..d71ab8ec4f
--- /dev/null
+++ b/t/lib/perlio.t
@@ -0,0 +1,90 @@
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bPerlIO\b/) {
+ print "1..0 # Skip: PerlIO was not built\n";
+ exit 0;
+ }
+}
+
+use PerlIO;
+
+print "1..19\n";
+
+print "ok 1\n";
+
+my $txt = "txt$$";
+my $bin = "bin$$";
+my $utf = "utf$$";
+
+my $txtfh;
+my $binfh;
+my $utffh;
+
+print "not " unless open($txtfh, ">:crlf", $txt);
+print "ok 2\n";
+
+print "not " unless open($binfh, ">:raw", $bin);
+print "ok 3\n";
+
+print "not " unless open($utffh, ">:utf8", $utf);
+print "ok 4\n";
+
+print $txtfh "foo\n";
+print $txtfh "bar\n";
+print "not " unless close($txtfh);
+print "ok 5\n";
+
+print $binfh "foo\n";
+print $binfh "bar\n";
+print "not " unless close($binfh);
+print "ok 6\n";
+
+print $utffh "foo\x{ff}\n";
+print $utffh "bar\x{abcd}\n";
+print "not " unless close($utffh);
+print "ok 7\n";
+
+print "not " unless open($txtfh, "<:crlf", $txt);
+print "ok 8\n";
+
+print "not " unless open($binfh, "<:raw", $bin);
+print "ok 9\n";
+
+print "not " unless open($utffh, "<:utf8", $utf);
+print "ok 10\n";
+
+print "not " unless <$txtfh> eq "foo\n" && <$txtfh> eq "bar\n";
+print "ok 11\n";
+
+print "not " unless <$binfh> eq "foo\n" && <$binfh> eq "bar\n";
+print "ok 12\n";
+
+print "not " unless <$utffh> eq "foo\x{ff}\n" && <$utffh> eq "bar\x{abcd}\n";
+print "ok 13\n";
+
+print "not " unless eof($txtfh);
+print "ok 14\n";
+
+print "not " unless eof($binfh);
+print "ok 15\n";
+
+print "not " unless eof($utffh);
+print "ok 16\n";
+
+print "not " unless close($txtfh);
+print "ok 17\n";
+
+print "not " unless close($binfh);
+print "ok 18\n";
+
+print "not " unless close($utffh);
+print "ok 19\n";
+
+END {
+ 1 while unlink $txt;
+ 1 while unlink $bin;
+ 1 while unlink $utf;
+}
+
diff --git a/t/lib/sigaction.t b/t/lib/sigaction.t
index 8b0a907e44..1815b19510 100644
--- a/t/lib/sigaction.t
+++ b/t/lib/sigaction.t
@@ -44,7 +44,7 @@ my $oldaction=POSIX::SigAction->new('::bar', new POSIX::SigSet(), 0);
}
if($oldaction->{HANDLER} eq 'DEFAULT' ||
- (! -t STDIN && $oldaction->{HANDLER} eq 'IGNORE'))
+ $oldaction->{HANDLER} eq 'IGNORE')
{ print "ok 2\n" } else { print "not ok 2 # ", $oldaction->{HANDLER}, "\n"}
print $SIG{HUP} eq '::foo' ? "ok 3\n" : "not ok 3\n";
diff --git a/t/lib/test-harness.t b/t/lib/test-harness.t
index 4ce6e1774a..a4c423ddd3 100644
--- a/t/lib/test-harness.t
+++ b/t/lib/test-harness.t
@@ -1,15 +1,16 @@
-#!./perl
+#!perl
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
}
+use strict;
# For shutting up Test::Harness.
package My::Dev::Null;
use Tie::Handle;
-@ISA = qw(Tie::StdHandle);
+@My::Dev::Null::ISA = qw(Tie::StdHandle);
sub WRITE { }
@@ -41,6 +42,7 @@ sub eqhash {
return $ok;
}
+use vars qw($Total_tests %samples);
my $loaded;
BEGIN { $| = 1; $^W = 1; }
@@ -56,7 +58,7 @@ BEGIN {
simple => {
bonus => 0,
max => 5,
- ok => 5,
+ 'ok' => 5,
files => 1,
bad => 0,
good => 1,
@@ -67,7 +69,7 @@ BEGIN {
simple_fail => {
bonus => 0,
max => 5,
- ok => 3,
+ 'ok' => 3,
files => 1,
bad => 1,
good => 0,
@@ -78,7 +80,7 @@ BEGIN {
descriptive => {
bonus => 0,
max => 5,
- ok => 5,
+ 'ok' => 5,
files => 1,
bad => 0,
good => 1,
@@ -89,7 +91,7 @@ BEGIN {
no_nums => {
bonus => 0,
max => 5,
- ok => 4,
+ 'ok' => 4,
files => 1,
bad => 1,
good => 0,
@@ -100,7 +102,7 @@ BEGIN {
todo => {
bonus => 1,
max => 5,
- ok => 5,
+ 'ok' => 5,
files => 1,
bad => 0,
good => 1,
@@ -111,7 +113,7 @@ BEGIN {
skip => {
bonus => 0,
max => 5,
- ok => 5,
+ 'ok' => 5,
files => 1,
bad => 0,
good => 1,
@@ -123,7 +125,7 @@ BEGIN {
combined => {
bonus => 1,
max => 10,
- ok => 8,
+ 'ok' => 8,
files => 1,
bad => 1,
good => 0,
@@ -134,7 +136,7 @@ BEGIN {
duplicates => {
bonus => 0,
max => 10,
- ok => 11,
+ 'ok' => 11,
files => 1,
bad => 1,
good => 0,
@@ -145,7 +147,7 @@ BEGIN {
header_at_end => {
bonus => 0,
max => 4,
- ok => 4,
+ 'ok' => 4,
files => 1,
bad => 0,
good => 1,
@@ -156,7 +158,7 @@ BEGIN {
skip_all => {
bonus => 0,
max => 0,
- ok => 0,
+ 'ok' => 0,
files => 1,
bad => 0,
good => 1,
@@ -167,7 +169,7 @@ BEGIN {
with_comments => {
bonus => 2,
max => 5,
- ok => 5,
+ 'ok' => 5,
files => 1,
bad => 0,
good => 1,
@@ -183,12 +185,12 @@ BEGIN {
tie *NULL, 'My::Dev::Null' or die $!;
while (my($test, $expect) = each %samples) {
- # _runtests() runs the tests but skips the formatting.
+ # _run_all_tests() runs the tests but skips the formatting.
my($totals, $failed);
eval {
- select NULL; # _runtests() isn't as quiet as it should be.
+ select NULL; # _run_all_tests() isn't as quiet as it should be.
($totals, $failed) =
- Test::Harness::_runtests("lib/sample-tests/$test");
+ Test::Harness::_run_all_tests("lib/sample-tests/$test");
};
select STDOUT;
diff --git a/t/lib/time-gmtime.t b/t/lib/time-gmtime.t
new file mode 100644
index 0000000000..853ec3b6e3
--- /dev/null
+++ b/t/lib/time-gmtime.t
@@ -0,0 +1,57 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $hasgm;
+ eval { my $n = gmtime 0 };
+ $hasgm = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($hasgm) { print "1..0 # Skip: no gmtime\n"; exit 0 }
+}
+
+BEGIN {
+ our @gmtime = gmtime 0; # This is the function gmtime.
+ unless (@gmtime) { print "1..0 # Skip: gmtime failed\n"; exit 0 }
+}
+
+print "1..10\n";
+
+use Time::gmtime;
+
+print "ok 1\n";
+
+my $gmtime = gmtime 0 ; # This is the OO gmtime.
+
+print "not " unless $gmtime->sec == $gmtime[0];
+print "ok 2\n";
+
+print "not " unless $gmtime->min == $gmtime[1];
+print "ok 3\n";
+
+print "not " unless $gmtime->hour == $gmtime[2];
+print "ok 4\n";
+
+print "not " unless $gmtime->mday == $gmtime[3];
+print "ok 5\n";
+
+print "not " unless $gmtime->mon == $gmtime[4];
+print "ok 6\n";
+
+print "not " unless $gmtime->year == $gmtime[5];
+print "ok 7\n";
+
+print "not " unless $gmtime->wday == $gmtime[6];
+print "ok 8\n";
+
+print "not " unless $gmtime->yday == $gmtime[7];
+print "ok 9\n";
+
+print "not " unless $gmtime->isdst == $gmtime[8];
+print "ok 10\n";
+
+
+
+
diff --git a/t/lib/time-localtime.t b/t/lib/time-localtime.t
new file mode 100644
index 0000000000..357615c780
--- /dev/null
+++ b/t/lib/time-localtime.t
@@ -0,0 +1,57 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $haslocal;
+ eval { my $n = localtime 0 };
+ $haslocal = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($haslocal) { print "1..0 # Skip: no localtime\n"; exit 0 }
+}
+
+BEGIN {
+ our @localtime = localtime 0; # This is the function localtime.
+ unless (@localtime) { print "1..0 # Skip: localtime failed\n"; exit 0 }
+}
+
+print "1..10\n";
+
+use Time::localtime;
+
+print "ok 1\n";
+
+my $localtime = localtime 0 ; # This is the OO localtime.
+
+print "not " unless $localtime->sec == $localtime[0];
+print "ok 2\n";
+
+print "not " unless $localtime->min == $localtime[1];
+print "ok 3\n";
+
+print "not " unless $localtime->hour == $localtime[2];
+print "ok 4\n";
+
+print "not " unless $localtime->mday == $localtime[3];
+print "ok 5\n";
+
+print "not " unless $localtime->mon == $localtime[4];
+print "ok 6\n";
+
+print "not " unless $localtime->year == $localtime[5];
+print "ok 7\n";
+
+print "not " unless $localtime->wday == $localtime[6];
+print "ok 8\n";
+
+print "not " unless $localtime->yday == $localtime[7];
+print "ok 9\n";
+
+print "not " unless $localtime->isdst == $localtime[8];
+print "ok 10\n";
+
+
+
+
diff --git a/t/lib/time-piece.t b/t/lib/time-piece.t
index bf41a7ddd3..c62e36d95e 100644
--- a/t/lib/time-piece.t
+++ b/t/lib/time-piece.t
@@ -314,7 +314,9 @@ print "ok 84\n";
print "not " unless Time::Piece::_is_leap_year(1904);
print "ok 85\n";
-my %T = $t->strptime("%T", "12:34:56");
+use Time::Piece 'strptime';
+
+my %T = strptime("%T", "12:34:56");
print "not " unless keys %T == 3 && $T{H} == 12 && $T{M} == 34 && $T{S} == 56;
print "ok 86\n";
diff --git a/t/lib/user-grent.t b/t/lib/user-grent.t
new file mode 100644
index 0000000000..760b814d54
--- /dev/null
+++ b/t/lib/user-grent.t
@@ -0,0 +1,44 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $hasgr;
+ eval { my @n = getgrgid 0 };
+ $hasgr = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($hasgr) { print "1..0 # Skip: no getgrgid\n"; exit 0 }
+ use Config;
+ $hasgr = 0 unless $Config{'i_grp'} eq 'define';
+ unless ($hasgr) { print "1..0 # Skip: no grp.h\n"; exit 0 }
+}
+
+BEGIN {
+ our @grent = getgrgid 0; # This is the function getgrgid.
+ unless (@grent) { print "1..0 # Skip: no gid 0\n"; exit 0 }
+}
+
+print "1..5\n";
+
+use User::grent;
+
+print "ok 1\n";
+
+my $grent = getgrgid 0; # This is the OO getgrgid.
+
+print "not " unless $grent->gid == 0;
+print "ok 2\n";
+
+print "not " unless $grent->name == $grent[0];
+print "ok 3\n";
+
+print "not " unless $grent->passwd eq $grent[1];
+print "ok 4\n";
+
+print "not " unless $grent->gid == $grent[2];
+print "ok 5\n";
+
+# Testing pretty much anything else is unportable.
+
diff --git a/t/lib/user-pwent.t b/t/lib/user-pwent.t
new file mode 100644
index 0000000000..e274265bd1
--- /dev/null
+++ b/t/lib/user-pwent.t
@@ -0,0 +1,63 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+BEGIN {
+ our $haspw;
+ eval { my @n = getpwuid 0 };
+ $haspw = 1 unless $@ && $@ =~ /unimplemented/;
+ unless ($haspw) { print "1..0 # Skip: no getpwuid\n"; exit 0 }
+ use Config;
+ $haspw = 0 unless $Config{'i_pwd'} eq 'define';
+ unless ($haspw) { print "1..0 # Skip: no pwd.h\n"; exit 0 }
+}
+
+BEGIN {
+ our @pwent = getpwuid 0; # This is the function getpwuid.
+ unless (@pwent) { print "1..0 # Skip: no uid 0\n"; exit 0 }
+}
+
+print "1..9\n";
+
+use User::pwent;
+
+print "ok 1\n";
+
+my $pwent = getpwuid 0; # This is the OO getpwuid.
+
+print "not " unless $pwent->uid == 0;
+print "ok 2\n";
+
+print "not " unless $pwent->name == $pwent[0];
+print "ok 3\n";
+
+print "not " unless $pwent->passwd eq $pwent[1];
+print "ok 4\n";
+
+print "not " unless $pwent->uid == $pwent[2];
+print "ok 5\n";
+
+print "not " unless $pwent->gid == $pwent[3];
+print "ok 6\n";
+
+# The quota and comment fields are unportable.
+
+print "not " unless $pwent->gecos eq $pwent[6];
+print "ok 7\n";
+
+print "not " unless $pwent->dir eq $pwent[7];
+print "ok 8\n";
+
+print "not " unless $pwent->shell eq $pwent[8];
+print "ok 9\n";
+
+# The expire field is unportable.
+
+# Testing pretty much anything else is unportable:
+# there maybe more than one username with uid 0;
+# uid 0's home directory may be "/" or "/root' or something else,
+# and so on.
+
diff --git a/t/op/gmagic.t b/t/op/gmagic.t
new file mode 100644
index 0000000000..ab6d2ee3e6
--- /dev/null
+++ b/t/op/gmagic.t
@@ -0,0 +1,83 @@
+#!./perl -w
+
+BEGIN {
+ $| = 1;
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+print "1..18\n";
+
+my $t = 1;
+tie my $c => 'Tie::Monitor';
+
+sub ok {
+ my($ok, $got, $exp, $rexp, $wexp) = @_;
+ my($rgot, $wgot) = (tied $c)->init(0);
+ print $ok ? "ok $t\n" : "# expected $exp, got $got\nnot ok $t\n";
+ ++$t;
+ if ($rexp == $rgot && $wexp == $wgot) {
+ print "ok $t\n";
+ } else {
+ print "# read $rgot expecting $rexp\n" if $rgot != $rexp;
+ print "# wrote $wgot expecting $wexp\n" if $wgot != $wexp;
+ print "not ok $t\n";
+ }
+ ++$t;
+}
+
+sub ok_undef { ok(!defined($_[0]), shift, "undef", @_) }
+sub ok_numeric { ok($_[0] == $_[1], @_) }
+sub ok_string { ok($_[0] eq $_[1], @_) }
+
+my($r, $s);
+# the thing itself
+ok_numeric($r = $c + 0, 0, 1, 0);
+ok_string($r = "$c", '0', 1, 0);
+
+# concat
+ok_string($c . 'x', '0x', 1, 0);
+ok_string('x' . $c, 'x0', 1, 0);
+$s = $c . $c;
+ok_string($s, '00', 2, 0);
+$r = 'x';
+$s = $c = $r . 'y';
+ok_string($s, 'xy', 1, 1);
+$s = $c = $c . 'x';
+ok_string($s, '0x', 2, 1);
+$s = $c = 'x' . $c;
+ok_string($s, 'x0', 2, 1);
+$s = $c = $c . $c;
+ok_string($s, '00', 3, 1);
+
+# adapted from Tie::Counter by Abigail
+package Tie::Monitor;
+
+sub TIESCALAR {
+ my($class, $value) = @_;
+ bless {
+ read => 0,
+ write => 0,
+ values => [ 0 ],
+ };
+}
+
+sub FETCH {
+ my $self = shift;
+ ++$self->{read};
+ $self->{values}[$#{ $self->{values} }];
+}
+
+sub STORE {
+ my($self, $value) = @_;
+ ++$self->{write};
+ push @{ $self->{values} }, $value;
+}
+
+sub init {
+ my $self = shift;
+ my @results = ($self->{read}, $self->{write});
+ $self->{read} = $self->{write} = 0;
+ $self->{values} = [ 0 ];
+ @results;
+}
diff --git a/t/op/misc.t b/t/op/misc.t
index e3927a3716..90df19a420 100755
--- a/t/op/misc.t
+++ b/t/op/misc.t
@@ -682,3 +682,15 @@ OK
"abcd\x{1234}" =~ /(a)(b[c])(d+)?/i and print "ok\n";
EXPECT
ok
+########
+# Bug 20010422.005
+{s//${}/; //}
+EXPECT
+syntax error at - line 2, near "${}"
+Execution of - aborted due to compilation errors.
+########
+# Bug 20010528.007
+"\x{"
+EXPECT
+Missing right brace on \x{} at - line 2, within string
+Execution of - aborted due to compilation errors.
diff --git a/t/op/regexp.t b/t/op/regexp.t
index 4a4d42fd98..0751559964 100755
--- a/t/op/regexp.t
+++ b/t/op/regexp.t
@@ -70,8 +70,8 @@ while (<TESTS>) {
$expect = $repl = '-' if $skip_amp and $input =~ /\$[&\`\']/;
$skip = ($skip_amp ? ($result =~ s/B//i) : ($result =~ s/B//));
# Certain tests don't work with utf8 (the re_test should be in UTF8)
- $skip = 1, $reason = 'utf8'
- if ($^H &= ~0x00000008) && $pat =~ /\[:\^(alnum|print|word|ascii|xdigit):\]/;
+# $skip = 1, $reason = 'utf8'
+# if ($^H &= ~0x00000008) && $pat =~ /\[:\^(alnum|print|word|ascii|xdigit):\]/;
$result =~ s/B//i unless $skip;
for $study ('', 'study \$subject') {
$c = $iters;
diff --git a/t/op/splice.t b/t/op/splice.t
index 06e350988d..3b4229a031 100755
--- a/t/op/splice.t
+++ b/t/op/splice.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..9\n";
+print "1..10\n";
@a = (1..10);
@@ -32,3 +32,9 @@ print "ok 8\n";
print "not " unless j(splice(@a,-3,-2,2)) eq j(7) && j(@a) eq j(1,2,7,3);
print "ok 9\n";
+
+# Bug 20000223.001 - no test for splice(@array). Destructive test!
+print "not " unless j(splice(@a)) eq j(1,2,7,3) && j(@a) eq '';
+print "ok 10\n";
+
+
diff --git a/t/op/taint.t b/t/op/taint.t
index 46b9aab3fb..0d1e747daf 100755
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -106,7 +106,7 @@ print PROG 'print "@ARGV\n"', "\n";
close PROG;
my $echo = "$Invoke_Perl $ECHO";
-print "1..173\n";
+print "1..174\n";
# First, let's make sure that Perl is checking the dangerous
# environment variables. Maybe they aren't set yet, so we'll
@@ -811,3 +811,22 @@ else {
}
}
+{
+ # bug 20010526.004
+
+ use warnings;
+
+ $SIG{__WARN__} = sub { print "not " };
+
+ sub fmi {
+ my $divnum = shift()/1;
+ sprintf("%1.1f\n", $divnum);
+ }
+
+ fmi(21 . $TAINT);
+ fmi(37);
+ fmi(248);
+
+ print "ok 174\n";
+}
+
diff --git a/t/op/ver.t b/t/op/ver.t
index 0fe7fd1bbb..05bd854b24 100755
--- a/t/op/ver.t
+++ b/t/op/ver.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..33\n";
+print "1..37\n";
my $test = 1;
@@ -222,3 +222,17 @@ okeq(v5.6.0 lt v5.7.0,1,"v5.6.0 lt v5.7.0 fails");
# floating point too messy
# my $v = ord($^V)+ord(substr($^V,1,1))/1000+ord(substr($^V,2,1))/1000000;
# okeq($v,$],"\$^V and \$] do not match");
+
+# 34..37: part of 20000323.059
+print "not " unless v200 eq chr(200);
+print "ok 34\n";
+
+print "not " unless v200 eq +v200;
+print "ok 35\n";
+
+print "not " unless v200 eq eval "v200";
+print "ok 36\n";
+
+print "not " unless v200 eq eval "+v200";
+print "ok 37\n";
+
diff --git a/t/pragma/autouse.t b/t/pragma/autouse.t
new file mode 100644
index 0000000000..0120ed0899
--- /dev/null
+++ b/t/pragma/autouse.t
@@ -0,0 +1,53 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use Test;
+BEGIN { plan tests => 9; }
+
+BEGIN {
+ require autouse;
+ eval {
+ "autouse"->import('List::Util' => 'List::Util::first');
+ };
+ ok( $@, qr/^autouse into different package attempted/ );
+
+ "autouse"->import('List::Util' => qw(max first(&@)));
+}
+
+my @a = (1,2,3,4,5.5);
+ok( max(@a), 5.5);
+
+
+# first() has a prototype of &@. Make sure that's preserved.
+ok( (first { $_ > 3 } @a), 4);
+
+
+# Example from the docs.
+use autouse 'Carp' => qw(carp croak);
+
+{
+ my @warning;
+ local $SIG{__WARN__} = sub { push @warning, @_ };
+ carp "this carp was predeclared and autoused\n";
+ ok( scalar @warning, 1 );
+ ok( $warning[0], "this carp was predeclared and autoused\n" );
+
+ eval { croak "It is but a scratch!" };
+ ok( $@, qr/^It is but a scratch!/);
+}
+
+
+# Test that autouse's lazy module loading works. We assume that nothing
+# involved in this test uses Test::Soundex, which is pretty safe.
+use File::Spec;
+use autouse 'Text::Soundex' => qw(soundex);
+
+my $mod_file = File::Spec->catfile(qw(Text Soundex.pm));
+ok( !exists $INC{$mod_file} );
+ok( soundex('Basset'), 'B230' );
+ok( exists $INC{$mod_file} );
+
diff --git a/t/pragma/locale.t b/t/pragma/locale.t
index 068fedeac8..000203b3c4 100755
--- a/t/pragma/locale.t
+++ b/t/pragma/locale.t
@@ -515,16 +515,15 @@ foreach $Locale (@Locale) {
# Test \w.
if (utf8locale($Locale)) {
- # Until the polymorphic regexen arrive.
+ # utf8 and locales do not mix.
debug "# skipping UTF-8 locale '$Locale'\n";
} else {
my $word = join('', @Neoalpha);
$word =~ /^(\w+)$/;
-
+
tryneoalpha($Locale, 99, $1 eq $word);
}
-
# Cross-check the whole 8-bit character set.
for (map { chr } 0..255) {
@@ -697,29 +696,32 @@ foreach $Locale (@Locale) {
# Does lc of an UPPER (if different from the UPPER) match
# case-insensitively the UPPER, and does the UPPER match
# case-insensitively the lc of the UPPER. And vice versa.
- if (utf8locale($Locale)) {
- # Until the polymorphic regexen arrive.
- debug "# skipping UTF-8 locale '$Locale'\n";
- } else {
- use locale;
-
- my @f = ();
- foreach my $x (keys %UPPER) {
- my $y = lc $x;
- next unless uc $y eq $x;
- push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
- }
- foreach my $x (keys %lower) {
- my $y = uc $x;
- next unless lc $y eq $x;
- push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
- }
- tryneoalpha($Locale, 116, @f == 0);
- if (@f) {
- print "# failed 116 locale '$Locale' characters @f\n"
+ {
+ if (utf8locale($Locale)) {
+ # utf8 and locales do not mix.
+ debug "# skipping UTF-8 locale '$Locale'\n";
+ } else {
+ use locale;
+ use locale;
+ no utf8; # so that the native 8-bit characters work
+
+ my @f = ();
+ foreach my $x (keys %UPPER) {
+ my $y = lc $x;
+ next unless uc $y eq $x;
+ push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
+ }
+ foreach my $x (keys %lower) {
+ my $y = uc $x;
+ next unless lc $y eq $x;
+ push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
+ }
+ tryneoalpha($Locale, 116, @f == 0);
+ if (@f) {
+ print "# failed 116 locale '$Locale' characters @f\n"
+ }
}
}
-
}
# Recount the errors.
diff --git a/t/pragma/warn/pp_hot b/t/pragma/warn/pp_hot
index 3ee853f6e2..c5a3790587 100644
--- a/t/pragma/warn/pp_hot
+++ b/t/pragma/warn/pp_hot
@@ -211,6 +211,21 @@ $b = sub
EXPECT
########
# pp_hot.c [pp_concat]
+use warnings 'uninitialized';
+my($x, $y);
+sub a { shift }
+a($x . "x"); # should warn once
+a($x . $y); # should warn twice
+$x .= $y; # should warn once
+$y .= $y; # should warn once
+EXPECT
+Use of uninitialized value in concatenation (.) or string at - line 5.
+Use of uninitialized value in concatenation (.) or string at - line 6.
+Use of uninitialized value in concatenation (.) or string at - line 6.
+Use of uninitialized value in concatenation (.) or string at - line 7.
+Use of uninitialized value in concatenation (.) or string at - line 8.
+########
+# pp_hot.c [pp_concat]
use warnings 'y2k';
use Config;
BEGIN {