summaryrefslogtreecommitdiff
path: root/t/uni/chomp.t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2004-01-23 18:28:43 +0000
committerNicholas Clark <nick@ccl4.org>2004-01-23 18:28:43 +0000
commit1858f5c364ee8a037ee41664a9d5964814b7e038 (patch)
treea93a87beb5803ea79fd3447c77b58f292b4010f7 /t/uni/chomp.t
parent442a8c128e085eacd56278a9e7cc5b0e6e864660 (diff)
downloadperl-1858f5c364ee8a037ee41664a9d5964814b7e038.tar.gz
test that use encoding; doesn't cause references to be stringified
p4raw-id: //depot/perl@22200
Diffstat (limited to 't/uni/chomp.t')
-rw-r--r--t/uni/chomp.t18
1 files changed, 16 insertions, 2 deletions
diff --git a/t/uni/chomp.t b/t/uni/chomp.t
index 35eafdf219..00d6e4642a 100644
--- a/t/uni/chomp.t
+++ b/t/uni/chomp.t
@@ -26,8 +26,7 @@ BEGIN {
}
use strict;
-# 2 * (@char ** 3) * (keys %mbchars)
-use Test::More tests => 2 * (4 * 4 * 4) * (3);
+use Test::More;
# %mbchars = (encoding => { bytes => utf8, ... }, ...);
# * pack('C*') is expected to return bytes even if ${^ENCODING} is true.
@@ -46,6 +45,10 @@ our %mbchars = (
},
);
+# 4 == @char; paired tests inside 3 nested loops,
+# plus extra pair of tests in a loop, plus extra pair of tests.
+plan tests => 2 * (4 ** 3 + 4 + 1) * (keys %mbchars);
+
for my $enc (sort keys %mbchars) {
local ${^ENCODING} = find_encoding($enc);
my @char = (sort(keys %{ $mbchars{$enc} }),
@@ -70,5 +73,16 @@ for my $enc (sort keys %mbchars) {
is ($string, $expect); # "$enc \$/=$rs $start $end"
}
}
+ # chomp should not stringify references unless it decides to modify
+ # them
+ $_ = [];
+ my $got = chomp();
+ is ($got, 0);
+ is (ref($_), "ARRAY", "chomp ref (no modify)");
}
+
+ $/ = ")"; # the last char of something like "ARRAY(0x80ff6e4)"
+ my $got = chomp();
+ is ($got, 1);
+ ok (!ref($_), "chomp ref (modify)");
}