summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/op/lc.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/t/op/lc.t b/t/op/lc.t
index a390c63c86..2ce65ac73c 100644
--- a/t/op/lc.t
+++ b/t/op/lc.t
@@ -1,6 +1,8 @@
#!./perl
# This file is intentionally encoded in latin-1.
+#
+# Test uc(), lc(), fc(), ucfirst(), lcfirst(), quotemeta() etc
BEGIN {
chdir 't' if -d 't';
@@ -14,7 +16,7 @@ BEGIN {
use feature qw( fc );
-plan tests => 134 + 4 * 256;
+plan tests => 139 + 4 * 256;
is(lc(undef), "", "lc(undef) is ''");
is(lcfirst(undef), "", "lcfirst(undef) is ''");
@@ -317,6 +319,28 @@ $h{k} = bless[], "\x{130}bcde"; # U+0130 grows with lc()
like lc delete $h{k}, qr "^i\x{307}bcde=array\(.*\)",
'lc(TEMP ref) does not produce a corrupt string';
+# List::Util::first() etc sets $_ to an SvTEMP without raising its
+# refcount. This was causing lc() etc to unsafely modify in-place.
+# see http://nntp.perl.org/group/perl.perl5.porters/228213
+
+SKIP: {
+ skip "no List::Util on miniperl", 5, if is_miniperl;
+ require List::Util;
+ my %hl = qw(a 1 b 2 c 3);
+ my %hu = qw(A 1 B 2 C 3);
+ my $x;
+ $x = List::Util::first(sub { uc $_ eq 'A' }, keys %hl);
+ is($x, "a", "first { uc }");
+ $x = List::Util::first(sub { ucfirst $_ eq 'A' }, keys %hl);
+ is($x, "a", "first { ucfirst }");
+ $x = List::Util::first(sub { lc $_ eq 'a' }, keys %hu);
+ is($x, "A", "first { lc }");
+ $x = List::Util::first(sub { lcfirst $_ eq 'a' }, keys %hu);
+ is($x, "A", "first { lcfirst }");
+ $x = List::Util::first(sub { fc $_ eq 'a' }, keys %hu);
+ is($x, "A", "first { fc }");
+}
+
my $utf8_locale = find_utf8_ctype_locale();