Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Deep CPAN distribution.

Report information
The Basics
Id: 81167
Status: resolved
Priority: 0/
Queue: Test-Deep

People
Owner: Nobody in particular
Requestors: zefram [...] fysh.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: comparator junctions modify operands
Date: Wed, 14 Nov 2012 14:42:52 +0000
To: bug-Test-Deep [...] rt.cpan.org
From: Zefram <zefram [...] fysh.org>
perl -lwe 'use Test::More; use Test::Deep; my $comparator = re(qr/a/) & re(qr/b/); cmp_deeply "ab", $comparator; cmp_deeply "abc", $comparator & re(qr/c/); cmp_deeply "ab", $comparator; done_testing()' ok 1 ok 2 not ok 3 # Failed test at -e line 1. # Using Regexp on (Part 3 of 3 in $data) # got : 'ab' # expect : (?-xism:c) 1..3 # Looks like you failed 1 test of 3. The "&" operation in which $comparator is an operand has the side effect of modifying $comparator, permanently incorporating the re(qr/c/) test into it. This breaks subsequent use of $comparator. This can be trivially solved by removing most of the logic from Test::Deep::Cmp::make_{all,any}, along with the overloads on Test::Deep::{All,Any}. In fact, once the special-effort-to-damage-an-operand logic is removed, there's nothing distinctive to those functions left, and the overload declaration may as well refer directly to Test::Deep::{all,any}. (Incidentally, the overload on Test::Deep::Any overloads "&" rather than the correct "|".) -zefram
Subject: Re: [rt.cpan.org #81167] comparator junctions modify operands
Date: Fri, 16 Nov 2012 07:11:46 +0900
To: bug-Test-Deep [...] rt.cpan.org
From: Fergal Daly <fergal [...] esatclear.ie>
Thanks, I will probably just delete them when I get some free time, F
I believed this is addressed in 0.118, now a trial release on the CPAN. The operator overloads are still in place, but no longer modify their arguments. In fact, the undocumented "add" methods on Any and All have been removed. Instead, I have made these two things equivalent: any(1, any(2,3)) any(1, 2, 3) ...so that "re(qr/.../) | any(1,2)" continues to behave the same, except it does not alter the any on the rhs, but returns a new one. I made this a trial release because breaking Test::Deep would be Bad, but I feel fairly good about this change. Although I agree that the overloaded operators do not grant any special value, I'd rather leave them there than go through the trouble of deprecating them, which will be work with very little reward. -- rjbs