|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/local/share/perl5/Test/Deep/ |
Upload File : |
use strict;
use warnings;
package Test::Deep::Any;
use Scalar::Util ();
use Test::Deep::Cmp;
sub init
{
my $self = shift;
my @list = map {
(Scalar::Util::blessed($_) && $_->isa('Test::Deep::Any'))
? @{ $_->{val} }
: $_
} @_;
$self->{val} = \@list;
}
sub descend
{
my $self = shift;
my $got = shift;
foreach my $cmp (@{$self->{val}})
{
return 1 if Test::Deep::eq_deeply_cache($got, $cmp);
}
return 0;
}
sub renderExp
{
my $self = shift;
my @expect = map {; Test::Deep::wrap($_) } @{ $self->{val} };
my $things = join(", ", map {$_->renderExp} @expect);
return "Any of ( $things )";
}
sub diagnostics
{
my $self = shift;
my ($where, $last) = @_;
my $got = $self->renderGot($last->{got});
my $exp = $self->renderExp;
my $diag = <<EOM;
Comparing $where with Any
got : $got
expected : $exp
EOM
$diag =~ s/\n+$/\n/;
return $diag;
}
4;