NAME
Fennec::Assert::Core::More - Assertion library that mirrors Test::More's functionality.
DESCRIPTION
This assertion library exports testers nearly identical to those in Test::More. There have been a couple changes in output, and some have been expanded to be more flexible, however they should be almost completely compatible with Test::More's.
TESTERS
These are exported for use within tests, each one generates at least 1 result.
- is($got, $want; $name)
-
Tests that $got == $want. Works for any scalar value, references must be the same reference or they will fail, if an argument is an array it will compare its size to the other argument.
- isnt($got, $want; $name)
-
The inverse of is, test passes if $got and $want are not the same.
- like($got, $want; $name)
-
Checks $got against $want, $want can be a qr// style regex, or a string which will be used inside a regex.
- unlike($got, $want; $name)
-
Inverse of like, true if $got does not match $want.
- can_ok(*thing; @list )
-
Tests that *thing is a class name, or object that implements the listed methods. *thing can be a bareword, the name of a class in a string, or a blessed object.
- isa_ok(*thing; @list )
-
Tests that *thing is a class name, or object that has each item from @list in its inheritance. *thing can be a bareword, the name of a class in a string, or a blessed object.
- is_deeply($got, $want; $name)
-
Compare one data structure to another. It will ignore blessed status of any objects. ['a'] and bless(['a'], 'XXX') will be considered the same, as will bless(['a'], 'XXX') and bless(['a'], 'YYY' ). CODE refs must be the same reference or they will fail, there is not currently a (good) way to verify 2 CODE references are identical.
- advanced_is(got => $got, want => $want, name => $name, %options)
-
Like is_deeply except you can pass in extra options to control comparisons.
Options:
advanced_is( ... # Verify blessed things are blessed in both datastructures, and blessed # as the same class. bless => 1, # Do not compare codereferences, just ensure both datastructures have a # coderef at the same point. no_code_checks => 1, )
INTERNAL API FUNCTIONS
These are functions that work behind the scenes to do the tests. They may be useful in other assertion libraries, they are documented here for that reason, none are exported, you must manually import them, or use them with the fully qualified package name.
- @errors = compare($got, $want; $specs)
-
Used by is_deeply() and is_advanced(). Compares the datastructures $got and $want and returns any differences in error form. The messages will take the form of a location identifier '{a}[1]{b}[4]...' showing the point in the datastructure that differs, followed by what was expected and what was found.
$specs is a hashref containing extra arguments available to is_advanced().
- @errors = ARRAY_compare($got, $want; $specs)
-
Used buy compare() to compare 2 arrays. Datastructures nested within the array will also be compared.
- @errors = HASH_compare($got, $want; $specs)
-
Used by compare() to compare 2 hashes. Datastructures nested within the array will also be compared.
- @errors = REGEXP_compare( \$got, \$want )
-
Alias to SCALAR_compare().
In perl 5.12.0 REGEXPs have become a proper type, in older versions this is never used
- @errors = SCALAR_compare(\$got, \$want)
-
NOTE: $got and $want must be references to scalars being compared, not the scalars themselves.
Used anywhere 2 scalars are compared, that includes qr// style regex's.
- @errors = CODE_compare($got, $want; $specs)
-
Used by compare() to compare 2 CODE refs.
AUTHORS
Chad Granum exodist7@gmail.com
COPYRIGHT
Copyright (C) 2010 Chad Granum
Fennec is free software; Standard perl licence.
Fennec is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.