Test-Stream
view release on metacpan or search on metacpan
lib/Test/Stream/Plugin/Classic.pm view on Meta::CPAN
package Test::Stream::Plugin::Classic;
use strict;
use warnings;
use Test::Stream::Exporter qw/import default_exports/;
default_exports qw/is is_deeply isnt like unlike isa_ok/;
no Test::Stream::Exporter;
use Scalar::Util qw/blessed reftype/;
use Test::Stream::Compare qw/-all/;
use Test::Stream::Context qw/context/;
use Test::Stream::Util qw/rtype render_ref protect/;
use Test::Stream::Compare::String();
use Test::Stream::Compare::Pattern();
use Test::Stream::Plugin::Compare();
sub is($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my @caller = caller;
my $delta = compare($got, $exp, \&is_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
sub isnt($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my @caller = caller;
my $delta = compare($got, $exp, \&isnt_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
else {
$ctx->ok(1, $name);
}
$ctx->release;
return !$delta;
}
sub is_convert {
my ($thing) = @_;
return Test::Stream::Compare::Undef->new()
unless defined $thing;
return Test::Stream::Compare::String->new(input => $thing);
}
sub isnt_convert {
my ($thing) = @_;
return Test::Stream::Compare::Undef->new()
unless defined $thing;
my $str = Test::Stream::Compare::String->new(input => $thing, negate => 1);
}
sub like($$;$@) {
my ($got, $exp, $name, @diag) = @_;
my $ctx = context();
my $delta = compare($got, $exp, \&like_convert);
if ($delta) {
$ctx->ok(0, $name, [$delta->table, @diag]);
}
( run in 1.498 second using v1.01-cache-2.11-cpan-524268b4103 )