summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2000-12-05 23:02:39 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2000-12-05 23:02:39 +0000
commiteadce870788b7d714b94b6f31ade209530f13e95 (patch)
tree4871be37d92e76587b3bcc09b063eef8754f112e /t
parentce3e5b80724e7725765c5559e5f4b0058876fc19 (diff)
parentf2b0cce78405182ac37776a9f6651ef31c276b8f (diff)
downloadperl-eadce870788b7d714b94b6f31ade209530f13e95.tar.gz
Integrate mainline.
p4raw-id: //depot/perlio@8003
Diffstat (limited to 't')
-rw-r--r--t/lib/net-hostent.t2
-rw-r--r--t/lib/syslfs.t40
-rwxr-xr-xt/op/each.t14
-rw-r--r--t/op/length.t85
-rw-r--r--t/op/lfs.t38
-rwxr-xr-xt/op/ref.t28
-rw-r--r--t/op/utf8decode.t181
-rwxr-xr-xt/pragma/utf8.t248
8 files changed, 352 insertions, 284 deletions
diff --git a/t/lib/net-hostent.t b/t/lib/net-hostent.t
index a0ec7bd970..b1c7a9db66 100644
--- a/t/lib/net-hostent.t
+++ b/t/lib/net-hostent.t
@@ -41,7 +41,7 @@ print "ok 5\n";
# VMS returns "LOCALHOST" under tcp/ip services V4.1 ECO 2, possibly others
# OS/390 returns localhost.YADDA.YADDA
-if ($^O eq 'MSWin32') {
+if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
print "ok $_ # skipped on win32\n" for (6,7);
} else {
print "not " unless $h->name =~ /^localhost(?:\..+)?$/i;
diff --git a/t/lib/syslfs.t b/t/lib/syslfs.t
index 39a57f36ac..cec839bc43 100644
--- a/t/lib/syslfs.t
+++ b/t/lib/syslfs.t
@@ -26,21 +26,28 @@ sub bye {
exit(0);
}
+my $explained;
+
sub explain {
- print <<EOM;
+ unless ($explained++) {
+ print <<EOM;
#
-# If the lfs (large file support: large meaning larger than two gigabytes)
-# tests are skipped or fail, it may mean either that your process
-# (or process group) is not allowed to write large files (resource
-# limits) or that the file system you are running the tests on doesn't
-# let your user/group have large files (quota) or the filesystem simply
-# doesn't support large files. You may even need to reconfigure your kernel.
-# (This is all very operating system and site-dependent.)
+# If the lfs (large file support: large meaning larger than two
+# gigabytes) tests are skipped or fail, it may mean either that your
+# process (or process group) is not allowed to write large files
+# (resource limits) or that the file system (the network filesystem?)
+# you are running the tests on doesn't let your user/group have large
+# files (quota) or the filesystem simply doesn't support large files.
+# You may even need to reconfigure your kernel. (This is all very
+# operating system and site-dependent.)
#
# Perl may still be able to support large files, once you have
# such a process, enough quota, and such a (file) system.
+# It is just that the test failed now.
#
EOM
+ }
+ print "1..0 # Skip: @_\n" if @_;
}
print "# checking whether we have sparse files...\n";
@@ -120,9 +127,8 @@ sysopen(BIG, "big", O_WRONLY|O_CREAT|O_TRUNC) or
my $sysseek = sysseek(BIG, 5_000_000_000, SEEK_SET);
unless (! $r && defined $sysseek && $sysseek == 5_000_000_000) {
$sysseek = 'undef' unless defined $sysseek;
- print "1..0 # Skip: seeking past 2GB failed: ",
- $r ? 'signal '.($r & 0x7f) : "$! (sysseek returned $sysseek)", "\n";
- explain();
+ explain("seeking past 2GB failed: ",
+ $r ? 'signal '.($r & 0x7f) : "$! (sysseek returned $sysseek)");
bye();
}
@@ -135,11 +141,12 @@ my $close = close BIG;
print "# close failed: $!\n" unless $close;
unless($syswrite && $close) {
if ($! =~/too large/i) {
- print "1..0 # Skip: writing past 2GB failed: process limits?\n";
+ explain("writing past 2GB failed: process limits?");
} elsif ($! =~ /quota/i) {
- print "1..0 # Skip: filesystem quota limits?\n";
+ explain("filesystem quota limits?");
+ } else {
+ explain("error: $!");
}
- explain();
bye();
}
@@ -148,8 +155,7 @@ unless($syswrite && $close) {
print "# @s\n";
unless ($s[7] == 5_000_000_003) {
- print "1..0 # Skip: not configured to use large files?\n";
- explain();
+ explain("kernel/fs not configured to use large files?");
bye();
}
@@ -220,7 +226,7 @@ print "ok 16\n";
fail unless $zero eq "\0\0\0";
print "ok 17\n";
-explain if $fail;
+explain() if $fail;
bye(); # does the necessary cleanup
diff --git a/t/op/each.t b/t/op/each.t
index 879c0d0fd3..4a00a1e2c5 100755
--- a/t/op/each.t
+++ b/t/op/each.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..19\n";
+print "1..20\n";
$h{'abc'} = 'ABC';
$h{'def'} = 'DEF';
@@ -131,3 +131,15 @@ if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }
print "ok 19\n";
}
+# Check for Unicode hash keys.
+%u = ("\x{12}", "f", "\x{123}", "fo", "\x{1234}", "foo");
+$u{"\x{12345}"} = "bar";
+@u{"\x{123456}"} = "zap";
+
+foreach (keys %u) {
+ unless (length() == 1) {
+ print "not ";
+ last;
+ }
+}
+print "ok 20\n";
diff --git a/t/op/length.t b/t/op/length.t
new file mode 100644
index 0000000000..ceb005ecc4
--- /dev/null
+++ b/t/op/length.t
@@ -0,0 +1,85 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+print "1..13\n";
+
+print "not " unless length("") == 0;
+print "ok 1\n";
+
+print "not " unless length("abc") == 3;
+print "ok 2\n";
+
+$_ = "foobar";
+print "not " unless length() == 6;
+print "ok 3\n";
+
+# Okay, so that wasn't very challenging. Let's go Unicode.
+
+{
+ my $a = "\x{41}";
+
+ print "not " unless length($a) == 1;
+ print "ok 4\n";
+ $test++;
+
+ use bytes;
+ print "not " unless $a eq "\x41" && length($a) == 1;
+ print "ok 5\n";
+ $test++;
+}
+
+{
+ my $a = "\x{80}";
+
+ print "not " unless length($a) == 1;
+ print "ok 6\n";
+ $test++;
+
+ use bytes;
+ print "not " unless $a eq "\xc2\x80" && length($a) == 2;
+ print "ok 7\n";
+ $test++;
+}
+
+{
+ my $a = "\x{100}";
+
+ print "not " unless length($a) == 1;
+ print "ok 8\n";
+ $test++;
+
+ use bytes;
+ print "not " unless $a eq "\xc4\x80" && length($a) == 2;
+ print "ok 9\n";
+ $test++;
+}
+
+{
+ my $a = "\x{100}\x{80}";
+
+ print "not " unless length($a) == 2;
+ print "ok 10\n";
+ $test++;
+
+ use bytes;
+ print "not " unless $a eq "\xc4\x80\xc2\x80" && length($a) == 4;
+ print "ok 11\n";
+ $test++;
+}
+
+{
+ my $a = "\x{80}\x{100}";
+
+ print "not " unless length($a) == 2;
+ print "ok 12\n";
+ $test++;
+
+ use bytes;
+ print "not " unless $a eq "\xc2\x80\xc4\x80" && length($a) == 4;
+ print "ok 13\n";
+ $test++;
+}
diff --git a/t/op/lfs.t b/t/op/lfs.t
index e55212fe51..e732adc798 100644
--- a/t/op/lfs.t
+++ b/t/op/lfs.t
@@ -25,21 +25,28 @@ sub bye {
exit(0);
}
+my $explained;
+
sub explain {
- print <<EOM;
+ unless ($explained++) {
+ print <<EOM;
#
-# If the lfs (large file support: large meaning larger than two gigabytes)
-# tests are skipped or fail, it may mean either that your process
-# (or process group) is not allowed to write large files (resource
-# limits) or that the file system you are running the tests on doesn't
-# let your user/group have large files (quota) or the filesystem simply
-# doesn't support large files. You may even need to reconfigure your kernel.
-# (This is all very operating system and site-dependent.)
+# If the lfs (large file support: large meaning larger than two
+# gigabytes) tests are skipped or fail, it may mean either that your
+# process (or process group) is not allowed to write large files
+# (resource limits) or that the file system (the network filesystem?)
+# you are running the tests on doesn't let your user/group have large
+# files (quota) or the filesystem simply doesn't support large files.
+# You may even need to reconfigure your kernel. (This is all very
+# operating system and site-dependent.)
#
# Perl may still be able to support large files, once you have
# such a process, enough quota, and such a (file) system.
+# It is just that the test failed now.
#
EOM
+ }
+ print "1..0 # Skip: @_\n" if @_;
}
print "# checking whether we have sparse files...\n";
@@ -125,8 +132,7 @@ open(BIG, ">big") or do { warn "open failed: $!\n"; bye };
binmode BIG;
if ($r or not seek(BIG, 5_000_000_000, $SEEK_SET)) {
my $err = $r ? 'signal '.($r & 0x7f) : $!;
- print "1..0 # Skip: seeking past 2GB failed: $err\n";
- explain();
+ explain("seeking past 2GB failed: $err");
bye();
}
@@ -138,11 +144,12 @@ my $close = close BIG;
print "# close failed: $!\n" unless $close;
unless ($print && $close) {
if ($! =~/too large/i) {
- print "1..0 # Skip: writing past 2GB failed: process limits?\n";
+ explain("writing past 2GB failed: process limits?");
} elsif ($! =~ /quota/i) {
- print "1..0 # Skip: filesystem quota limits?\n";
+ explain("filesystem quota limits?");
+ } else {
+ explain("error: $!");
}
- explain();
bye();
}
@@ -151,8 +158,7 @@ unless ($print && $close) {
print "# @s\n";
unless ($s[7] == 5_000_000_003) {
- print "1..0 # Skip: not configured to use large files?\n";
- explain();
+ explain("kernel/fs not configured to use large files?");
bye();
}
@@ -224,7 +230,7 @@ print "ok 16\n";
fail unless $zero eq "\0\0\0";
print "ok 17\n";
-explain if $fail;
+explain() if $fail;
bye(); # does the necessary cleanup
diff --git a/t/op/ref.t b/t/op/ref.t
index a2baab8e3b..8ae90424eb 100755
--- a/t/op/ref.t
+++ b/t/op/ref.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..56\n";
+print "1..61\n";
# Test glob operations.
@@ -279,14 +279,34 @@ print $$_,"\n";
print ${\$_} for @a;
}
+# This test is the reason for postponed destruction in sv_unref
+$a = [1,2,3];
+$a = $a->[1];
+print "not " unless $a == 2;
+print "ok 54\n";
+
+sub x::DESTROY {print "ok ", 54 + shift->[0], "\n"}
+{ my $a1 = bless [4],"x";
+ my $a2 = bless [3],"x";
+ { my $a3 = bless [2],"x";
+ my $a4 = bless [1],"x";
+ 567;
+ }
+}
+
+
# test global destruction
+my $test = 59;
+my $test1 = $test + 1;
+my $test2 = $test + 2;
+
package FINALE;
{
- $ref3 = bless ["ok 56\n"]; # package destruction
- my $ref2 = bless ["ok 55\n"]; # lexical destruction
- local $ref1 = bless ["ok 54\n"]; # dynamic destruction
+ $ref3 = bless ["ok $test2\n"]; # package destruction
+ my $ref2 = bless ["ok $test1\n"]; # lexical destruction
+ local $ref1 = bless ["ok $test\n"]; # dynamic destruction
1; # flush any temp values on stack
}
diff --git a/t/op/utf8decode.t b/t/op/utf8decode.t
new file mode 100644
index 0000000000..c631c0a7a9
--- /dev/null
+++ b/t/op/utf8decode.t
@@ -0,0 +1,181 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+print "1..78\n";
+
+my $test = 1;
+
+# This table is based on Markus Kuhn's UTF-8 Decode Stress Tester,
+# http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt,
+# version dated 2000-09-02.
+
+# Note the \0 instead of a raw zero byte in 2.1.1: for example
+# GNU patch v2.1 has "issues" with raw zero bytes.
+
+my @MK = split(/\n/, <<__EOMK__);
+1 Correct UTF-8
+1.1.1 y "κόσμε" - 11 ce:ba:e1:bd:b9:cf:83:ce:bc:ce:b5 5
+2 Boundary conditions
+2.1 First possible sequence of certain length
+2.1.1 y "\0" 0 1 00 1
+2.1.2 y "€" 80 2 c2:80 1
+2.1.3 y "ࠀ" 800 3 e0:a0:80 1
+2.1.4 y "𐀀" 10000 4 f0:90:80:80 1
+2.1.5 y "" 200000 5 f8:88:80:80:80 1
+2.1.6 y "" 4000000 6 fc:84:80:80:80:80 1
+2.2 Last possible sequence of certain length
+2.2.1 y "" 7f 1 7f 1
+2.2.2 y "߿" 7ff 2 df:bf 1
+# The ffff is illegal unless UTF8_ALLOW_FFFF
+2.2.3 n "￿" ffff 3 ef:bf:bf 1 character 0xffff
+2.2.4 y "" 1fffff 4 f7:bf:bf:bf 1
+2.2.5 y "" 3ffffff 5 fb:bf:bf:bf:bf 1
+2.2.6 y "" 7fffffff 6 fd:bf:bf:bf:bf:bf 1
+2.3 Other boundary conditions
+2.3.1 y "퟿" d7ff 3 ed:9f:bf 1
+2.3.2 y "" e000 3 ee:80:80 1
+2.3.3 y "�" fffd 3 ef:bf:bd 1
+2.3.4 y "􏿿" 10ffff 4 f4:8f:bf:bf 1
+2.3.5 y "" 110000 4 f4:90:80:80 1
+3 Malformed sequences
+3.1 Unexpected continuation bytes
+3.1.1 n "" - 1 80 - unexpected continuation byte 0x80
+3.1.2 n "" - 1 bf - unexpected continuation byte 0xbf
+3.1.3 n "" - 2 80:bf - unexpected continuation byte 0x80
+3.1.4 n "" - 3 80:bf:80 - unexpected continuation byte 0x80
+3.1.5 n "" - 4 80:bf:80:bf - unexpected continuation byte 0x80
+3.1.6 n "" - 5 80:bf:80:bf:80 - unexpected continuation byte 0x80
+3.1.7 n "" - 6 80:bf:80:bf:80:bf - unexpected continuation byte 0x80
+3.1.8 n "" - 7 80:bf:80:bf:80:bf:80 - unexpected continuation byte 0x80
+3.1.9 n "" - 64 80:81:82:83:84:85:86:87:88:89:8a:8b:8c:8d:8e:8f:90:91:92:93:94:95:96:97:98:99:9a:9b:9c:9d:9e:9f:a0:a1:a2:a3:a4:a5:a6:a7:a8:a9:aa:ab:ac:ad:ae:af:b0:b1:b2:b3:b4:b5:b6:b7:b8:b9:ba:bb:bc:bd:be:bf - unexpected continuation byte 0x80
+3.2 Lonely start characters
+3.2.1 n " " - 64 c0:20:c1:20:c2:20:c3:20:c4:20:c5:20:c6:20:c7:20:c8:20:c9:20:ca:20:cb:20:cc:20:cd:20:ce:20:cf:20:d0:20:d1:20:d2:20:d3:20:d4:20:d5:20:d6:20:d7:20:d8:20:d9:20:da:20:db:20:dc:20:dd:20:de:20:df:20 - unexpected non-continuation byte 0x20 after byte 0xc0
+3.2.2 n " " - 32 e0:20:e1:20:e2:20:e3:20:e4:20:e5:20:e6:20:e7:20:e8:20:e9:20:ea:20:eb:20:ec:20:ed:20:ee:20:ef:20 - unexpected non-continuation byte 0x20 after byte 0xe0
+3.2.3 n " " - 16 f0:20:f1:20:f2:20:f3:20:f4:20:f5:20:f6:20:f7:20 - unexpected non-continuation byte 0x20 after byte 0xf0
+3.2.4 n " " - 8 f8:20:f9:20:fa:20:fb:20 - unexpected non-continuation byte 0x20 after byte 0xf8
+3.2.5 n " " - 4 fc:20:fd:20 - unexpected non-continuation byte 0x20 after byte 0xfc
+3.3 Sequences with last continuation byte missing
+3.3.1 n "" - 1 c0 - 1 byte, need 2
+3.3.2 n "" - 2 e0:80 - 2 bytes, need 3
+3.3.3 n "" - 3 f0:80:80 - 3 bytes, need 4
+3.3.4 n "" - 4 f8:80:80:80 - 4 bytes, need 5
+3.3.5 n "" - 5 fc:80:80:80:80 - 5 bytes, need 6
+3.3.6 n "" - 1 df - 1 byte, need 2
+3.3.7 n "" - 2 ef:bf - 2 bytes, need 3
+3.3.8 n "" - 3 f7:bf:bf - 3 bytes, need 4
+3.3.9 n "" - 4 fb:bf:bf:bf - 4 bytes, need 5
+3.3.10 n "" - 5 fd:bf:bf:bf:bf - 5 bytes, need 6
+3.4 Concatenation of incomplete sequences
+3.4.1 n "" - 30 c0:e0:80:f0:80:80:f8:80:80:80:fc:80:80:80:80:df:ef:bf:f7:bf:bf:fb:bf:bf:bf:fd:bf:bf:bf:bf - unexpected continuation byte 0xe0
+3.5 Impossible bytes
+3.5.1 n "" - 1 fe - byte 0xfe
+3.5.2 n "" - 1 ff - byte 0xff
+3.5.3 n "" - 4 fe:fe:ff:ff - byte 0xfe
+4 Overlong sequences
+4.1 Examples of an overlong ASCII character
+4.1.1 n "" - 2 c0:af - 2 bytes, need 1
+4.1.2 n "" - 3 e0:80:af - 3 bytes, need 1
+4.1.3 n "" - 4 f0:80:80:af - 4 bytes, need 1
+4.1.4 n "" - 5 f8:80:80:80:af - 5 bytes, need 1
+4.1.5 n "" - 6 fc:80:80:80:80:af - 6 bytes, need 1
+4.2 Maximum overlong sequences
+4.2.1 n "" - 2 c1:bf - 2 bytes, need 1
+4.2.2 n "" - 3 e0:9f:bf - 3 bytes, need 2
+4.2.3 n "" - 4 f0:8f:bf:bf - 4 bytes, need 3
+4.2.4 n "" - 5 f8:87:bf:bf:bf - 5 bytes, need 4
+4.2.5 n "" - 6 fc:83:bf:bf:bf:bf - 6 bytes, need 5
+4.3 Overlong representation of the NUL character
+4.3.1 n "" - 2 c0:80 - 2 bytes, need 1
+4.3.2 n "" - 3 e0:80:80 - 3 bytes, need 1
+4.3.3 n "" - 4 f0:80:80:80 - 4 bytes, need 1
+4.3.4 n "" - 5 f8:80:80:80:80 - 5 bytes, need 1
+4.3.5 n "" - 6 fc:80:80:80:80:80 - 6 bytes, need 1
+5 Illegal code positions
+5.1 Single UTF-16 surrogates
+5.1.1 n "" - 3 ed:a0:80 - UTF-16 surrogate 0xd800
+5.1.2 n "" - 3 ed:ad:bf - UTF-16 surrogate 0xdb7f
+5.1.3 n "" - 3 ed:ae:80 - UTF-16 surrogate 0xdb80
+5.1.4 n "" - 3 ed:af:bf - UTF-16 surrogate 0xdbff
+5.1.5 n "" - 3 ed:b0:80 - UTF-16 surrogate 0xdc00
+5.1.6 n "" - 3 ed:be:80 - UTF-16 surrogate 0xdf80
+5.1.7 n "" - 3 ed:bf:bf - UTF-16 surrogate 0xdfff
+5.2 Paired UTF-16 surrogates
+5.2.1 n "" - 6 ed:a0:80:ed:b0:80 - UTF-16 surrogate 0xd800
+5.2.2 n "" - 6 ed:a0:80:ed:bf:bf - UTF-16 surrogate 0xd800
+5.2.3 n "" - 6 ed:ad:bf:ed:b0:80 - UTF-16 surrogate 0xdb7f
+5.2.4 n "" - 6 ed:ad:bf:ed:bf:bf - UTF-16 surrogate 0xdb7f
+5.2.5 n "" - 6 ed:ae:80:ed:b0:80 - UTF-16 surrogate 0xdb80
+5.2.6 n "" - 6 ed:ae:80:ed:bf:bf - UTF-16 surrogate 0xdb80
+5.2.7 n "" - 6 ed:af:bf:ed:b0:80 - UTF-16 surrogate 0xdbff
+5.2.8 n "" - 6 ed:af:bf:ed:bf:bf - UTF-16 surrogate 0xdbff
+5.3 Other illegal code positions
+5.3.1 n "￾" - 3 ef:bf:be - byte order mark 0xfffe
+# The ffff is illegal unless UTF8_ALLOW_FFFF
+5.3.2 n "￿" - 3 ef:bf:bf - character 0xffff
+__EOMK__
+
+# 104..181
+{
+ my $WARNCNT;
+ my $id;
+
+ local $SIG{__WARN__} =
+ sub {
+ # print "# $id: @_";
+ $WARNCNT++;
+ $WARNMSG = "@_";
+ };
+
+ sub moan {
+ print "$id: @_";
+ }
+
+ sub test_unpack_U {
+ $WARNCNT = 0;
+ $WARNMSG = "";
+ unpack('U*', $_[0]);
+ }
+
+ for (@MK) {
+ if (/^(?:\d+(?:\.\d+)?)\s/ || /^#/) {
+ # 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) =
+ ($2, $3, $4, $5, $6, $7, $8);
+ my @hex = split(/:/, $hex);
+ unless (@hex == $byteslen) {
+ my $nhex = @hex;
+ moan "amount of hex ($nhex) not equal to byteslen ($byteslen)\n";
+ }
+ {
+ use bytes;
+ my $bytesbyteslen = length($bytes);
+ unless ($bytesbyteslen == $byteslen) {
+ moan "bytes length() ($bytesbyteslen) not equal to $byteslen\n";
+ }
+ }
+ if ($okay eq 'y') {
+ test_unpack_U($bytes);
+ if ($WARNCNT) {
+ moan "unpack('U*') 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";
+ print "not ";
+ }
+ }
+ print "ok $test\n";
+ $test++;
+ } else {
+ moan "unknown format\n";
+ }
+ }
+}
diff --git a/t/pragma/utf8.t b/t/pragma/utf8.t
index 60cbd8c97a..8efd571901 100755
--- a/t/pragma/utf8.t
+++ b/t/pragma/utf8.t
@@ -10,7 +10,7 @@ BEGIN {
}
}
-print "1..191\n";
+print "1..103\n";
my $test = 1;
@@ -104,6 +104,7 @@ sub nok_bytes {
ok $1, '123alpha';
$test++; # 12
}
+
{
use utf8;
@@ -204,10 +205,8 @@ sub nok_bytes {
ok $1, pack("C*", 0342);
$test++; # 40
-
}
-
{
no utf8;
$_="\342\230\272>\342\230\272\342\230\272";
@@ -262,6 +261,7 @@ sub nok_bytes {
ok $tmp, pack("C*", 0342, 0230, 0272);
$test++; # 54
}
+
{
use bytes;
no utf8;
@@ -295,7 +295,6 @@ sub nok_bytes {
ok $1, pack("C*", 0342);
$test++; # 64
-
}
ok "\x{ab}" =~ /^\x{ab}$/, 1;
@@ -389,8 +388,6 @@ sub nok_bytes {
{
# bug id 20000323.056
- use utf8;
-
print "not " unless "\x{41}" eq +v65;
print "ok $test\n";
$test++;
@@ -564,242 +561,3 @@ sub nok_bytes {
print "ok $test\n";
$test++;
}
-
-# This table is based on Markus Kuhn's UTF-8 Decode Stress Tester,
-# http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt,
-# version dated 2000-09-02.
-
-# Note the \0 instead of a raw zero byte in 2.1.1: for example
-# GNU patch v2.1 has "issues" with raw zero bytes.
-
-my @MK = split(/\n/, <<__EOMK__);
-1 Correct UTF-8
-1.1.1 y "κόσμε" - 11 ce:ba:e1:bd:b9:cf:83:ce:bc:ce:b5 5
-2 Boundary conditions
-2.1 First possible sequence of certain length
-2.1.1 y "\0" 0 1 00 1
-2.1.2 y "€" 80 2 c2:80 1
-2.1.3 y "ࠀ" 800 3 e0:a0:80 1
-2.1.4 y "𐀀" 10000 4 f0:90:80:80 1
-2.1.5 y "" 200000 5 f8:88:80:80:80 1
-2.1.6 y "" 4000000 6 fc:84:80:80:80:80 1
-2.2 Last possible sequence of certain length
-2.2.1 y "" 7f 1 7f 1
-2.2.2 y "߿" 7ff 2 df:bf 1
-# The ffff is illegal unless UTF8_ALLOW_FFFF
-2.2.3 n "￿" ffff 3 ef:bf:bf 1
-2.2.4 y "" 1fffff 4 f7:bf:bf:bf 1
-2.2.5 y "" 3ffffff 5 fb:bf:bf:bf:bf 1
-2.2.6 y "" 7fffffff 6 fd:bf:bf:bf:bf:bf 1
-2.3 Other boundary conditions
-2.3.1 y "퟿" d7ff 3 ed:9f:bf 1
-2.3.2 y "" e000 3 ee:80:80 1
-2.3.3 y "�" fffd 3 ef:bf:bd 1
-2.3.4 y "􏿿" 10ffff 4 f4:8f:bf:bf 1
-2.3.5 y "" 110000 4 f4:90:80:80 1
-3 Malformed sequences
-3.1 Unexpected continuation bytes
-3.1.1 n "" - 1 80
-3.1.2 n "" - 1 bf
-3.1.3 n "" - 2 80:bf
-3.1.4 n "" - 3 80:bf:80
-3.1.5 n "" - 4 80:bf:80:bf
-3.1.6 n "" - 5 80:bf:80:bf:80
-3.1.7 n "" - 6 80:bf:80:bf:80:bf
-3.1.8 n "" - 7 80:bf:80:bf:80:bf:80
-3.1.9 n "" - 64 80:81:82:83:84:85:86:87:88:89:8a:8b:8c:8d:8e:8f:90:91:92:93:94:95:96:97:98:99:9a:9b:9c:9d:9e:9f:a0:a1:a2:a3:a4:a5:a6:a7:a8:a9:aa:ab:ac:ad:ae:af:b0:b1:b2:b3:b4:b5:b6:b7:b8:b9:ba:bb:bc:bd:be:bf
-3.2 Lonely start characters
-3.2.1 n " " - 64 c0:20:c1:20:c2:20:c3:20:c4:20:c5:20:c6:20:c7:20:c8:20:c9:20:ca:20:cb:20:cc:20:cd:20:ce:20:cf:20:d0:20:d1:20:d2:20:d3:20:d4:20:d5:20:d6:20:d7:20:d8:20:d9:20:da:20:db:20:dc:20:dd:20:de:20:df:20
-3.2.2 n " " - 32 e0:20:e1:20:e2:20:e3:20:e4:20:e5:20:e6:20:e7:20:e8:20:e9:20:ea:20:eb:20:ec:20:ed:20:ee:20:ef:20
-3.2.3 n " " - 16 f0:20:f1:20:f2:20:f3:20:f4:20:f5:20:f6:20:f7:20
-3.2.4 n " " - 8 f8:20:f9:20:fa:20:fb:20
-3.2.5 n " " - 4 fc:20:fd:20
-3.3 Sequences with last continuation byte missing
-3.3.1 n "" - 1 c0
-3.3.2 n "" - 2 e0:80
-3.3.3 n "" - 3 f0:80:80
-3.3.4 n "" - 4 f8:80:80:80
-3.3.5 n "" - 5 fc:80:80:80:80
-3.3.6 n "" - 1 df
-3.3.7 n "" - 2 ef:bf
-3.3.8 n "" - 3 f7:bf:bf
-3.3.9 n "" - 4 fb:bf:bf:bf
-3.3.10 n "" - 5 fd:bf:bf:bf:bf
-3.4 Concatenation of incomplete sequences
-3.4.1 n "" - 30 c0:e0:80:f0:80:80:f8:80:80:80:fc:80:80:80:80:df:ef:bf:f7:bf:bf:fb:bf:bf:bf:fd:bf:bf:bf:bf
-3.5 Impossible bytes
-3.5.1 n "" - 1 fe
-3.5.2 n "" - 1 ff
-3.5.3 n "" - 4 fe:fe:ff:ff
-4 Overlong sequences
-4.1 Examples of an overlong ASCII character
-4.1.1 n "" - 2 c0:af
-4.1.2 n "" - 3 e0:80:af
-4.1.3 n "" - 4 f0:80:80:af
-4.1.4 n "" - 5 f8:80:80:80:af
-4.1.5 n "" - 6 fc:80:80:80:80:af
-4.2 Maximum overlong sequences
-4.2.1 n "" - 2 c1:bf
-4.2.2 n "" - 3 e0:9f:bf
-4.2.3 n "" - 4 f0:8f:bf:bf
-4.2.4 n "" - 5 f8:87:bf:bf:bf
-4.2.5 n "" - 6 fc:83:bf:bf:bf:bf
-4.3 Overlong representation of the NUL character
-4.3.1 n "" - 2 c0:80
-4.3.2 n "" - 3 e0:80:80
-4.3.3 n "" - 4 f0:80:80:80
-4.3.4 n "" - 5 f8:80:80:80:80
-4.3.5 n "" - 6 fc:80:80:80:80:80
-5 Illegal code positions
-5.1 Single UTF-16 surrogates
-5.1.1 n "" - 3 ed:a0:80
-5.1.2 n "" - 3 ed:ad:bf
-5.1.3 n "" - 3 ed:ae:80
-5.1.4 n "" - 3 ed:af:bf
-5.1.5 n "" - 3 ed:b0:80
-5.1.6 n "" - 3 ed:be:80
-5.1.7 n "" - 3 ed:bf:bf
-5.2 Paired UTF-16 surrogates
-5.2.1 n "" - 6 ed:a0:80:ed:b0:80
-5.2.2 n "" - 6 ed:a0:80:ed:bf:bf
-5.2.3 n "" - 6 ed:ad:bf:ed:b0:80
-5.2.4 n "" - 6 ed:ad:bf:ed:bf:bf
-5.2.5 n "" - 6 ed:ae:80:ed:b0:80
-5.2.6 n "" - 6 ed:ae:80:ed:bf:bf
-5.2.7 n "" - 6 ed:af:bf:ed:b0:80
-5.2.8 n "" - 6 ed:af:bf:ed:bf:bf
-5.3 Other illegal code positions
-5.3.1 n "￾" - 3 ef:bf:be
-# The ffff is illegal unless UTF8_ALLOW_FFFF
-5.3.2 n "￿" - 3 ef:bf:bf
-__EOMK__
-
-# 104..181
-{
- my $WARN;
- my $id;
-
- local $SIG{__WARN__} =
- sub {
- # print "# $id: @_";
- $WARN++;
- };
-
- sub moan {
- print "$id: @_";
- }
-
- sub test_unpack_U {
- $WARN = 0;
- unpack('U*', $_[0]);
- }
-
- for (@MK) {
- if (/^(?:\d+(?:\.\d+)?)\s/ || /^#/) {
- # 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+))?$/) {
- $id = $1;
- my ($okay, $bytes, $Unicode, $byteslen, $hex, $charslen) =
- ($2, $3, $4, $5, $6, $7);
- my @hex = split(/:/, $hex);
- unless (@hex == $byteslen) {
- my $nhex = @hex;
- moan "amount of hex ($nhex) not equal to byteslen ($byteslen)\n";
- }
- {
- use bytes;
- my $bytesbyteslen = length($bytes);
- unless ($bytesbyteslen == $byteslen) {
- moan "bytes length() ($bytesbyteslen) not equal to $byteslen\n";
- }
- }
- if ($okay eq 'y') {
- test_unpack_U($bytes);
- unless ($WARN == 0) {
- moan "unpack('U*') false negative\n";
- print "not ";
- }
- } elsif ($okay eq 'n') {
- test_unpack_U($bytes);
- unless ($WARN) {
- moan "unpack('U*') false positive\n";
- print "not ";
- }
- }
- print "ok $test\n";
- $test++;
- } else {
- moan "unknown format\n";
- }
- }
-}
-
-{
- # tests 182..191
-
- {
- my $a = "\x{41}";
-
- print "not " unless length($a) == 1;
- print "ok $test\n";
- $test++;
-
- use bytes;
- print "not " unless $a eq "\x41" && length($a) == 1;
- print "ok $test\n";
- $test++;
- }
-
- {
- my $a = "\x{80}";
-
- print "not " unless length($a) == 1;
- print "ok $test\n";
- $test++;
-
- use bytes;
- print "not " unless $a eq "\xc2\x80" && length($a) == 2;
- print "ok $test\n";
- $test++;
- }
-
- {
- my $a = "\x{100}";
-
- print "not " unless length($a) == 1;
- print "ok $test\n";
- $test++;
-
- use bytes;
- print "not " unless $a eq "\xc4\x80" && length($a) == 2;
- print "ok $test\n";
- $test++;
- }
-
- {
- my $a = "\x{100}\x{80}";
-
- print "not " unless length($a) == 2;
- print "ok $test\n";
- $test++;
-
- use bytes;
- print "not " unless $a eq "\xc4\x80\xc2\x80" && length($a) == 4;
- print "ok $test\n";
- $test++;
- }
-
- {
- my $a = "\x{80}\x{100}";
-
- print "not " unless length($a) == 2;
- print "ok $test\n";
- $test++;
-
- use bytes;
- print "not " unless $a eq "\xc2\x80\xc4\x80" && length($a) == 4;
- print "ok $test\n";
- $test++;
- }
-}
-