Test-Deep
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
1.129 2020-01-26 - TRIAL RELEASE
- documentation fixes (thanks, Daniel Böhmer!)
- allow NoTest to be used without breaking other Test::Deep
(thanks, Alexander Karelas!)
- added true/false optional imports (thanks, Denis Ibaev!)
1.128 2018-04-18
- numerous small improvements to documentation; thanks to
Fabrice Gabolde, Daniel Böhmer, Lance Wicks, Matthew Horsfall
- improved CI setup; thanks to eadjei and Philip J. Ludlam
1.127 2017-05-04
- no code changes from previous release
1.126_001 2017-04-17
- do not eagerly convert simple scalars into tests in the all, any, and
none tests; this was breaking LeafWrapper application
1.126 2016-12-27
- no changes since v1.125_001
lib/Test/Deep/Ref.pm
lib/Test/Deep/RefType.pm
lib/Test/Deep/Regexp.pm
lib/Test/Deep/RegexpMatches.pm
lib/Test/Deep/RegexpOnly.pm
lib/Test/Deep/RegexpRef.pm
lib/Test/Deep/RegexpRefOnly.pm
lib/Test/Deep/RegexpVersion.pm
lib/Test/Deep/ScalarRef.pm
lib/Test/Deep/ScalarRefOnly.pm
lib/Test/Deep/Set.pm
lib/Test/Deep/Shallow.pm
lib/Test/Deep/Stack.pm
lib/Test/Deep/String.pm
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/all.t
t/any.t
t/array.t
t/array_each.t
t/arraylength.t
lib/Test/Deep/Array.pm view on Meta::CPAN
my $exp = $self->{val};
return 0 unless Test::Deep::descend($got, Test::Deep::arraylength(scalar @$exp));
return 0 unless $self->test_class($got);
return Test::Deep::descend($got, Test::Deep::arrayelementsonly($exp));
}
sub reset_arrow
{
return 0;
}
1;
__END__
=pod
lib/Test/Deep/ArrayElementsOnly.pm view on Meta::CPAN
sub render_stack
{
my $self = shift;
my ($var, $data) = @_;
$var .= "->" unless $Test::Deep::Stack->incArrow;
$var .= "[$data->{index}]";
return $var;
}
sub reset_arrow
{
return 0;
}
1;
__END__
=pod
lib/Test/Deep/Cmp.pm view on Meta::CPAN
return $self->renderGot($self->{val});
}
sub renderGot
{
my $self = shift;
return Test::Deep::render_val(@_);
}
sub reset_arrow
{
return 1;
}
sub data
{
my $self = shift;
return $Test::Deep::Stack->getLast;
}
lib/Test/Deep/Hash.pm view on Meta::CPAN
sub hash_keys
{
require Test::Deep::HashKeys;
my $self = shift;
my $exp = shift;
return Test::Deep::HashKeys->new(keys %$exp);
}
sub reset_arrow
{
return 0;
}
package Test::Deep::SuperHash 1.204;
use base 'Test::Deep::Hash';
sub hash_elements
{
lib/Test/Deep/HashElements.pm view on Meta::CPAN
sub render_stack
{
my $self = shift;
my ($var, $data) = @_;
$var .= "->" unless $Test::Deep::Stack->incArrow;
$var .= '{"'.quotemeta($data->{index}).'"}';
return $var;
}
sub reset_arrow
{
return 0;
}
package Test::Deep::SuperHashElements 1.204;
use base 'Test::Deep::HashElements';
sub getMaster
{
lib/Test/Deep/HashKeysOnly.pm view on Meta::CPAN
}
return 1;
}
sub diagnostics
{
my $self = shift;
my ($where, $last) = @_;
my $type = $self->{IgnoreDupes} ? "Set" : "Bag";
my $error = $last->{diag};
my $diag = <<EOM;
Comparing hash keys of $where
$error
EOM
return $diag;
}
lib/Test/Deep/MM.pm view on Meta::CPAN
foreach my $attr (@_)
{
if ($attr =~ /^[a-z]/)
{
no strict 'refs';
*{$mpkg."::$attr"} = \&{$attr};
}
else
{
my $get_name = $mpkg."::get$attr";
my $set_name = $mpkg."::set$attr";
my $get_sub = sub {
return $_[0]->{$attr};
};
my $set_sub = sub {
return $_[0]->{$attr} = $_[1];
};
{
no strict 'refs';
*$get_name = $get_sub;
*$set_name = $set_sub;
push(@{$pkg."::ISA"}, $mpkg);
}
}
}
}
sub new
{
my $pkg = shift;
lib/Test/Deep/Set.pm view on Meta::CPAN
use strict;
use warnings;
package Test::Deep::Set 1.204;
use Test::Deep::Cmp;
sub init
{
my $self = shift;
$self->{IgnoreDupes} = shift;
$self->{SubSup} = shift;
lib/Test/Deep/Stack.pm view on Meta::CPAN
use Scalar::Util;
use Test::Deep::MM qw( new init Stack Arrow );
sub init
{
my $self = shift;
$self->SUPER::init(@_);
$self->setStack([]) unless $self->getStack;
}
sub push
{
my $self = shift;
push(@{$self->getStack}, @_);
}
sub pop
cmp_deeply($v1, $b1);
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Bag
Missing: 'b', 'b'
Extra: 'c', 'c'
EOM
},
"circular double set not eq"
);
check_test(
sub {
cmp_bag([1, 2, 2], [2, 1, 2]);
},
{
actual_ok => 1,
},
"cmp_bag eq"
},
"matches global not eq"
);
}
{
my $re = qr/(..)/;
check_test(
sub {
cmp_deeply("abababcdcdefef", re($re, set(qw( ab cd ef )), "g"));
},
{
actual_ok => 1,
diag => "",
},
"matches re and set eq"
);
check_test(
sub {
cmp_deeply("cat=2,dog=67,sheep=3,goat=2,dog=5",
re(qr/(\D+)=\d+,?/, set(qw( cat sheep dog )), "g"))
},
{
actual_ok => 0,
diag => <<EOM,
Comparing [\$data =~ (?$xism:(\\D+)=\\d+,?)] as a Set
Extra: 'goat'
EOM
},
"string runre not eq"
);
}
{
require Over;
use strict;
use warnings;
use lib 't/lib';
use Std;
{
check_test(
sub {
cmp_deeply([], set());
},
{
actual_ok => 1,
diag => "",
},
"empty eq"
);
check_test(
sub {
cmp_deeply(["a"], set("a", "a"));
},
{
actual_ok => 1,
diag => "",
},
"empty eq"
);
check_test(
sub {
cmp_deeply(['a', 'b', 'b', ['c', 'd']], set('b', 'a', ['c', 'd'], 'b'));
},
{
actual_ok => 1,
diag => "",
},
"3 elem eq"
);
check_test(
sub {
cmp_deeply(['a', [], 'b', 'b'], set());
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Set
Extra: 'a', 'b', 1 reference
EOM
},
"empty extra"
);
check_test(
sub {
cmp_deeply([], set('a', [], 'a', 'b'));
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Set
Missing: 'a', 'b', 1 reference
EOM
},
"empty missing"
);
check_test(
sub {
cmp_deeply(['a', 'a', 'b', [\"c"], "d", []], set({}, 'a', [\"c"], 'd', 'd', "e"));
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Set
Missing: 'e', 1 reference
Extra: 'b', 1 reference
EOM
},
"extra and missing"
);
check_test(
sub {
cmp_deeply("a", set());
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Set
got : 'a'
expect : An array to use as a Set
EOM
},
"no array"
);
check_test(
sub {
cmp_deeply(['a',['a', 'b', 'b'], ['c', 'd', 'c','d'], ['a', 'b', 'a']],
set(set('c', 'd', 'd'), set('a', 'b', 'a'), set('c', 'c', 'd'), 'a')
);
},
{
actual_ok => 1,
diag => '',
},
"set of sets eq"
);
check_test(
sub {
cmp_deeply([['a', 'b', 'c'], ['c', 'd', 'c'], ['a', 'b', 'a']],
set(set('c', 'd', 'c'), set('a', 'b', 'a'), set('b', 'b', 'a'))
);
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Set
Extra: 1 reference
EOM
},
"set of sets not eq"
);
my $b1 = set('a');
my $b2 = [set('b')];
$b1->add($b1, $b2, $b1);
$b2->[0]->add($b2, $b1, $b2);
my $v1 = ['a'];
my $v2 = [['b']];
push(@$v1, $v2, $v1, $v2);
push(@{$v2->[0]}, $v1, $v2, $v1);
check_test(
sub {
cmp_deeply($v1, $b1);
},
{
actual_ok => 1,
diag => '',
},
"circular double set eq"
);
$b1->add('b', 'b');
push(@$v1, 'c', 'c');
check_test(
sub {
cmp_deeply($v1, $b1);
},
{
actual_ok => 0,
diag => <<EOM,
Comparing \$data as a Set
Missing: 'b'
Extra: 'c'
EOM
},
"circular double set not eq"
);
check_test(
sub {
cmp_set([1, 2, 2], [1, 1, 2]);
},
{
actual_ok => 1,
},
"cmp_set eq"
);
check_test(
sub {
cmp_set([1, 2, 2, 3], [1, 1, 2]);
},
{
actual_ok => 0,
},
"cmp_set not eq"
);
}
{
my $a1 = \"a";
my $b1 = \"b";
my $a2 = \"a";
my $b2 = \"b";
TODO:
{
todo_skip(
"Because I want to get it out the door see notes on bags and sets",
5
);
check_test(
sub {
cmp_deeply([[\'a', \'b']], set(set($a2, $b1), set($b2, $a1)))
},
{
actual_ok => 1,
diag => "",
},
"set compare()"
);
}
check_test(
sub {
cmp_deeply(['a', 'b', 'c', 'a'], supersetof('b', 'a', 'b'));
},
{
actual_ok => 1,
diag => "",
},
"supersetof yes"
);
check_test(
sub {
cmp_deeply(['a', 'b', 'c', 'a'], supersetof('d', 'b', 'd'));
},
{
actual_ok => 0,
diag => <<'EOM',
Comparing $data as a SuperSet
Missing: 'd'
EOM
},
"supersetof no"
);
check_test(
sub {
cmp_deeply(['b', 'a', 'b'], subsetof('a', 'b', 'c', 'a'));
},
{
actual_ok => 1,
diag => "",
},
"subsetof yes"
);
check_test(
sub {
cmp_deeply(['d', 'b', 'd'], subsetof('a', 'b', 'c', 'a'));
},
{
actual_ok => 0,
diag => <<'EOM',
Comparing $data as a SubSet
Extra: 'd'
EOM
},
"subsetof no"
);
}
{
check_test(
sub {
cmp_deeply(['a', 'b', 'c'], noneof('d', 'e', 'f'));
},
{
actual_ok => 1,
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.615 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )