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: 76634
Status: open
Priority: 0/
Queue: Test-Deep

People
Owner: Nobody in particular
Requestors: asuihen [...] gmail.com
Cc:
AdminCc:

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



Subject: feature requirement: hash_without_keys - test the absense of certain keys,
I need to test absence of the certain key(s) in hash ignoring everithing else. Sample usage: cmp_deep( parse('<lot_of_parameters>IMPORTANT_PARAMETER=GOOD_VALUE<lot_of_parameters>'), {'parsed'=>1, 'params' => superhashof('IMPORTANT_PARAMETER' => 'GOOD_VALUE')}, 'test if parameter exist'); cmp_deep( parse('<lot_of_parameters>IMPORTANT_PARAMETER=BAD_VALUE<lot_of_parameters>'), {'parsed'=>1, 'params' => hash_without_keys(['IMPORTANT_PARAMETER'])}, 'test that parameter is absent, because it value is bad'); Of course I can simply check the absence of ineteresting keys one by one by is(exists ...) or even ok(). But it breaks the nice and clean look of my tests, for most of which i use Test::Deep, as resulting structures are complicated.
On Tue Apr 17 07:09:07 2012, https://www.google.com/accounts/o8/id?id=AItOawm2QGNHZQrPYNG_jdD_ZSKOTZQih3GPzHM wrote: Show quoted text
> I need to test absence of the certain key(s) in hash ignoring > everithing > else.
This would be appropriate to implement as a separate plugin. Potential API: use Test::Deep; use Test::Deep::Hash::DoesNotExist; cmp_deeply( $foo, { a => 1, b => 2, c => ignore, d => does_not_exist, }, 'test name', );
Show quoted text
> This would be appropriate to implement as a separate plugin.
This is only possible by embedding DNE support into core Test::Deep methods (specifically, the check that compares the keys list of $got and $wanted needs to be DNE-aware). This can only be accomplished in a separate plugin by monkeypatching core Test::Deep. This is still a reasonable way to go about it, but I'd prefer to fold the functionality into Test::Deep itself as soon as the concept is proven.