summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-07-11 19:11:18 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-07-11 19:11:18 +0000
commitbe3174d2532d82826fc0aa416a83ef8ce0f07732 (patch)
treedcb2f29d4e1d0a6db01d7d1c2c96304de9c13b8d /t
parent5e5f20b507b6c3b7749b1f2f6cfd8a156eca9deb (diff)
downloadperl-be3174d2532d82826fc0aa416a83ef8ce0f07732.tar.gz
integrate cfgperl changes#6268..6282 into mainline
p4raw-link: @6282 on //depot/cfgperl: d4817f5b97d4072a6efac47844b617245b179f2c p4raw-link: @6268 on //depot/cfgperl: 22e04bdb3a09a4c369fd1666143349eab2eba9d4 p4raw-id: //depot/perl@6366 p4raw-integrated: from //depot/cfgperl@6365 'copy in' lib/Net/Ping.pm lib/Text/Wrap.pm t/lib/dprof.t t/lib/dumper-ovl.t t/lib/hostname.t (@5586..) lib/Pod/Html.pm (@5608..) t/lib/ipc_sysv.t (@5812..) t/lib/dumper.t (@5972..) ext/File/Glob/Glob.pm (@6026..) lib/Pod/Man.pm lib/Pod/Text.pm (@6034..) t/lib/anydbm.t (@6072..) lib/ExtUtils/xsubpp (@6156..) pod/perlsub.pod pod/perltie.pod (@6206..) utils/h2xs.PL (@6280..) p4raw-integrated: from //depot/cfgperl@6282 'merge in' vms/vms.c (@6238..) p4raw-integrated: from //depot/cfgperl@6277 'copy in' pod/perlfunc.pod (@6276..) p4raw-integrated: from //depot/cfgperl@6273 'ignore' perlapi.h (@6243..) embedvar.h (@6254..) 'merge in' perlapi.c (@6243..) embed.h (@6254..) embed.pl objXSUB.h op.c proto.h (@6269..) p4raw-integrated: from //depot/cfgperl@6270 'copy in' t/op/taint.t (@5857..) p4raw-integrated: from //depot/cfgperl@6269 'copy in' doop.c (@6263..) 'ignore' toke.c (@6261..) p4raw-integrated: from //depot/cfgperl@6268 'copy in' t/op/sprintf.t (@6267..)
Diffstat (limited to 't')
-rwxr-xr-xt/lib/anydbm.t5
-rwxr-xr-xt/lib/dprof.t6
-rwxr-xr-xt/lib/dumper-ovl.t5
-rwxr-xr-xt/lib/dumper.t5
-rwxr-xr-xt/lib/hostname.t5
-rwxr-xr-xt/lib/ipc_sysv.t4
-rwxr-xr-xt/op/sprintf.t252
-rwxr-xr-xt/op/taint.t7
8 files changed, 264 insertions, 25 deletions
diff --git a/t/lib/anydbm.t b/t/lib/anydbm.t
index a7fca17811..e304766fc1 100755
--- a/t/lib/anydbm.t
+++ b/t/lib/anydbm.t
@@ -5,6 +5,11 @@
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
+ require Config; import Config;
+ if (($Config{'extensions'} !~ /\b(DB|[A-Z]DBM)_File\b/) ){
+ print "1..0 # Skipping (no DB_File or [A-Z]DBM_File)\n";
+ exit 0;
+ }
}
require AnyDBM_File;
use Fcntl;
diff --git a/t/lib/dprof.t b/t/lib/dprof.t
index 4d6f7823c3..fc5bd050cb 100755
--- a/t/lib/dprof.t
+++ b/t/lib/dprof.t
@@ -3,6 +3,11 @@
BEGIN {
chdir( 't' ) if -d 't';
unshift @INC, '../lib';
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bDevel\/DProf\b/){
+ print "1..0 # Skip: Devel::DProf was not built\n";
+ exit 0;
+ }
}
END {
@@ -11,7 +16,6 @@ END {
use Benchmark qw( timediff timestr );
use Getopt::Std 'getopts';
-use Config '%Config';
getopts('vI:p:');
# -v Verbose
diff --git a/t/lib/dumper-ovl.t b/t/lib/dumper-ovl.t
index 8c095e59be..b8c8719318 100755
--- a/t/lib/dumper-ovl.t
+++ b/t/lib/dumper-ovl.t
@@ -3,6 +3,11 @@
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib' if -d '../lib';
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
+ print "1..0 # Skip: Data::Dumper was not built\n";
+ exit 0;
+ }
}
use Data::Dumper;
diff --git a/t/lib/dumper.t b/t/lib/dumper.t
index b9680bd5e6..7b5a611b7d 100755
--- a/t/lib/dumper.t
+++ b/t/lib/dumper.t
@@ -6,6 +6,11 @@
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib' if -d '../lib';
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bData\/Dumper\b/) {
+ print "1..0 # Skip: Data::Dumper was not built\n";
+ exit 0;
+ }
}
use Data::Dumper;
diff --git a/t/lib/hostname.t b/t/lib/hostname.t
index 6f61fb9dad..8a34e9c4e7 100755
--- a/t/lib/hostname.t
+++ b/t/lib/hostname.t
@@ -3,6 +3,11 @@
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
+ require Config; import Config;
+ if ($Config{'extensions'} !~ /\bSys\/Hostname\b/) {
+ print "1..0 # Skip: Sys::Hostname was not built\n";
+ exit 0;
+ }
}
use Sys::Hostname;
diff --git a/t/lib/ipc_sysv.t b/t/lib/ipc_sysv.t
index a4f3e3f367..d2991e3eac 100755
--- a/t/lib/ipc_sysv.t
+++ b/t/lib/ipc_sysv.t
@@ -9,7 +9,9 @@ BEGIN {
my $reason;
- if ($Config{'d_sem'} ne 'define') {
+ if ($Config{'extensions'} !~ /\bIPC\/SysV\b/) {
+ $reason = 'IPC::SysV was not built';
+ } elsif ($Config{'d_sem'} ne 'define') {
$reason = '$Config{d_sem} undefined';
} elsif ($Config{'d_msg'} ne 'define') {
$reason = '$Config{d_msg} undefined';
diff --git a/t/op/sprintf.t b/t/op/sprintf.t
index 4d54d2c317..d731ac4138 100755
--- a/t/op/sprintf.t
+++ b/t/op/sprintf.t
@@ -1,6 +1,10 @@
#!./perl
-# $RCSfile: sprintf.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:27 $
+# Tests sprintf, excluding handling of 64-bit integers or long
+# doubles (if supported), of machine-specific short and long
+# integers, machine-specific floating point exceptions (infinity,
+# not-a-number ...), of the effects of locale, and of features
+# specific to multi-byte characters (under use utf8 and such).
BEGIN {
chdir 't' if -d 't';
@@ -8,31 +12,239 @@ BEGIN {
}
use warnings;
-print "1..4\n";
+while (<DATA>) {
+ s/^\s*>//; s/<\s*$//;
+ push @tests, [split(/<\s*>/, $_, 4)];
+}
+
+print '1..', scalar @tests, "\n";
$SIG{__WARN__} = sub {
if ($_[0] =~ /^Invalid conversion/) {
- $w++;
+ $w = ' INVALID'
} else {
- warn @_;
+ warn @_;
}
};
-$w = 0;
-$x = sprintf("%3s %-4s%%foo %.0d%5d %#x%c%3.1f %b %x %X %#b %#x %#X","hi",123,0,456,0,ord('A'),3.0999,11,171,171,11,171,171);
-if ($x eq ' hi 123 %foo 456 0A3.1 1011 ab AB 0b1011 0xab 0XAB' && $w == 0) {
- print "ok 1\n";
-} else {
- print "not ok 1 '$x'\n";
-}
-
-for $i (2 .. 4) {
- $f = ('%6 .6s', '%6. 6s', '%6.6 s')[$i - 2];
- $w = 0;
- $x = sprintf($f, '');
- if ($x eq $f && $w == 1) {
- print "ok $i\n";
- } else {
- print "not ok $i '$x' '$f' '$w'\n";
+for ($i = 1; @tests; $i++) {
+ ($template, $data, $result, $comment) = @{shift @tests};
+ $evalData = eval $data;
+ $w = undef;
+ $x = sprintf(">$template<",
+ defined @$evalData ? @$evalData : $evalData);
+ substr($x, -1, 0) = $w if $w;
+ if ($x eq ">$result<") {
+ print "ok $i\n";
+ }
+ else {
+ print("not ok $i >$template< >$data< >$result< $x",
+ $comment ? " # $comment\n" : "\n");
}
}
+
+# In each of the the following lines, there are three required fields:
+# printf template, data to be formatted (as a Perl expression), and
+# expected result of formatting. An optional fourth field can contain
+# a comment. Each field is delimited by a starting '>' and a
+# finishing '<'; any whitespace outside these start and end marks is
+# not part of the field. If formatting requires more than one data
+# item (for example, if variable field widths are used), the Perl data
+# expression should return a reference to an array having the requisite
+# number of elements. Even so, subterfuge is sometimes required: see
+# tests for %n and %p.
+#
+# template data result
+__END__
+>%6 .6s< >''< >%6 .6s INVALID< >First test from old sprintf.t<
+>%6. 6s< >''< >%6. 6s INVALID< >(See use of $w in code above)<
+>%6.6 s< >''< >%6.6 s INVALID<
+>%3s< >'hi'< > hi<
+>%-4s< >123< >123 <
+>%%foo< >'bar'< >%foo<
+>%.0d< >0< ><
+>%5d< >456< > 456<
+>%#x< >0< >0<
+>%c< >ord('A')< >A<
+>%3.1f< >3.0999< >3.1<
+>%b< >11< >1011<
+>%x< >171< >ab<
+>%X< >171< >AB<
+>%#b< >11< >0b1011<
+>%#x< >171< >0xab<
+>%#X< >171< >0XAB< >Last test from old sprintf.t<
+>%A< >''< >%A INVALID< >First new test<
+>%B< >''< >%B INVALID<
+>%C< >''< >%C INVALID<
+>%D< >0x7fffffff< >2147483647< >Synonym for %ld<
+>%E< >123456.789< >1.234568E+05< >Like %e, but using upper-case "E"<
+>%F< >123456.789< >123456.789000< >Synonym for %f<
+>%G< >1234567.89< >1.23457E+06< >Like %g, but using upper-case "E"<
+>%G< >12345.6789< >12345.7<
+>%H< >''< >%H INVALID<
+>%I< >''< >%I INVALID<
+>%J< >''< >%J INVALID<
+>%K< >''< >%K INVALID<
+>%L< >''< >%L INVALID<
+>%M< >''< >%M INVALID<
+>%N< >''< >%N INVALID<
+>%O< >2**32-1< >37777777777< >Synonym for %lo<
+>%P< >''< >%P INVALID<
+>%Q< >''< >%Q INVALID<
+>%R< >''< >%R INVALID<
+>%S< >''< >%S INVALID<
+>%T< >''< >%T INVALID<
+>%U< >2**32-1< >4294967295< >Synonym for %lu<
+>%V< >''< >%V INVALID<
+>%W< >''< >%W INVALID<
+>%X< >2**32-1< >FFFFFFFF< >Like %x, but with u/c letters<
+>%#X< >2**32-1< >0XFFFFFFFF<
+>%Y< >''< >%Y INVALID<
+>%Z< >''< >%Z INVALID<
+>%a< >''< >%a INVALID<
+>%b< >2**32-1< >11111111111111111111111111111111<
+>%+b< >2**32-1< >11111111111111111111111111111111<
+>%#b< >2**32-1< >0b11111111111111111111111111111111<
+>%34b< >2**32-1< > 11111111111111111111111111111111<
+>%034b< >2**32-1< >0011111111111111111111111111111111<
+>%-34b< >2**32-1< >11111111111111111111111111111111 <
+>%-034b< >2**32-1< >11111111111111111111111111111111 <
+>%c< >ord('A')< >A<
+>%10c< >ord('A')< > A<
+>%#10c< >ord('A')< > A< ># modifier: no effect<
+>%010c< >ord('A')< >000000000A<
+>%10lc< >ord('A')< > A< >l modifier: no effect<
+>%10hc< >ord('A')< > A< >h modifier: no effect<
+>%10.5c< >ord('A')< > A< >precision: no effect<
+>%-10c< >ord('A')< >A <
+>%d< >123456.789< >123456<
+>%d< >-123456.789< >-123456<
+>%d< >0< >0<
+>%+d< >0< >+0<
+>%0d< >0< >0<
+>%.0d< >0< ><
+>%+.0d< >0< >+<
+>%.0d< >1< >1<
+>%d< >1< >1<
+>%+d< >1< >+1<
+>%#3.2d< >1< > 01< ># modifier: no effect<
+>%3.2d< >1< > 01<
+>%03.2d< >1< >001<
+>%-3.2d< >1< >01 <
+>%-03.2d< >1< >01 < >zero pad + left just.: no effect<
+>%d< >-1< >-1<
+>%+d< >-1< >-1<
+>%hd< >1< >1< >More extensive testing of<
+>%ld< >1< >1< >length modifiers would be<
+>%Vd< >1< >1< >platform-specific<
+>%vd< >chr(1)< >1<
+>%+vd< >chr(1)< >+1<
+>%#vd< >chr(1)< >1<
+>%vd< >"\01\02\03"< >1.2.3<
+>%v.3d< >"\01\02\03"< >001.002.003<
+>%v03d< >"\01\02\03"< >001.002.003<
+>%v-3d< >"\01\02\03"< >1 .2 .3 <
+>%v+-3d< >"\01\02\03"< >+1 .2 .3 <
+>%v4.3d< >"\01\02\03"< > 001. 002. 003<
+>%v04.3d< >"\01\02\03"< >0001.0002.0003<
+>%*v02d< >['-', "\0\6\35"]< >00-06-29<
+>%e< >1234.875< >1.234875e+03<
+>%+e< >1234.875< >+1.234875e+03<
+>%#e< >1234.875< >1.234875e+03<
+>%e< >-1234.875< >-1.234875e+03<
+>%+e< >-1234.875< >-1.234875e+03<
+>%#e< >-1234.875< >-1.234875e+03<
+>%.0e< >1234.875< >1e+03<
+>%.*e< >[0, 1234.875]< >1e+03<
+>%.1e< >1234.875< >1.2e+03<
+>%-12.4e< >1234.875< >1.2349e+03 <
+>%12.4e< >1234.875< > 1.2349e+03<
+>%+-12.4e< >1234.875< >+1.2349e+03 <
+>%+12.4e< >1234.875< > +1.2349e+03<
+>%+-12.4e< >-1234.875< >-1.2349e+03 <
+>%+12.4e< >-1234.875< > -1.2349e+03<
+>%f< >1234.875< >1234.875000<
+>%+f< >1234.875< >+1234.875000<
+>%#f< >1234.875< >1234.875000<
+>%f< >-1234.875< >-1234.875000<
+>%+f< >-1234.875< >-1234.875000<
+>%#f< >-1234.875< >-1234.875000<
+>%6f< >1234.875< >1234.875000<
+>%*f< >[6, 1234.875]< >1234.875000<
+>%.0f< >1234.875< >1235<
+>%.1f< >1234.875< >1234.9<
+>%-8.1f< >1234.875< >1234.9 <
+>%8.1f< >1234.875< > 1234.9<
+>%+-8.1f< >1234.875< >+1234.9 <
+>%+8.1f< >1234.875< > +1234.9<
+>%+-8.1f< >-1234.875< >-1234.9 <
+>%+8.1f< >-1234.875< > -1234.9<
+>%*.*f< >[5, 2, 12.3456]< >12.35<
+>%g< >12345.6789< >12345.7<
+>%+g< >12345.6789< >+12345.7<
+>%#g< >12345.6789< >12345.7<
+>%.0g< >12345.6789< >1e+04<
+>%.2g< >12345.6789< >1.2e+04<
+>%.*g< >[2, 12345.6789]< >1.2e+04<
+>%.9g< >12345.6789< >12345.6789<
+>%12.9g< >12345.6789< > 12345.6789<
+>%012.9g< >12345.6789< >0012345.6789<
+>%-12.9g< >12345.6789< >12345.6789 <
+>%*.*g< >[-12, 9, 12345.6789]< >12345.6789 <
+>%-012.9g< >12345.6789< >12345.6789 <
+>%g< >-12345.6789< >-12345.7<
+>%+g< >-12345.6789< >-12345.7<
+>%g< >1234567.89< >1.23457e+06<
+>%+g< >1234567.89< >+1.23457e+06<
+>%#g< >1234567.89< >1.23457e+06<
+>%g< >-1234567.89< >-1.23457e+06<
+>%+g< >-1234567.89< >-1.23457e+06<
+>%#g< >-1234567.89< >-1.23457e+06<
+>%13g< >1234567.89< > 1.23457e+06<
+>%+13g< >1234567.89< > +1.23457e+06<
+>%013g< >1234567.89< >001.23457e+06<
+>%-13g< >1234567.89< >1.23457e+06 <
+>%h< >''< >%h INVALID<
+>%i< >123456.789< >123456< >Synonym for %d<
+>%j< >''< >%j INVALID<
+>%k< >''< >%k INVALID<
+>%l< >''< >%l INVALID<
+>%m< >''< >%m INVALID<
+>%s< >sprintf('%%n%n %d', $n, $n)< >%n 2< >Slight sneakiness to test %n<
+>%o< >2**32-1< >37777777777<
+>%+o< >2**32-1< >37777777777<
+>%#o< >2**32-1< >037777777777<
+>%d< >$p=sprintf('%p',$p);$p=~/^[0-9a-f]+$/< >1< >Coarse hack: hex from %p?<
+>%q< >''< >%q INVALID<
+>%r< >''< >%r INVALID<
+>%s< >'string'< >string<
+>%10s< >'string'< > string<
+>%+10s< >'string'< > string<
+>%#10s< >'string'< > string<
+>%010s< >'string'< >0000string<
+>%0*s< >[10, 'string']< >0000string<
+>%-10s< >'string'< >string <
+>%3s< >'string'< >string<
+>%.3s< >'string'< >str<
+>%.*s< >[3, 'string']< >str<
+>%t< >''< >%t INVALID<
+>%u< >2**32-1< >4294967295<
+>%+u< >2**32-1< >4294967295<
+>%#u< >2**32-1< >4294967295<
+>%12u< >2**32-1< > 4294967295<
+>%012u< >2**32-1< >004294967295<
+>%-12u< >2**32-1< >4294967295 <
+>%-012u< >2**32-1< >4294967295 <
+>%v< >''< >%v INVALID<
+>%w< >''< >%w INVALID<
+>%x< >2**32-1< >ffffffff<
+>%+x< >2**32-1< >ffffffff<
+>%#x< >2**32-1< >0xffffffff<
+>%10x< >2**32-1< > ffffffff<
+>%010x< >2**32-1< >00ffffffff<
+>%-10x< >2**32-1< >ffffffff <
+>%-010x< >2**32-1< >ffffffff <
+>%0-10x< >2**32-1< >ffffffff <
+>%0*x< >[-10, ,2**32-1]< >ffffffff <
+>%y< >''< >%y INVALID<
+>%z< >''< >%z INVALID<
diff --git a/t/op/taint.t b/t/op/taint.t
index 6548b46f59..af578347cc 100755
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -24,7 +24,8 @@ BEGIN {
$ENV{PATH} = $ENV{PATH};
$ENV{TERM} = $ENV{TERM} ne ''? $ENV{TERM} : 'dummy';
}
- if ($Config{d_shm} || $Config{d_msg}) {
+ if ($Config{'extensions'} =~ /\bIPC\/SysV\b/
+ && ($Config{d_shm} || $Config{d_msg})) {
require IPC::SysV;
IPC::SysV->import(qw(IPC_PRIVATE IPC_RMID IPC_CREAT S_IRWXU));
}
@@ -612,7 +613,7 @@ else {
# test shmread
{
- if ($Config{d_shm}) {
+ if ($Config{'extensions'} =~ /\bIPC\/SysV\b/ && $Config{d_shm}) {
no strict 'subs';
my $sent = "foobar";
my $rcvd;
@@ -646,7 +647,7 @@ else {
# test msgrcv
{
- if ($Config{d_msg}) {
+ if ($Config{'extensions'} =~ /\bIPC\/SysV\b/ && $Config{d_msg}) {
no strict 'subs';
my $id = msgget(IPC_PRIVATE, IPC_CREAT | S_IRWXU);