NAME
Assert::Refute::T::Basic - a set of most common checks for Assert::Refute suite
DESCRIPTION
This module contains most common test conditions similar to those in Test::More, like is $got, $expected;
or like $got, qr/.../;
.
They appear as both exportable functions in this module and Assert::Refute itself and as corresponding methods in Assert::Refute::Exec.
FUNCTIONS
All functions below are prototyped to be used without parentheses and exported by default. Scalar context is imposed onto arguments, so
is @foo, @bar;
would actually compare arrays by length.
If a contract { ... }
is in action, the results of each assertion will be recorded there. See Assert::Refute::Exec for more. If Test::More is in action, a unit testing script is assumed. If neither is true, an exception is thrown.
In addition, a Assert::Refute::Exec->function_name
method with the same signature is generated for each of them (see Assert::Refute::Build).
is $got, $expected, "explanation"
Check for equality, undef
equals undef
and nothing else.
isnt $got, $expected, "explanation"
The reverse of is().
ok $condition, "explanation"
use_ok
Not really tested well.
cpm_ok $value1, 'operation', $value2, "explanation"
Currently supported: < <= == != >= >
lt le eq ne ge gt
Fails if any argument is undefined.
like $got, qr/.../, "explanation"
like $got, "regex", "explanation"
UNLIKE Test::More, accepts string argument just fine.
If argument is plain scalar, it is anchored to match the WHOLE string, so that "foobar"
does NOT match "ob"
, but DOES match ".*ob.*"
OR qr/ob/
.
unlike $got, "regex", "explanation"
The exact reverse of the above.
UNLIKE Test::More, accepts string argument just fine.
If argument is plain scalar, it is anchored to match the WHOLE string, so that "foobar"
does NOT match "ob"
, but DOES match ".*ob.*"
OR qr/ob/
.
can_ok
isa_ok
contract_is $contract, "signature", ["message"]
Check that a contract has been fullfilled to exactly the specified extent.
See "signature" in Assert::Refute::Exec for exact signature format.
diag @message
Human-readable diagnostic message.
References are automatically serialized to depth 1.
note @message
Human-readable comment message.
References are automatically serialized to depth 1.
is_deeply( $got, $expected )
my $check = contract {
my $arg = shift;
my $expected = naive_impl( $arg );
is_deeply fast_impl( $arg ), $expected, "fast_impl ok for";
};
Unlike the Test::More counterpart, prints all found discrepancies, although in a weird format. Better difference formatting wanted.
deep_diff( $old, $new )
Not exported by default. Compares 2 scalars recursively, outputs nothing if they are identical, or a (somewhat strange) in-depth summary if they differ.
LICENSE AND COPYRIGHT
This module is part of Assert::Refute suite.
Copyright 2017 Konstantin S. Uvarin. <khedin at gmail.com>
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.