summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-27 04:17:24 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-27 04:17:24 +0000
commit78f67eb5ee42ac6b16274177e3472ab2362e0fbf (patch)
treeff4ded7523715d9b511db6e14e668a002474f0c1
parent656b9f42446ec12c1cc99492757549d1b04f7382 (diff)
downloadperl-78f67eb5ee42ac6b16274177e3472ab2362e0fbf.tar.gz
Forgot from #8545. Oops.
p4raw-id: //depot/perl@8561
-rw-r--r--pp.c2
-rwxr-xr-xt/pragma/overload.t44
2 files changed, 40 insertions, 6 deletions
diff --git a/pp.c b/pp.c
index d9b0685a43..bbb6b820f5 100644
--- a/pp.c
+++ b/pp.c
@@ -2576,7 +2576,7 @@ PP(pp_sqrt)
PP(pp_int)
{
- djSP; dTARGET;
+ djSP; dTARGET; tryAMAGICun(int);
{
NV value;
IV iv = TOPi; /* attempt to convert to IV if possible. */
diff --git a/t/pragma/overload.t b/t/pragma/overload.t
index bf24c07ec9..2cf937b6b7 100755
--- a/t/pragma/overload.t
+++ b/t/pragma/overload.t
@@ -970,6 +970,38 @@ unless ($aaa) {
test($a =~ /^`1' is not a code reference at/); # 215
}
+{
+ my $c = 0;
+ package ov_int1;
+ use overload '""' => sub { 3+shift->[0] },
+ '0+' => sub { 10+shift->[0] },
+ 'int' => sub { 100+shift->[0] };
+ sub new {my $p = shift; bless [shift], $p}
+
+ package ov_int2;
+ use overload '""' => sub { 5+shift->[0] },
+ '0+' => sub { 30+shift->[0] },
+ 'int' => sub { 'ov_int1'->new(1000+shift->[0]) };
+ sub new {my $p = shift; bless [shift], $p}
+
+ package noov_int;
+ use overload '""' => sub { 2+shift->[0] },
+ '0+' => sub { 9+shift->[0] };
+ sub new {my $p = shift; bless [shift], $p}
+
+ package main;
+
+ my $x = new noov_int 11;
+ my $int_x = int $x;
+ main::test("$int_x" eq 20); # 216
+ $x = new ov_int1 31;
+ $int_x = int $x;
+ main::test("$int_x" eq 131); # 217
+ $x = new ov_int2 51;
+ $int_x = int $x;
+ main::test("$int_x" eq 1054); # 218
+}
+
# make sure that we don't inifinitely recurse
{
my $c = 0;
@@ -979,10 +1011,12 @@ unless ($aaa) {
'bool' => sub { shift },
fallback => 1;
my $x = bless([]);
- main::test("$x" =~ /Recurse=ARRAY/); # 216
- main::test($x); # 217
- main::test($x+0 =~ /Recurse=ARRAY/); # 218
-};
+ main::test("$x" =~ /Recurse=ARRAY/); # 219
+ main::test($x); # 220
+ main::test($x+0 =~ /Recurse=ARRAY/); # 221
+}
+
+
# Last test is:
-sub last {218}
+sub last {221}