This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_length should stringify before checking DO_UTF8
[perl5.git] / t / op / length.t
index 0288bec..dffc583 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-plan (tests => 37);
+plan (tests => 39);
 
 print "not " unless length("")    == 0;
 print "ok 1\n";
@@ -224,4 +224,17 @@ is($ul, undef, "Assigned length of overloaded undef with result in TARG");
     print length undef;
 }
 
+{
+    local $SIG{__WARN__} = sub {
+       pass '[perl #106726] no crash with length @lexical warning'
+    };
+    eval ' sub { length my @forecasts } ';
+}
+
+# length could be fooled by UTF8ness of non-magical variables changing with
+# stringification.
+my $ref = [];
+bless $ref, "\x{100}";
+is length $ref, length "$ref", 'length on reference blessed to utf8 class';
+
 is($warnings, 0, "There were no other warnings");