{
package perl31793;
use overload cmp => sub { 0 };
+ package perl31793_fb;
+ use overload cmp => sub { 0 }, fallback => 1;
package main;
my $o = bless [], 'perl31793';
+ my $of = bless [], 'perl31793_fb';
my $no = bless [], 'no_overload';
test (overload::StrVal(\"scalar") =~ /^SCALAR\(0x[0-9a-f]+\)$/);
test (overload::StrVal([]) =~ /^ARRAY\(0x[0-9a-f]+\)$/);
test (overload::StrVal(\$o) =~ /^REF\(0x[0-9a-f]+\)$/);
test (overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/);
test (overload::StrVal($o) =~ /^perl31793=ARRAY\(0x[0-9a-f]+\)$/);
+ test (overload::StrVal($of) =~ /^perl31793_fb=ARRAY\(0x[0-9a-f]+\)$/);
test (overload::StrVal($no) =~ /^no_overload=ARRAY\(0x[0-9a-f]+\)$/);
}
}
}
}
+{
+ # 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=$/);
+
+}
+
+{
+ my $twenty_three = 23;
+ # Check that constant overloading propagates into evals
+ BEGIN { overload::constant integer => sub { 23 } }
+ test(eval "17", $twenty_three);
+}
+
+
# Last test is:
-sub last {492}
+sub last {498}