This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix =~ $str_overloaded (5.10 regression)
[perl5.git] / lib / overload.t
index 12ed55b..1021a5f 100644 (file)
@@ -48,7 +48,7 @@ package main;
 
 $| = 1;
 BEGIN { require './test.pl' }
-plan tests => 4982;
+plan tests => 5037;
 
 use Scalar::Util qw(tainted);
 
@@ -1793,6 +1793,8 @@ foreach my $op (qw(<=> == != < <= > >=)) {
        # note: this is testing unary qr, not binary =~
        $subs{qr} = '(qr/%s/)';
        push @tests, [ "abc", '"abc" =~ (%s)', '(qr)', '("")', [ 1, 2, 0 ], 0 ];
+       push @tests, [ chr 256, 'chr(256) =~ (%s)', '(qr)', '("")',
+                                                         [ 1, 2, 0 ], 0 ];
 
        $e = '"abc" ~~ (%s)';
        $subs{'~~'} = $e;
@@ -1820,7 +1822,7 @@ foreach my $op (qw(<=> == != < <= > >=)) {
 
        $subs{'%{}'} = '%s';
        push @tests, [ {qw(a 1 b 2 c 3)}, 'join "", sort keys %%{%s}',
-                       '(%{})', undef, [ 1, 2, 0 ], 0 ];
+                       '(%{})', undef, [ 1, 1, 0 ], 0 ];
 
        $subs{'&{}'} = '%s';
        push @tests, [ sub {99}, 'do {&{%s} for 1,2}',
@@ -2173,7 +2175,7 @@ fresh_perl_is
     use overload '+' => 'justice';
     eval {bless[]};
     ::like $@, qr/^Can't resolve method "justice" overloading "\+" in p(?x:
-                  )ackage "overload" at /,
+                  )ackage "Justus" at /,
       'Error message when explicitly named overload method does not exist';
 
     package JustUs;
@@ -2182,8 +2184,17 @@ fresh_perl_is
     "JustUs"->${\"(+"};
     eval {bless []};
     ::like $@, qr/^Stub found while resolving method "\?{3}" overloadin(?x:
-                  )g "\+" in package "overload" at /,
+                  )g "\+" in package "JustUs" at /,
       'Error message when sub stub is encountered';
 }
 
+{ # undefining the overload stash -- KEEP THIS TEST LAST
+    package ant;
+    use overload '+' => 'onion';
+    $_ = \&overload::nil;
+    undef %overload::;
+    bless[];
+    ::ok(1, 'no crash when undefining %overload::');
+}
+
 # EOF