1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
use Test2::Bundle::Extended -target => 'Test2::Compare::Scalar';
my $one = $CLASS->new(item => 'foo');
is($one->name, '<SCALAR>', "got name");
is($one->operator, '${...}', "Got operator");
ok(!$one->verify(exists => 0), "nothing to verify");
ok(!$one->verify(exists => 1, got => undef), "undef");
ok(!$one->verify(exists => 1, got => 'a'), "not a ref");
ok(!$one->verify(exists => 1, got => {}), "not a scalar ref");
ok($one->verify(exists => 1, got => \'anything'), "Scalar ref");
my $convert = Test2::Compare->can('strict_convert');
is(
[$one->deltas(got => \'foo', convert => $convert, seen => {})],
[],
"Exact match, no delta"
);
like(
[$one->deltas(got => \'bar', convert => $convert, seen => {})],
[
{
got => 'bar',
id => [SCALAR => '$*'],
chk => {'input' => 'foo'},
}
],
"Value pointed to is different"
);
like(
dies { $CLASS->new() },
qr/'item' is a required attribute/,
"item is required"
);
done_testing;
|