diff options
Diffstat (limited to 'lib/overload.t')
-rw-r--r-- | lib/overload.t | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t index c1b92c574a..7d076c2bfe 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -1174,5 +1174,29 @@ foreach my $op (qw(<=> == != < <= > >=)) { } } } +{ + # check that overloading works in regexes + { + package Foo493; + use overload + '""' => sub { "^$_[0][0]\$" }, + '.' => sub { + bless [ + $_[2] + ? (ref $_[1] ? $_[1][0] : $_[1]) . ':' .$_[0][0] + : $_[0][0] . ':' . (ref $_[1] ? $_[1][0] : $_[1]) + ], 'Foo493' + }; + } + + my $a = bless [ "a" ], 'Foo493'; + test('a' =~ /$a/); + test('x:a' =~ /x$a/); + test('x:a:=' =~ /x$a=$/); + test('x:a:a:=' =~ /x$a$a=$/); + +} + + # Last test is: -sub last {492} +sub last {496} |