Debian Codegraph @

cpan/Test2-Suite/t/modules/Compare/Scalar.t

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