Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

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



While Test-Deep-UnorderedPairs seems like it would be useful for some purposes, I'm not sure it would always be useful for the example given in the SYNOPSIS - comparing PSGI responses. The reason being that PSGI header arrayrefs allow repetition: [ Set_Cookie => q[foo='1'; path="/"], Set_Cookie => q[bar='2'; path="/"], ]
Perhaps an additional function could be provided that allowed repeated keys.
Subject: Re: [rt.cpan.org #85470] Disallows repetition within the "keys"
Date: Mon, 20 May 2013 09:42:15 -0700
To: Toby Inkster via RT <bug-Test-Deep-UnorderedPairs [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Mon, May 20, 2013 at 12:38:36PM -0400, Toby Inkster via RT wrote: Show quoted text
> Queue: Test-Deep-UnorderedPairs > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=85470 > > > Perhaps an additional function could be provided that allowed repeated keys.
Agreed, the current implementation would only work if there are no duplicate keys. I'll leave this ticket open while I ponder how to implement what is quite a valid usecase.
The easiest implementation I can see would be to map: [ foo => 3, foo => 2, bar => 1, ] to: [ foo => [3, 2], bar => [1], ] then sort those arrayrefs: [ foo => [2, 3], bar => [1], ] ... and you should be able to do a normal deep comparison.
Subject: Re: [rt.cpan.org #85470] Disallows repetition within the "keys"
Date: Mon, 20 May 2013 15:40:26 -0700
To: Toby Inkster via RT <bug-Test-Deep-UnorderedPairs [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Mon, May 20, 2013 at 05:16:05PM -0400, Toby Inkster via RT wrote: Show quoted text
> then sort those arrayrefs: > > [ > foo => [2, 3], > bar => [1], > ] > > ... and you should be able to do a normal deep comparison.
Doing the comparisons is not difficult - one can even do the comparison like all(bag(pair), bag(pair), ...) -- the trick is getting the diagnostics to look sane on failure. That's why a custom descender is needed.
Fixed in v0.003.