From 2ab54efd6265713df5cd4bd0927024245675c1c2 Mon Sep 17 00:00:00 2001 From: Michael Breen Date: Fri, 11 Dec 2009 17:48:51 +0000 Subject: fix bug 67156: overload: nomethod(..., '!') return value inverted --- lib/overload.t | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/overload.t') diff --git a/lib/overload.t b/lib/overload.t index d54068eabc..39333cff87 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -47,7 +47,7 @@ sub numify { 0 + "${$_[0]}" } # Not needed, additional overhead package main; $| = 1; -use Test::More tests => 605; +use Test::More tests => 607; $a = new Oscalar "087"; @@ -1420,7 +1420,7 @@ foreach my $op (qw(<=> == != < <= > >=)) { } { - # comparison operators with nomethod + # comparison operators with nomethod (bug 41546) my $warning = ""; my $method; @@ -1466,6 +1466,21 @@ foreach my $op (qw(<=> == != < <= > >=)) { } +{ + # nomethod called for '!' after attempted fallback + my $nomethod_called = 0; + + package nomethod_not; + use overload nomethod => sub { $nomethod_called = 'yes'; }; + + package main; + my $o = bless [], 'nomethod_not'; + my $res = ! $o; + + is($nomethod_called, 'yes', "nomethod() is called for '!'"); + is($res, 'yes', "nomethod(..., '!') return value propagates"); +} + { # Subtle bug pre 5.10, as a side effect of the overloading flag being # stored on the reference rather than the referent. Despite the fact that -- cgit v1.2.1