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::Report.
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::Report 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::Report->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 $module, [ @arguments ]
Check whether the module can be loaded correctly with given arguments. This never dies, only returns a failure.
require_ok My::Module
Require, but do not call import. This never dies, only returns a failure.
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 "get_sign" in Assert::Refute::Report 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 generates same data";
};
Unlike the Test::More counterpart, it will not first after first mismatch and print details about 10 mismatching entries.
is_deeply_diff( $got, $expected, $max_diff )
Same as above, but the third parameter specifies the number of mismatches in data to be reported.
[EXPERIMENTAL] name and meaning may change in the future. a $max_diff
of 0 would lead to unpredictable results.
deep_diff( $old, $new )
Not exported by default. Compares 2 scalars recursively, outputs nothing if they are identical, or a complete difference if they differ.
The exact difference format shall not be relied upon.
LICENSE AND COPYRIGHT
This module is part of Assert::Refute suite.
Copyright 2017-2018 Konstantin S. Uvarin. <khedin at cpan.org>
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: