summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2017-12-17 11:02:23 +0000
committerZefram <zefram@fysh.org>2017-12-17 11:02:23 +0000
commitda4e040f42421764ef069371d77c008e6b801f45 (patch)
treedad219b9c5a660c14705b6544fab2b3572bc2bd9 /lib/overload.t
parentb2cd5cb1d8b3c8a7a7f033784d5134d2fbd8cad8 (diff)
parentd6374f3d794e2a640258023e92e8d922409215ec (diff)
downloadperl-da4e040f42421764ef069371d77c008e6b801f45.tar.gz
merge branch zefram/dumb_match
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/overload.t b/lib/overload.t
index 2afa6cf437..99f5b64adb 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 => 5338;
+plan tests => 5392;
use Scalar::Util qw(tainted);
@@ -1622,6 +1622,11 @@ foreach my $op (qw(<=> == != < <= > >=)) {
is($y, $o, "copy constructor falls back to assignment (preinc)");
}
+{
+ package MatchAbc;
+ use overload '~~' => sub { $_[1] eq "abc" };
+}
+
# only scalar 'x' should currently overload
{
@@ -1835,7 +1840,10 @@ foreach my $op (qw(<=> == != < <= > >=)) {
$e = '"abc" ~~ (%s)';
$subs{'~~'} = $e;
- push @tests, [ "abc", $e, '(~~)', '(NM:~~)', [ 1, 1, 0 ], 0 ];
+ push @tests, [ bless({}, "MatchAbc"), $e, '(~~)', '(NM:~~)',
+ [ 1, 1, 0 ], 0 ];
+ $e = '(%s) ~~ bless({}, "MatchAbc")';
+ push @tests, [ "xyz", $e, '(eq)', '(NM:eq)', [ 1, 1, 0 ], 0 ];
$subs{'-X'} = 'do { my $f = (%s);'
. '$_[1] eq "r" ? (-r ($f)) :'