Debian Codegraph @

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

raw
1 use Test2::Bundle::Extended -target => 'Test2::Compare::Ref';
2
3 my $ref = sub { 1 };
4 my $one = $CLASS->new(input => $ref);
5 isa_ok($one, $CLASS, 'Test2::Compare::Base');
6
7 like($one->name, qr/CODE\(.*\)/, "Got Name");
8 is($one->operator, '==', "got operator");
9
10 ok($one->verify(exists => 1, got => $ref), "verified ref");
11 ok(!$one->verify(exists => 1, got => sub { 1 }), "different ref");
12 ok(!$one->verify(exists => 0, got => $ref), "value must exist");
13
14 is(
15 [ 'a', $ref ],
16 [ 'a', $one ],
17 "Did a ref check"
18 );
19
20 ok(!$one->verify(exists => 1, got => 'a'), "not a ref");
21
22 $one->set_input('a');
23 ok(!$one->verify(exists => 1, got => $ref), "input not a ref");
24
25 like(
26 dies { $CLASS->new() },
27 qr/'input' is a required attribute/,
28 "Need input"
29 );
30
31 like(
32 dies { $CLASS->new(input => 'a') },
33 qr/'input' must be a reference, got 'a'/,
34 "Input must be a ref"
35 );
36
37 done_testing;