table of contents
| Test::Deep::UnorderedPairs(3pm) | User Contributed Perl Documentation | Test::Deep::UnorderedPairs(3pm) |
NAME¶
Test::Deep::UnorderedPairs - A Test::Deep plugin for comparing an unordered list of tuplesVERSION¶
version 0.006SYNOPSIS¶
use Test::More;
use Test::Deep;
use Test::Deep::UnorderedPairs;
cmp_deeply(
{
inventory => [
pear => 6,
peach => 5,
apple => 1,
],
},
{
inventory => unordered_pairs(
apple => 1,
peach => ignore,
pear => 6,
),
},
'got the right inventory',
);
DESCRIPTION¶
This module provides the sub "unordered_pairs" (and "tuples", "samehash", as synonyms) to indicate the data being tested is a list of pairs that should be tested where the order of the pairs is insignificant.This is useful when testing a function that returns a list of hash elements as an arrayref, not a hashref. One such application might be testing PSGI headers, which are passed around as an arrayref:
my $response = [
'200',
[
'Content-Length' => '12',
'Content-Type' => 'text/plain',
],
[ 'hello world!' ],
];
# this test passes
cmp_deeply(
$response,
[
'200',
unordered_pairs(
'Content-Type' => 'text/plain',
'Content-Length' => '12',
],
[ 'hello world!' ],
],
'check headers as an arrayref of unordered pairs',
);
FUNCTIONS¶
"unordered_pairs"¶
Pass an (even-numbered) list of items to test"tuples", "samehash"¶
"tuples" and "samehash" are aliases for "unordered_pairs". I'm open to more names as well; I'm not quite yet sure what the best nomenclature should be.(Be aware that ""samehash"" is a bit of a misnomer, since if a key is repeated, the comparison is not equivalent to comparing as a hash.)
ACKNOWLEDGEMENTS¶
Ricardo Signes, for maintaining Test::Deep and for being the first consumer of this module, in Router::Dumb.SEE ALSO¶
- •
- Test::Deep
SUPPORT¶
Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Deep-UnorderedPairs> (or bug-Test-Deep-UnorderedPairs@rt.cpan.org <mailto:bug-Test-Deep-UnorderedPairs@rt.cpan.org>).There is also a mailing list available for users of this distribution, at <http://lists.perl.org/list/perl-qa.html>.
There is also an irc channel available for users of this distribution, at "#perl" on "irc.perl.org" <irc://irc.perl.org/#perl-qa>.
I am also usually active on irc, as 'ether' at "irc.perl.org".
AUTHOR¶
Karen Etheridge <ether@cpan.org>COPYRIGHT AND LICENCE¶
This software is copyright (c) 2013 by Karen Etheridge.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| 2016-12-25 | perl v5.24.1 |