summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-04-29 17:38:08 +0000
committerNicholas Clark <nick@ccl4.org>2006-04-29 17:38:08 +0000
commit676f44e7e401461aa81575a0e3d8e005bbe94251 (patch)
tree117ff07232a8f0b438590194c6df249f7e49a727 /t
parent95be277cce2cef5ea17debb2d60e8f38283b5ecc (diff)
downloadperl-676f44e7e401461aa81575a0e3d8e005bbe94251.tar.gz
print couldn't correctly handle surprises from UTF-8 overloading.
p4raw-id: //depot/perl@28016
Diffstat (limited to 't')
-rw-r--r--t/uni/overload.t45
1 files changed, 43 insertions, 2 deletions
diff --git a/t/uni/overload.t b/t/uni/overload.t
index 95c916ae0d..478544c89a 100644
--- a/t/uni/overload.t
+++ b/t/uni/overload.t
@@ -7,7 +7,7 @@ BEGIN {
}
}
-use Test::More tests => 56;
+use Test::More tests => 68;
package UTF8Toggle;
use strict;
@@ -16,7 +16,9 @@ use overload '""' => 'stringify';
sub new {
my $class = shift;
- return bless [shift, 0], $class;
+ my $value = shift;
+ my $state = shift||0;
+ return bless [$value, $state], $class;
}
sub stringify {
@@ -146,3 +148,42 @@ SKIP: {
is ($uc, "\311", "e accute -> E accute");
}
}
+
+my $tmpfile = 'overload.tmp';
+
+foreach my $operator (qw (print)) {
+ 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;
+
+ seek $fh, 0, 0 or die $!;
+ my $line;
+ chomp ($line = <$fh>);
+ is ($line, "\311", "$operator $layer");
+ chomp ($line = <$fh>);
+ is ($line, "\311", "$operator $layer");
+ chomp ($line = <$fh>);
+ is ($line, "\311", "$operator $layer");
+ chomp ($line = <$fh>);
+ is ($line, "\351", "$operator $layer");
+ chomp ($line = <$fh>);
+ is ($line, "\351", "$operator $layer");
+ chomp ($line = <$fh>);
+ is ($line, "\351", "$operator $layer");
+
+ close $fh or die $!;
+ unlink $tmpfile or die $!;
+ }
+}
+
+
+END {
+ 1 while -f $tmpfile and unlink $tmpfile || die "unlink '$tmpfile': $!";
+}