diff options
author | Nicholas Clark <nick@ccl4.org> | 2004-01-23 17:41:01 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2004-01-23 17:41:01 +0000 |
commit | 0a61292d87a3ad96dcd4c6518e0d39ab9feb225d (patch) | |
tree | 984d1213dba0804a44dba01f75234f41e8e495df | |
parent | 132d8bbf73395c4dba67e9728802e28e74a22baa (diff) | |
download | perl-0a61292d87a3ad96dcd4c6518e0d39ab9feb225d.tar.gz |
Check the return values of chomp
(more tricky than it may seem, as the return value is unicode)
p4raw-id: //depot/perl@22198
-rw-r--r-- | t/uni/chomp.t | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/t/uni/chomp.t b/t/uni/chomp.t index 1cb3d155c2..35eafdf219 100644 --- a/t/uni/chomp.t +++ b/t/uni/chomp.t @@ -26,7 +26,8 @@ BEGIN { } use strict; -use Test::More tests => (4 * 4 * 4) * (3); # (@char ** 3) * (keys %mbchars) +# 2 * (@char ** 3) * (keys %mbchars) +use Test::More tests => 2 * (4 * 4 * 4) * (3); # %mbchars = (encoding => { bytes => utf8, ... }, ...); # * pack('C*') is expected to return bytes even if ${^ENCODING} is true. @@ -55,9 +56,18 @@ for my $enc (sort keys %mbchars) { for my $start (@char) { for my $end (@char) { my $string = $start.$end; - my $expect = $end eq $rs ? $start : $string; - chomp $string; - is($string, $expect); + my ($expect, $return); + if ($end eq $rs) { + $expect = $start; + # The answer will always be a length in utf8, even if the + # scalar was encoded with a different length + $return = length ($end . "\x{100}") - 1; + } else { + $expect = $string; + $return = 0; + } + is (chomp ($string), $return); + is ($string, $expect); # "$enc \$/=$rs $start $end" } } } |