Test2::Compare - Test2 extension for writing deep comparison tools.
This library is the driving force behind deep comparison tools such as Test2::Tools::Compare::is() and Test2::Tools::ClassicCompare::is_deeply().
Test2::Tools::Compare::is()
Test2::Tools::ClassicCompare::is_deeply()
package Test2::Tools::MyCheck; use Test2::Compare::MyCheck; use Test2::Compare qw/compare/; sub MyCheck { my ($got, $exp, $name, @diag) = @_; my $ctx = context(); my $delta = compare($got, $exp, \&convert); if ($delta) { $ctx->ok(0, $name, [$delta->table, @diag]); } else { $ctx->ok(1, $name); } $ctx->release; return !$delta; } sub convert { my $thing = shift; return $thing if blessed($thing) && $thing->isa('Test2::Compare::MyCheck'); return Test2::Compare::MyCheck->new(stuff => $thing); }
See Test2::Compare::Base for details about writing a custom check.
This will compare the structures in $got with those in $expect, The convert sub should convert vanilla structures inside $expect into checks. If there are differences in the structures they will be reported back as an Test2::Compare::Delta tree.
$got
$expect
Get the current global build, if any.
Set the current global build.
Unset the current global build. This will throw an exception if the build passed in is different from the current global.
Run the provided codeblock with a new instance of $class as the current build. Returns the new build.
$class
Convert $thing to an Test2::Compare::* object. This will behave strictly which means:
$thing
Convert $thing to an Test2::Compare::* object. This will be relaxed which means:
The source code repository for Test2-Suite can be found at http://github.com/Test-More/Test2-Suite/.
Copyright 2016 Chad Granum <exodist@cpan.org>.
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/
To install Test2::Suite, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test2::Suite
CPAN shell
perl -MCPAN -e shell install Test2::Suite
For more information on module installation, please visit the detailed CPAN module installation guide.