diff options
author | Zefram <zefram@fysh.org> | 2017-12-17 11:02:23 +0000 |
---|---|---|
committer | Zefram <zefram@fysh.org> | 2017-12-17 11:02:23 +0000 |
commit | da4e040f42421764ef069371d77c008e6b801f45 (patch) | |
tree | dad219b9c5a660c14705b6544fab2b3572bc2bd9 /lib/overload.t | |
parent | b2cd5cb1d8b3c8a7a7f033784d5134d2fbd8cad8 (diff) | |
parent | d6374f3d794e2a640258023e92e8d922409215ec (diff) | |
download | perl-da4e040f42421764ef069371d77c008e6b801f45.tar.gz |
merge branch zefram/dumb_match
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 12 |
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)) :' |