Test2-Suite
view release on metacpan or search on metacpan
lib/Test2/Tools/Basic.pm view on Meta::CPAN
use Carp qw/croak/;
use Test2::API qw/context/;
our @EXPORT = qw{
ok pass fail diag note todo skip
plan skip_all done_testing bail_out
};
use base 'Exporter';
sub ok($;$@) {
my ($bool, $name, @diag) = @_;
my $ctx = context();
$ctx->ok($bool, $name, \@diag);
$ctx->release;
return $bool ? 1 : 0;
}
sub pass {
my ($name) = @_;
my $ctx = context();
lib/Test2/Tools/ClassicCompare.pm view on Meta::CPAN
use Test2::Compare::OrderedSubset();
use Test2::Compare::Pattern();
use Test2::Compare::Ref();
use Test2::Compare::Regex();
use Test2::Compare::Scalar();
use Test2::Compare::Set();
use Test2::Compare::String();
use Test2::Compare::Undef();
use Test2::Compare::Wildcard();
sub is($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my @caller = caller;
my $delta = compare($got, $exp, \&is_convert);
if ($delta) {
$ctx->fail($name, $delta->diag, @diag);
}
lib/Test2/Tools/Compare.pm view on Meta::CPAN
$module = 'Data::Dumper';
}
my $deparse = $Data::Dumper::Deparse;
$deparse = !!$ENV{'T2_AUTO_DEPARSE'} if exists $ENV{'T2_AUTO_DEPARSE'};
local $Data::Dumper::Deparse = $deparse;
$ctx->diag($module->Dump([$got], ['GOT']));
};
sub is($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my $delta = compare($got, $exp, \&strict_convert);
if ($delta) {
# Temporary thing.
my $count = 0;
my $implicit = 0;
my @deltas = ($delta);
lib/Test2/Tools/Compare.pm view on Meta::CPAN
sub D() {
my @caller = caller;
Test2::Compare::Custom->new(
code => sub { defined $_ ? 1 : 0 }, name => 'DEFINED', operator => 'DEFINED()',
file => $caller[1],
lines => [$caller[2]],
);
}
sub DF() {
my @caller = caller;
Test2::Compare::Custom->new(
code => sub { defined $_ && ( ! ref $_ && ! $_ ) ? 1 : 0 }, name => 'DEFINED BUT FALSE', operator => 'DEFINED() && FALSE()',
file => $caller[1],
lines => [$caller[2]],
);
}
sub DNE() {
my @caller = caller;
t/modules/Util/Times.t view on Meta::CPAN
use Test2::Bundle::Extended;
use Test2::Util::Times qw/render_bench/;
imported_ok qw{ render_bench };
sub TM() { 0.5 }
is(
render_bench(0, 2.123456, TM, TM, TM, TM),
"2.12346s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
"Got benchmark with < 10 second duration"
);
is(
render_bench(0, 42.123456, TM, TM, TM, TM),
"42.1235s on wallclock (0.50 usr 0.50 sys + 0.50 cusr 0.50 csys = 2.00 CPU)",
( run in 3.373 seconds using v1.01-cache-2.11-cpan-524268b4103 )