summaryrefslogtreecommitdiff
path: root/t/uni
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-30 11:14:04 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-30 11:14:04 +0000
commit73ee8be2712c500c98e5976864ba96726bf311e2 (patch)
tree69af13d297713caa615426fcc1c9262ed09a8540 /t/uni
parentd34786ba12ee5b96d9e34dd6fcdda158d7d2597b (diff)
downloadperl-73ee8be2712c500c98e5976864ba96726bf311e2.tar.gz
index and rindex couldn't correctly handle surprises from UTF-8
overloading. p4raw-id: //depot/perl@28022
Diffstat (limited to 't/uni')
-rw-r--r--t/uni/overload.t32
1 files changed, 31 insertions, 1 deletions
diff --git a/t/uni/overload.t b/t/uni/overload.t
index 5812425ca5..ef61667448 100644
--- a/t/uni/overload.t
+++ b/t/uni/overload.t
@@ -7,7 +7,7 @@ BEGIN {
}
}
-use Test::More tests => 116;
+use Test::More tests => 190;
package UTF8Toggle;
use strict;
@@ -212,6 +212,36 @@ foreach my $operator ('print', 'syswrite', 'syswrite len', 'syswrite off',
}
}
+my $little = "\243\243";
+my $big = " \243 $little ! $little ! $little \243 ";
+my $right = rindex $big, $little;
+my $right1 = rindex $big, $little, 11;
+my $left = index $big, $little;
+my $left1 = index $big, $little, 4;
+
+cmp_ok ($right, ">", $right1, "Sanity check our rindex tests");
+cmp_ok ($left, "<", $left1, "Sanity check our index tests");
+
+foreach my $b ($big, UTF8Toggle->new($big)) {
+ foreach my $l ($little, UTF8Toggle->new($little),
+ UTF8Toggle->new($little, 1)) {
+ is (rindex ($b, $l), $right, "rindex");
+ is (rindex ($b, $l), $right, "rindex");
+ is (rindex ($b, $l), $right, "rindex");
+
+ is (rindex ($b, $l, 11), $right1, "rindex 11");
+ is (rindex ($b, $l, 11), $right1, "rindex 11");
+ is (rindex ($b, $l, 11), $right1, "rindex 11");
+
+ is (index ($b, $l), $left, "index");
+ is (index ($b, $l), $left, "index");
+ is (index ($b, $l), $left, "index");
+
+ is (index ($b, $l, 4), $left1, "index 4");
+ is (index ($b, $l, 4), $left1, "index 4");
+ is (index ($b, $l, 4), $left1, "index 4");
+ }
+}
END {
1 while -f $tmpfile and unlink $tmpfile || die "unlink '$tmpfile': $!";