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::TOOLS::CLASSICCOMPARE (3)

.ds Aq ’

NAME

Test2::Tools::ClassicCompare - Classic (Test::More style) comparison tools.

CONTENTS

DESCRIPTION

This provides comparison functions that behave like they did in Test::More, unlike the Test2::Tools::Compare plugin which has modified them.

SYNOPSIS



    use Test2::Tools::ClassicCompare qw/is is_deeply isnt like unlike cmp_ok/;

    is($got, $expect, "these are the same when stringified");
    isnt($got, $unexpect, "these are not the same when stringified");

    like($got, qr/.../, "got matches the pattern");
    unlike($got, qr/.../, "got does not match the pattern");

    is_deeply($got, $expect, "These structures are same when checked deeply");

    cmp_ok($GOT, $OP, $WANT, Compare these items using the specified operatr);



EXPORTS

$bool = is($got, $expect)
$bool = is($got, $expect, $name)
$bool = is($got, $expect, $name, @diag) This does a string comparison of the 2 arguments. If the 2 arguments are the same after stringification the test passes. The test will also pas sif both arguments are undef.

The test $name is optional.

The test @diag is optional, it is extra diagnostics messages that will be displayed if the test fails. The diagnostics are ignored if the test passes.

It is important to note that this tool considers "1" and "1.0" to not be equal as it uses a string comparison.

See Test2::Tools::Compare if you want a is() function that tries to be smarter for you.

$bool = isnt($got, $dont_expect)
$bool = isnt($got, $dont_expect, $name)
$bool = isnt($got, $dont_expect, $name, @diag) This is the inverse of is(), it passes when the strings are not the same.
$bool = like($got, $pattern)
$bool = like($got, $pattern, $name)
$bool = like($got, $pattern, $name, @diag) Check if $got matches the specified pattern. Will fail if it does not match.

The test $name is optional.

The test @diag is optional, it is extra diagnostics messages that will be displayed if the test fails. The diagnostics are ignored if the test passes.

$bool = unlike($got, $pattern)
$bool = unlike($got, $pattern, $name)
$bool = unlike($got, $pattern, $name, @diag) This is the inverse of like(). This will fail if $got matches $pattern.
$bool = is_deeply($got, $expect)
$bool = is_deeply($got, $expect, $name)
$bool = is_deeply($got, $expect, $name, @diag) This does a deep check, it compares the structures in $got with those in $expect. It will recurse into hashrefs, arrayrefs, and scalar refs. All other values will be stringified and compared as strings. It is important to note that this tool considers "1" and "1.0" to not be equal as it uses a string comparison.

This is the same as Test2::Tools::Compare::is().

cmp_ok($got, $op, $expect)
cmp_ok($got, $op, $expect, $name)
cmp_ok($got, $op, $expect, $name, @diag) Compare $got to $expect using the operator specified in $op. This is effectively a eval "\$got $op \$expect" with some other stuff to make it more sane. This is useful for comparing numbers, overloaded objects, etc.

<B>Overloading Note:B> Your input is passed as-is to the comparison. In the event that the comparison fails between 2 overloaded objects, the diagnostics will try to show you the overload form that was used in comparisons. It is possible that the diagnostics will be wrong, though attempts have been made to improve them since Test::More.

<B>Exceptions:B> If the comparison results in an exception then the test will fail and the exception will be shown.

cmp_ok has an internal list of operators it supports. If you provide an unsupported operator it will issue a warning. You can add operators to the %Test2::Tools::ClassicCompare::OPS hash, the key should be the operator, and the value should either be ’str’ for string comparison operators, ’num’ for numeric operators, or any other true value for other operators.

Supported operators:
== (num)
!= (num)
>= (num)
<= (num)
> (num)
< (num)
<=> (num)
eq (str)
ne (str)
gt (str)
lt (str)
ge (str)
le (str)
cmp (str)
!~ (str)
=~ (str)
&&
||
xor
or
and
//
&
|
~~

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::TOOLS::CLASSICCOMPARE (3) 2016-03-20

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