summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-14 09:47:58 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:23 +0100
commit5b7508176e5e4ba4f0e051ad3d5cc45dbbe3ab24 (patch)
tree84b31d4ecc75273fe4880cbdd1112490685aa2c5 /lib/overload.t
parent7caeb7be934ab798a490d6205914121a6a935f01 (diff)
downloadperl-5b7508176e5e4ba4f0e051ad3d5cc45dbbe3ab24.tar.gz
pp_length: use TARGi rather rather than sv_setiv()
TARGi(i,1) is equivalent to sv_setiv_mg(TARG,i), except that it inlines some simple common cases. Also add a couple of test for length on an overloaded utf8 string. I don't think it was being tested for properly.
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t
index d778776ef7..b684c4ca33 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -48,7 +48,7 @@ package main;
$| = 1;
BEGIN { require './test.pl'; require './charset_tools.pl' }
-plan tests => 5215;
+plan tests => 5217;
use Scalar::Util qw(tainted);
@@ -2816,6 +2816,16 @@ package bitops2 {
'experimental "bitwise" ops with nomethod'
}
+package length_utf8 {
+ use overload '""' => sub { "\x{100}" };
+ my $o = bless [];
+print length $o, "\n";
+
+ ::is length($o), 1, "overloaded utf8 length";
+ ::is "$o", "\x{100}", "overloaded utf8 value";
+}
+
+
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;
use overload '+' => 'onion';