GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Deep::UnorderedPairs(3) User Contributed Perl Documentation Test::Deep::UnorderedPairs(3)

Test::Deep::UnorderedPairs - A Test::Deep plugin for comparing an unordered list of tuples

version 0.006

    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',
    );

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',
    );

Pass an (even-numbered) list of items to test

"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.)

Ricardo Signes, for maintaining Test::Deep and for being the first consumer of this module, in Router::Dumb.

Test::Deep

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".

Karen Etheridge <ether@cpan.org>

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-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.