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


Manual Reference Pages  -  TEST2::COMPARE::BASE (3)

.ds Aq ’

NAME

Test2::Compare::Base - Base class for comparison classes.

CONTENTS

DESCRIPTION

All Comparison Classes for Test2::Compare should inherit from this base class.

SYNOPSIS



    package Test2::Compare::MyCheck;
    use strict;
    use warnings;

    use base Test2::Compare::Base;
    use Test2::Util::HashBase qw/stuff/;

    sub name { STUFF }

    sub operator {
        my $self = shift;
        my ($got) = @_;
        return eq;
    }

    sub verify {
        my $self = shift;
        my $params = @_;

        # Always check if $got even exists, this will be false if no value at
        # all was received. (as opposed to a $got of undef or 0 which are
        # valid meaning this field will be true).
        return 0 unless $params{exists};

        my $got = $params{got};

        return $got eq $self->stuff;
    }



METHODS

Some of these must be overriden, others can be.
$dclass = $check->delta_class Returns the delta subclass that should be used. By default Test2::Compare::Delta is used.
@deltas = $check->deltas(id => $id, exists => $bool, got => $got, convert => \&convert, seen => \%seen) Should return child deltas.
@lines = $check->got_lines($got) This is your chance to provide line numbers for errors in the $got structure.
$op = $check->operator()
$op = $check->operator($got) Returns the operator that was used to compare the check with the received data in $got. If there was no value for got then there will be no arguments, undef will only be an argument if undef was seen in $got, this is how you can tell the difference between a missing value and an undefined one.
$bool = $check->verify(id => $id, exists => $bool, got => $got, convert => \&convert, seen => \%seen) Return true if there is a shallow match, that is both items are arrayrefs, both items are the same string or same number, etc. This should not look deep, deep checks are done in $check->deltas().
$name = $check->name Get the name of the check.
$display = $check->render What should be displayed in a table for this check, usually the name or value.
$delta = $check->run(id => $id, exists => $bool, got => $got, convert => \&convert, seen => \%seen) This is where the checking is done, first a shallow check using $check->verify, then checking $check->deltas(). \%seen is used to prevent cycles.

SOURCE

The source code repository for Test2-Suite can be found at http://github.com/Test-More/Test2-Suite/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright 2015 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://dev.perl.org/licenses/

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


perl v5.20.3 TEST2::COMPARE::BASE (3) 2016-03-20

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