From 1c3caf3f8c1b996b57e6fd1e4eadcfb9272a4741 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 27 Feb 2011 00:50:08 -0800 Subject: [PATCH] [perl #76814] FETCH called twice - || MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- t/op/tie_fetch_count.t | 10 +++------- 1 file 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'; -- 2.7.4