Assert::Refute::T::Basic - a set of most common checks for Assert::Refute suite
This module contains most common test conditions similar to those in Test::More, like is $got, $expected; or like $got, qr/.../;.
is $got, $expected;
like $got, qr/.../;
They appear as both exportable functions in this module and Assert::Refute itself and as corresponding methods in Assert::Refute::Report.
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.
contract { ... }
In addition, a Assert::Refute::Report->function_name method with the same signature is generated for each of them (see Assert::Refute::Build).
Assert::Refute::Report->function_name
Check for equality, undef equals undef and nothing else.
undef
The reverse of is().
Check whether the module can be loaded correctly with given arguments. This never dies, only returns a failure.
Require, but do not call import. This never dies, only returns a failure.
Currently supported: < <= == != >= > lt le eq ne ge gt
< <= == != >= >
lt le eq ne ge gt
Fails if any argument is undefined.
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/.
"foobar"
"ob"
".*ob.*"
qr/ob/
The exact reverse of the above.
Check that a contract has been fullfilled to exactly the specified extent.
See "get_sign" in Assert::Refute::Report for exact signature format.
Human-readable diagnostic message.
References are automatically serialized to depth 1.
Human-readable comment message.
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.
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.
$max_diff
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.
Declare the test ok. Synonym for ok(1)
Declare the test not ok. Synonym for ok(0)
This module is part of Assert::Refute suite.
Copyright 2017-2018 Konstantin S. Uvarin. <khedin at cpan.org>
<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:
http://www.perlfoundation.org/artistic_license_2_0
To install Assert::Refute, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Assert::Refute
CPAN shell
perl -MCPAN -e shell install Assert::Refute
For more information on module installation, please visit the detailed CPAN module installation guide.