summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-05-15 08:39:14 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-05-15 08:39:14 +0000
commit16ad5aca1f5177638c984f3315f96c0cd2f10334 (patch)
tree9df74b62e1f5396d43f119b6065dca88c3bd7ff7 /t
parent2e117952781c322d29321f4d0b7193f45488d1cb (diff)
parentec5f161023cc5696391a8f74e39775a6aaaa1bbb (diff)
downloadperl-16ad5aca1f5177638c984f3315f96c0cd2f10334.tar.gz
Integrate mainline.
p4raw-id: //depot/perlio@10111
Diffstat (limited to 't')
-rwxr-xr-xt/TEST57
-rw-r--r--t/TestInit.pm3
-rw-r--r--t/camel-III/vstring.t37
-rwxr-xr-xt/cmd/for.t13
-rw-r--r--t/harness2
-rw-r--r--t/lib/class-struct.t12
-rwxr-xr-xt/lib/filefind.t33
-rwxr-xr-xt/lib/glob-basic.t3
-rw-r--r--t/lib/io_scalar.t15
-rw-r--r--t/lib/md5-file.t2
-rwxr-xr-xt/op/append.t29
-rwxr-xr-xt/op/method.t5
-rwxr-xr-xt/op/pat.t2
-rwxr-xr-xt/op/regexp.t2
-rwxr-xr-xt/op/tr.t8
-rwxr-xr-xt/op/ver.t128
16 files changed, 229 insertions, 122 deletions
diff --git a/t/TEST b/t/TEST
index 122bd96a86..702409e467 100755
--- a/t/TEST
+++ b/t/TEST
@@ -8,9 +8,13 @@ $| = 1;
# Cheesy version of Getopt::Std. Maybe we should replace it with that.
if ($#ARGV >= 0) {
foreach my $idx (0..$#ARGV) {
- next unless $ARGV[$idx] =~ /^-(\w+)$/;
+ next unless $ARGV[$idx] =~ /^-(\S+)$/;
$verbose = 1 if $1 eq 'v';
$with_utf= 1 if $1 eq 'utf8';
+ if ($1 =~ /^deparse(,.+)?$/) {
+ $deparse = 1;
+ $deparse_opts = $1;
+ }
splice(@ARGV, $idx, 1);
}
}
@@ -42,13 +46,17 @@ $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 camel-III/*.t`);
+ `echo base/*.t comp/*.t cmd/*.t run/*.t io/*.t; echo op/*.t pragma/*.t lib/*.t pod/*.t`);
}
# %infinite = ( 'comp/require.t', 1, 'op/bop.t', 1, 'lib/hostname.t', 1 );
-_testprogs('perl', @ARGV);
-_testprogs('compile', @ARGV) if (-e "../testcompile");
+if ($deparse) {
+ _testprogs('deparse', @ARGV);
+} else {
+ _testprogs('perl', @ARGV);
+ _testprogs('compile', @ARGV) if (-e "../testcompile");
+}
sub _testprogs {
$type = shift @_;
@@ -61,6 +69,12 @@ TESTING COMPILER
--------------------------------------------------------------------------------
EOT
+ print <<'EOT' if ($type eq 'deparse');
+--------------------------------------------------------------------------------
+TESTING DEPARSER
+--------------------------------------------------------------------------------
+EOT
+
$ENV{PERLCC_TIMEOUT} = 120
if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
@@ -86,13 +100,23 @@ EOT
if ($test =~ /^$/) {
next;
}
+ if ($type eq 'deparse') {
+ if ($test eq "comp/redef.t") {
+ # Redefinition happens at compile time
+ next;
+ }
+ elsif ($test eq "lib/switch.t") {
+ # B::Deparse doesn't support source filtering
+ next;
+ }
+ }
$te = $test;
chop($te);
print "$te" . '.' x ($dotdotdot - length($te));
open(SCRIPT,"<$test") or die "Can't run $test.\n";
$_ = <SCRIPT>;
- close(SCRIPT);
+ close(SCRIPT) unless ($type eq 'deparse');
if (/#!.*perl(.*)$/) {
$switch = $1;
if ($^O eq 'VMS') {
@@ -104,10 +128,28 @@ EOT
$switch = '';
}
+ my $file_opts = "";
+ if ($type eq 'deparse') {
+ # Look for #line directives which change the filename
+ while (<SCRIPT>) {
+ $file_opts .= ",-f$3$4"
+ if /^#\s*line\s+(\d+)\s+((\w+)|"([^"]+)")/;
+ }
+ close(SCRIPT);
+ }
my $utf = $with_utf ? '-I../lib -Mutf8'
: '';
my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
- if ($type eq 'perl') {
+ if ($type eq 'deparse') {
+ my $deparse =
+ "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
+ "-l$deparse_opts$file_opts ".
+ "./$test > ./$test.dp ".
+ "&& ./perl $testswitch $switch -I../lib ./$test.dp |";
+ open(RESULTS, $deparse)
+ or print "can't deparse '$deparse': $!.\n";
+ }
+ elsif ($type eq 'perl') {
my $run = "./perl $testswitch $switch $utf $test |";
open(RESULTS,$run) or print "can't run '$run': $!.\n";
}
@@ -161,6 +203,9 @@ EOT
}
}
close RESULTS;
+ if ($type eq 'deparse') {
+ unlink "./$test.dp";
+ }
if ($ENV{PERL_3LOG}) {
my $tpp = $test;
$tpp =~ s:/:_:g;
diff --git a/t/TestInit.pm b/t/TestInit.pm
index 873c3ce878..a9322862ce 100644
--- a/t/TestInit.pm
+++ b/t/TestInit.pm
@@ -15,3 +15,6 @@
chdir 't' if -d 't';
@INC = '../lib';
+$0 =~ s/\.dp$//;
+1;
+
diff --git a/t/camel-III/vstring.t b/t/camel-III/vstring.t
deleted file mode 100644
index 6dec4ddd69..0000000000
--- a/t/camel-III/vstring.t
+++ /dev/null
@@ -1,37 +0,0 @@
-# See if the things Camel-III says are true.
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
-}
-use Test;
-plan test => 5;
-
-# Chapter 2 pp67/68
-my $vs = v1.20.300.4000;
-ok($vs,"\x{1}\x{14}\x{12c}\x{fa0}","v-string ne \\x{}");
-ok($vs,chr(1).chr(20).chr(300).chr(4000),"v-string ne chr()");
-ok('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.
- skip("No Socket",'');
- }
-else
- {
- my $ip = v2004.148.0.1;
- my $host;
- eval { $host = gethostbyaddr($ip,Socket::AF_INET()) };
- ok($@ =~ /Wide character/,1,"Non-bytes leak to gethostbyaddr");
- }
-
-# Chapter 28, pp671
-ok(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;
-# ok($v,$],"\$^V and \$] do not match");
diff --git a/t/cmd/for.t b/t/cmd/for.t
index d70af579fc..90b5ff0b4f 100755
--- a/t/cmd/for.t
+++ b/t/cmd/for.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..10\n";
+print "1..11\n";
for ($i = 0; $i <= 10; $i++) {
$x[$i] = $i;
@@ -55,3 +55,14 @@ sub foo {
print foo(1) == 1 ? "ok" : "not ok", " 8\n";
print foo(2) == 2 ? "ok" : "not ok", " 9\n";
print foo(5) == 5 ? "ok" : "not ok", " 10\n";
+
+sub bar {
+ return (1, 2, 4);
+}
+
+$a = 0;
+foreach $b (bar()) {
+ $a += $b;
+}
+print $a == 7 ? "ok" : "not ok", " 11\n";
+
diff --git a/t/harness b/t/harness
index ca8a676aea..3cacc59337 100644
--- a/t/harness
+++ b/t/harness
@@ -37,7 +37,7 @@ foreach (keys %datahandle) {
}
@tests = @ARGV;
-@tests = <base/*.t comp/*.t cmd/*.t io/*.t op/*.t pragma/*.t lib/*.t camel-III/*.t> unless @tests;
+@tests = <base/*.t comp/*.t cmd/*.t io/*.t op/*.t pragma/*.t lib/*.t pod/*.t> unless @tests;
Test::Harness::runtests @tests;
exit(0) unless -e "../testcompile";
diff --git a/t/lib/class-struct.t b/t/lib/class-struct.t
index 26505bacfc..2dfaf85e6d 100644
--- a/t/lib/class-struct.t
+++ b/t/lib/class-struct.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..8\n";
+print "1..10\n";
package aClass;
@@ -64,3 +64,13 @@ $obk->SomeElem(123);
print "not " unless $obk->SomeElem() == 123;
print "ok 8\n";
+$obj->a([4,5,6]);
+
+print "not " unless $obj->a(1) == 5;
+print "ok 9\n";
+
+$obj->h({h=>7,r=>8,f=>9});
+
+print "not " unless $obj->h('r') == 8;
+print "ok 10\n";
+
diff --git a/t/lib/filefind.t b/t/lib/filefind.t
index 362c1ebf07..de322f84c3 100755
--- a/t/lib/filefind.t
+++ b/t/lib/filefind.t
@@ -14,24 +14,35 @@ else { print "1..61\n"; }
use File::Find;
+cleanup();
+
find(sub { print "ok 1\n" if $_ eq 'filefind.t'; }, ".");
finddepth(sub { print "ok 2\n" if $_ eq 'filefind.t'; }, ".");
-
my $case = 2;
my $FastFileTests_OK = 0;
+sub cleanup {
+ if (-d 'for_find') {
+ chdir('for_find');
+ }
+ if (-d 'fa') {
+ unlink 'fa/fa_ord', 'fa/fsl', 'fa/faa/faa_ord',
+ 'fa/fab/fab_ord', 'fa/fab/faba/faba_ord',
+ 'fb/fb_ord', 'fb/fba/fba_ord';
+ rmdir 'fa/faa';
+ rmdir 'fa/fab/faba';
+ rmdir 'fa/fab';
+ rmdir 'fa';
+ rmdir 'fb/fba';
+ rmdir 'fb';
+ chdir '..';
+ rmdir 'for_find';
+ }
+}
+
END {
- unlink 'fa/fa_ord','fa/fsl','fa/faa/faa_ord',
- 'fa/fab/fab_ord','fa/fab/faba/faba_ord','fb/fb_ord','fb/fba/fba_ord';
- rmdir 'fa/faa';
- rmdir 'fa/fab/faba';
- rmdir 'fa/fab';
- rmdir 'fa';
- rmdir 'fb/fba';
- rmdir 'fb';
- chdir '..';
- rmdir 'for_find';
+ cleanup();
}
sub Check($) {
diff --git a/t/lib/glob-basic.t b/t/lib/glob-basic.t
index fda0f721e8..6c12c2624c 100755
--- a/t/lib/glob-basic.t
+++ b/t/lib/glob-basic.t
@@ -138,9 +138,8 @@ chdir "pteerslt";
@f_alpha = qw(Ax.pl aY.pl Bx.pl bY.pl Cx.pl cY.pl);
if ('a' lt 'A') { # EBCDIC char sets sort lower case before UPPER
@f_names = sort(@f_names);
- @f_alpha = qw(aY.pl Ax.pl bY.pl Bx.pl cY.pl Cx.pl);
}
-if ($^O eq 'VMS') {
+if ($^O eq 'VMS') { # VMS is happily caseignorant
@f_alpha = qw(ax.pl ay.pl bx.pl by.pl cx.pl cy.pl);
@f_names = @f_alpha;
}
diff --git a/t/lib/io_scalar.t b/t/lib/io_scalar.t
index 14bbf4d222..b1ef199a5c 100644
--- a/t/lib/io_scalar.t
+++ b/t/lib/io_scalar.t
@@ -10,7 +10,7 @@ BEGIN {
}
$| = 1;
-print "1..19\n";
+print "1..20\n";
my $fh;
my $var = "ok 2\n";
@@ -86,3 +86,16 @@ print $fh "is here";
print "# Got [$var], expect [Something else is here]\n";
print "not " unless $var eq "Something else is here";
print "ok 19\n";
+close $fh;
+
+# Check that updates to the scalar from elsewhere do not
+# cause problems
+$var = "line one\nline two\line three\n";
+open $fh, "<", \$var;
+while (<$fh>) {
+ $var = "foo";
+}
+close $fh;
+print "# Got [$var], expect [foo]\n";
+print "not " unless $var eq "foo";
+print "ok 20\n";
diff --git a/t/lib/md5-file.t b/t/lib/md5-file.t
index d0f0d034a1..2aec7e34b7 100644
--- a/t/lib/md5-file.t
+++ b/t/lib/md5-file.t
@@ -16,7 +16,7 @@ my $EXPECT;
if (ord('A') == 193) { # EBCDIC
$EXPECT = <<EOT;
95a81f17a8e6c2273aecac12d8c4cb90 ext/Digest/MD5/MD5.pm
-c1eb144eccdad16fc34399cb4ab2e136 ext/Digest/MD5/MD5.xs
+e9e70adad1215b8fa43b52508f425ae9 ext/Digest/MD5/MD5.xs
EOT
} else { # ASCII
$EXPECT = <<EOT;
diff --git a/t/op/append.t b/t/op/append.t
index 5aa4bf9007..5e70659c07 100755
--- a/t/op/append.t
+++ b/t/op/append.t
@@ -43,17 +43,38 @@ if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";}
my $t1 = $a; $t1 .= $ab;
print $t1 =~ /\142/ ? "ok 6\n" : "not ok 6\t# $t1\n";
my $t2 = $a; $t2 .= $ub;
- print $t2 =~ /\142/ ? "ok 7\n" : "not ok 7\t# $t2\n";
+ if (ord('A') == 193) {
+ # print $t2 eq "\141\141\000" ? "ok 7\n" : "not ok 7\t# $t2\n";
+ print $t2 =~ /\141/ ? "ok 7\n" : "not ok 7\t# $t2\n";
+ }
+ else {
+ print $t2 =~ /\142/ ? "ok 7\n" : "not ok 7\t# $t2\n";
+ }
my $t3 = $u; $t3 .= $ab;
print $t3 =~ /\142/ ? "ok 8\n" : "not ok 8\t# $t3\n";
my $t4 = $u; $t4 .= $ub;
- print $t4 =~ /\142/ ? "ok 9\n" : "not ok 9\t# $t4\n";
+ if (ord('A') == 193) {
+ print $t4 =~ /\141/ ? "ok 9\n" : "not ok 9\t# $t4\n";
+ }
+ else {
+ print $t4 =~ /\142/ ? "ok 9\n" : "not ok 9\t# $t4\n";
+ }
my $t5 = $a; $t5 = $ab . $t5;
print $t5 =~ /\142/ ? "ok 10\n" : "not ok 10\t# $t5\n";
my $t6 = $a; $t6 = $ub . $t6;
- print $t6 =~ /\142/ ? "ok 11\n" : "not ok 11\t# $t6\n";
+ if (ord('A') == 193) {
+ print $t6 =~ /\141/ ? "ok 11\n" : "not ok 11\t# $t6\n";
+ }
+ else {
+ print $t6 =~ /\142/ ? "ok 11\n" : "not ok 11\t# $t6\n";
+ }
my $t7 = $u; $t7 = $ab . $t7;
print $t7 =~ /\142/ ? "ok 12\n" : "not ok 12\t# $t7\n";
my $t8 = $u; $t8 = $ub . $t8;
- print $t8 =~ /\142/ ? "ok 13\n" : "not ok 13\t# $t8\n";
+ if (ord('A') == 193) {
+ print $t8 =~ /\141/ ? "ok 13\n" : "not ok 13\t# $t8\n";
+ }
+ else {
+ print $t8 =~ /\142/ ? "ok 13\n" : "not ok 13\t# $t8\n";
+ }
}
diff --git a/t/op/method.t b/t/op/method.t
index 1f5cbb64dc..ceb39be7da 100755
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -9,7 +9,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..54\n";
+print "1..56\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -46,6 +46,9 @@ test($obj->$mname("a","b","c"), "method,a,b,c");
test((method $obj ("a","b","c")), "method,a,b,c");
test((method $obj "a","b","c"), "method,a,b,c");
+test($obj->method(0), "method,0");
+test($obj->method(1), "method,1");
+
test($obj->method(), "method");
test($obj->$mname(), "method");
test((method $obj ()), "method");
diff --git a/t/op/pat.t b/t/op/pat.t
index 1be72346f8..0df4d786ee 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -13,8 +13,6 @@ BEGIN {
@INC = '../lib';
}
-use re 'asciirange'; # Compute ranges in ASCII space
-
eval 'use Config'; # Defaults assumed if this fails
$x = "abc\ndef\n";
diff --git a/t/op/regexp.t b/t/op/regexp.t
index 0b81e714a9..4a4d42fd98 100755
--- a/t/op/regexp.t
+++ b/t/op/regexp.t
@@ -36,8 +36,6 @@ BEGIN {
@INC = '../lib';
}
-use re 'asciirange'; # ranges are computed in ASCII
-
$iters = shift || 1; # Poor man performance suite, 10000 is OK.
open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') ||
diff --git a/t/op/tr.t b/t/op/tr.t
index 7c73430687..1e30365eeb 100755
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = '../lib';
}
-print "1..69\n";
+print "1..70\n";
$_ = "abcdefghijklmnopqrstuvwxyz";
@@ -385,3 +385,9 @@ print "ok 68\n";
print "not " if "@a" ne "1 2";
print "ok 69\n";
+# Additional test for Inaba Hiroto patch (robin@kitsite.com)
+($a = "\x{100}\x{102}\x{101}") =~ tr/\x00-\377/XYZ/c;
+print "not " unless $a eq "XZY";
+print "ok 70\n";
+
+
diff --git a/t/op/ver.t b/t/op/ver.t
index 2eddabd22d..0fe7fd1bbb 100755
--- a/t/op/ver.t
+++ b/t/op/ver.t
@@ -5,10 +5,20 @@ BEGIN {
@INC = '../lib';
}
-print "1..28\n";
+print "1..33\n";
my $test = 1;
+sub okeq {
+ my $ok = $_[0] eq $_[1];;
+ print "not " unless $ok;
+ print "ok ", $test++;
+ print " # $_[2]" if !$ok && @_ == 3;
+ print "\n";
+}
+
+sub skip { print "ok ", $test++, " # Skip: $_[0]\n" }
+
use v5.5.640;
require v5.5.640;
print "ok $test\n"; ++$test;
@@ -45,11 +55,9 @@ if (ord("\t") == 9) { # ASCII
else {
$x = v212.213.214;
}
-print "not " unless $x eq "MNO";
-print "ok $test\n"; ++$test;
+okeq($x, "MNO");
-print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
-print "ok $test\n"; ++$test;
+okeq(v1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}");
#
# now do the same without the "v"
@@ -72,108 +80,94 @@ if (ord("\t") == 9) { # ASCII
else {
$x = 212.213.214;
}
-print "not " unless $x eq "MNO";
-print "ok $test\n"; ++$test;
+okeq($x, "MNO");
-print "not " unless 1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
-print "ok $test\n"; ++$test;
+okeq(1.20.300.4000, "\x{1}\x{14}\x{12c}\x{fa0}");
# test sprintf("%vd"...) etc
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
+ okeq(sprintf("%vd", "Perl"), '80.101.114.108');
}
else {
- print "not " unless sprintf("%vd", "Perl") eq '215.133.153.147';
+ okeq(sprintf("%vd", "Perl"), '215.133.153.147');
}
-print "ok $test\n"; ++$test;
-print "not " unless sprintf("%vd", v1.22.333.4444) eq '1.22.333.4444';
-print "ok $test\n"; ++$test;
+okeq(sprintf("%vd", v1.22.333.4444), '1.22.333.4444');
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
+ okeq(sprintf("%vx", "Perl"), '50.65.72.6c');
}
else {
- print "not " unless sprintf("%vx", "Perl") eq 'd7.85.99.93';
+ okeq(sprintf("%vx", "Perl"), 'd7.85.99.93');
}
-print "ok $test\n"; ++$test;
-print "not " unless sprintf("%vX", 1.22.333.4444) eq '1.16.14D.115C';
-print "ok $test\n"; ++$test;
+okeq(sprintf("%vX", 1.22.333.4444), '1.16.14D.115C');
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%#*vo", ":", "Perl") eq '0120:0145:0162:0154';
+ okeq(sprintf("%#*vo", ":", "Perl"), '0120:0145:0162:0154');
}
else {
- print "not " unless sprintf("%#*vo", ":", "Perl") eq '0327:0205:0231:0223';
+ okeq(sprintf("%#*vo", ":", "Perl"), '0327:0205:0231:0223');
}
-print "ok $test\n"; ++$test;
-print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
- eq '1##10110##101001101##1000101011100';
-print "ok $test\n"; ++$test;
+okeq(sprintf("%*vb", "##", v1.22.333.4444),
+ '1##10110##101001101##1000101011100');
-print "not " unless sprintf("%vd", join("", map { chr }
- unpack 'U*', pack('U*',2001,2002,2003)))
- eq '2001.2002.2003';
-print "ok $test\n"; ++$test;
+okeq(sprintf("%vd", join("", map { chr }
+ unpack 'U*', pack('U*',2001,2002,2003))),
+ '2001.2002.2003');
{
use bytes;
+
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
+ okeq(sprintf("%vd", "Perl"), '80.101.114.108');
}
else {
- print "not " unless sprintf("%vd", "Perl") eq '215.133.153.147';
+ okeq(sprintf("%vd", "Perl"), '215.133.153.147');
}
- print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
- print "not " unless
- sprintf("%vd", 1.22.333.4444) eq '1.22.197.141.225.133.156';
+ okeq(sprintf("%vd", 1.22.333.4444), '1.22.197.141.225.133.156');
}
else {
- print "not " unless
- sprintf("%vd", 1.22.333.4444) eq '1.22.142.84.187.81.112';
+ okeq(sprintf("%vd", 1.22.333.4444), '1.22.142.84.187.81.112');
}
- print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
+ okeq(sprintf("%vx", "Perl"), '50.65.72.6c');
}
else {
- print "not " unless sprintf("%vx", "Perl") eq 'd7.85.99.93';
+ okeq(sprintf("%vx", "Perl"), 'd7.85.99.93');
}
- print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
+ okeq(sprintf("%vX", v1.22.333.4444), '1.16.C5.8D.E1.85.9C');
}
else {
- print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.8E.54.BB.51.70';
+ okeq(sprintf("%vX", v1.22.333.4444), '1.16.8E.54.BB.51.70');
}
- print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%#*vo", ":", "Perl") eq '0120:0145:0162:0154';
+ okeq(sprintf("%#*vo", ":", "Perl"), '0120:0145:0162:0154');
}
else {
- print "not " unless sprintf("%#*vo", ":", "Perl") eq '0327:0205:0231:0223';
+ okeq(sprintf("%#*vo", ":", "Perl"), '0327:0205:0231:0223');
}
- print "ok $test\n"; ++$test;
if (ord("\t") == 9) { # ASCII
- print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
- eq '1##10110##11000101##10001101##11100001##10000101##10011100';
+ okeq(sprintf("%*vb", "##", v1.22.333.4444),
+ '1##10110##11000101##10001101##11100001##10000101##10011100');
}
else {
- print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
- eq '1##10110##10001110##1010100##10111011##1010001##1110000';
+ okeq(sprintf("%*vb", "##", v1.22.333.4444),
+ '1##10110##10001110##1010100##10111011##1010001##1110000');
}
- print "ok $test\n"; ++$test;
}
{
+ # 24..28
+
# bug id 20000323.056
print "not " unless "\x{41}" eq +v65;
@@ -196,3 +190,35 @@ print "ok $test\n"; ++$test;
print "ok $test\n";
$test++;
}
+
+# 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 ''");
+
+# 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.
+ skip("No Socket");
+ }
+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");
+ }
+
+# Chapter 28, pp671
+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");