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.
use strict;
use warnings;
-my $TODO = "Bug 76814";
-
my $count = 0;
sub TIESCALAR {bless \do {my $var = $_ [1]} => $_ [0];}
# 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';