summaryrefslogtreecommitdiff
path: root/t/uni
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-29 23:33:36 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-29 23:33:36 +0000
commitc9cb0f4189a96c284198e261ba3e6a7df9d31f55 (patch)
treec265fd3eba0d69fc5aa6522292dd92fc8ac7b6f4 /t/uni
parent4d70b921e1187677f4cf1096318a548c16b9b695 (diff)
downloadperl-c9cb0f4189a96c284198e261ba3e6a7df9d31f55.tar.gz
syswrite couldn't correctly handle surprises from UTF-8 overloading.
As part of fixing this, syswrite now tries to take advantage of the UTF-8 cache logic for lengths and offsets on regular scalars. p4raw-id: //depot/perl@28019
Diffstat (limited to 't/uni')
-rw-r--r--t/uni/overload.t49
1 files changed, 39 insertions, 10 deletions
diff --git a/t/uni/overload.t b/t/uni/overload.t
index 478544c89a..5812425ca5 100644
--- a/t/uni/overload.t
+++ b/t/uni/overload.t
@@ -7,7 +7,7 @@ BEGIN {
}
}
-use Test::More tests => 68;
+use Test::More tests => 116;
package UTF8Toggle;
use strict;
@@ -151,17 +151,46 @@ SKIP: {
my $tmpfile = 'overload.tmp';
-foreach my $operator (qw (print)) {
+foreach my $operator ('print', 'syswrite', 'syswrite len', 'syswrite off',
+ 'syswrite len off') {
foreach my $layer ('', ':utf8') {
open my $fh, "+>$layer", $tmpfile or die $!;
- my $u = UTF8Toggle->new("\311\n");
- print $fh $u;
- print $fh $u;
- print $fh $u;
- my $l = UTF8Toggle->new("\351\n", 1);
- print $fh $l;
- print $fh $l;
- print $fh $l;
+ my $pad = $operator =~ /\boff\b/ ? "\243" : "";
+ my $trail = $operator =~ /\blen\b/ ? "!" : "";
+ my $u = UTF8Toggle->new("$pad\311\n$trail");
+ my $l = UTF8Toggle->new("$pad\351\n$trail", 1);
+ if ($operator eq 'print') {
+ print $fh $u;
+ print $fh $u;
+ print $fh $u;
+ print $fh $l;
+ print $fh $l;
+ print $fh $l;
+ } elsif ($operator eq 'syswrite') {
+ syswrite $fh, $u;
+ syswrite $fh, $u;
+ syswrite $fh, $u;
+ syswrite $fh, $l;
+ syswrite $fh, $l;
+ syswrite $fh, $l;
+ } elsif ($operator eq 'syswrite len') {
+ syswrite $fh, $u, 2;
+ syswrite $fh, $u, 2;
+ syswrite $fh, $u, 2;
+ syswrite $fh, $l, 2;
+ syswrite $fh, $l, 2;
+ syswrite $fh, $l, 2;
+ } elsif ($operator eq 'syswrite off'
+ || $operator eq 'syswrite len off') {
+ syswrite $fh, $u, 2, 1;
+ syswrite $fh, $u, 2, 1;
+ syswrite $fh, $u, 2, 1;
+ syswrite $fh, $l, 2, 1;
+ syswrite $fh, $l, 2, 1;
+ syswrite $fh, $l, 2, 1;
+ } else {
+ die $operator;
+ }
seek $fh, 0, 0 or die $!;
my $line;