From: Ilya Zakharevich Date: Mon, 5 Jul 1999 18:24:19 +0000 (-0400) Subject: Re: [ID 19990705.001] Overloading boolean conversion X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fe7ac86adc7dbfe34590b2596930effe07cb024b;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 19990705.001] Overloading boolean conversion Message-Id: <199907052224.SAA10454@monk.mps.ohio-state.edu> p4raw-id: //depot/perl@3652 --- diff --git a/gv.c b/gv.c index d1cf7ae..9fcf55b 100644 --- a/gv.c +++ b/gv.c @@ -1466,7 +1466,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) case dec_amg: SvSetSV(left,res); return left; case not_amg: - ans=!SvOK(res); break; + ans=!SvTRUE(res); break; } return boolSV(ans); } else if (method==copy_amg) { diff --git a/t/pragma/overload.t b/t/pragma/overload.t index 7fd0196..ff8d805 100755 --- a/t/pragma/overload.t +++ b/t/pragma/overload.t @@ -899,5 +899,22 @@ test $bar->{two}, 11; # 205 $bar->{three} = 13; test $bar->[3], 13; # 206 +{ + package B; + use overload bool => sub { ${+shift} }; +} + +my $aaa; +{ my $bbbb = 0; $aaa = bless \$bbbb, B } + +test !$aaa, 1; + +unless ($aaa) { + test 'ok', 'ok'; +} else { + test 'is not', 'ok'; +} + + # Last test is: -sub last {206} +sub last {208}