In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/1c3caf3f8c1b996b57e6fd1e4eadcfb9272a4741?hp=8818d4099a576554d990d17764107b1b1480bead>
- Log ----------------------------------------------------------------- commit 1c3caf3f8c1b996b57e6fd1e4eadcfb9272a4741 Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Feb 27 00:50:08 2011 -0800 [perl #76814] FETCH called twice - || The || case in t/op/tie_fetch_count.t is not a bug, as there are two separate operators operating on it in the test script. In $dummy = $x || $y The || does mg_get($x). If itâs true it returns it and the = does mg_get($x). If $x is false, then $y is returned, so magic is called once on each of $x and $y. Similarly, && will seemingly call mg_get($x) twice if $x is false. If you just write: $x || $y then magic is only called once on $x. This patch corrects the test. ----------------------------------------------------------------------- Summary of changes: t/op/tie_fetch_count.t | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-) diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index a5e652e..6e93452 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -13,8 +13,6 @@ BEGIN { use strict; use warnings; -my $TODO = "Bug 76814"; - my $count = 0; sub TIESCALAR {bless \do {my $var = $_ [1]} => $_ [0];} @@ -84,11 +82,9 @@ $dummy = ~$var ; check_count '~'; # Logical operators $dummy = !$var ; check_count '!'; -TODO: { - local $::TODO = $TODO; - $dummy = $var || 1 ; check_count '||'; - $dummy = ($var or 1); check_count 'or'; -} +tie my $v_1, "main", 0; +$dummy = $v_1 || 1 ; check_count '||'; +$dummy = ($v_1 or 1); check_count 'or'; $dummy = $var && 1 ; check_count '&&'; $dummy = ($var and 1); check_count 'and'; $dummy = ($var xor 1); check_count 'xor'; -- Perl5 Master Repository