diff options
author | Nicholas Clark <nick@ccl4.org> | 2004-01-15 00:03:04 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2004-01-15 00:03:04 +0000 |
commit | c4c87a065d5684a07ac86a151149508724e14d4e (patch) | |
tree | 7a31550bcb46ef9edc1895fe18e15e2246b03e2c /t/op/chop.t | |
parent | 2e038148849ab01588058f0158033f74c84f47f5 (diff) | |
download | perl-c4c87a065d5684a07ac86a151149508724e14d4e.tar.gz |
Make chomp heed the utf8 flags on the target string and $/
[Fixes #24888]
More work still needed to make chomp heed the encoding pragma.
p4raw-id: //depot/perl@22155
Diffstat (limited to 't/op/chop.t')
-rwxr-xr-x | t/op/chop.t | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/t/op/chop.t b/t/op/chop.t index 87700de929..68025b7f3a 100755 --- a/t/op/chop.t +++ b/t/op/chop.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 51; +plan tests => 91; $_ = 'abc'; $c = do foo(); @@ -183,3 +183,29 @@ ok($@ =~ /Can\'t modify.*chop.*in.*assignment/); eval 'chomp($x, $y) = (1, 2);'; ok($@ =~ /Can\'t modify.*chom?p.*in.*assignment/); +my @chars = ("N", "\xd3", substr ("\xd4\x{100}", 0, 1), chr 1296); +foreach my $start (@chars) { + foreach my $end (@chars) { + local $/ = $end; + my $message = "start=" . ord ($start) . " end=" . ord $end; + my $string = $start . $end; + chomp $string; + is ($string, $start, $message); + + my $end_utf8 = $end; + utf8::encode ($end_utf8); + next if $end_utf8 eq $end; + + # $end ne $end_utf8, so these should not chomp. + $string = $start . $end_utf8; + my $chomped = $string; + chomp $chomped; + is ($chomped, $string, "$message (end as bytes)"); + + $/ = $end_utf8; + $string = $start . $end; + $chomped = $string; + chomp $chomped; + is ($chomped, $string, "$message (\$/ as bytes)"); + } +} |