1use Test2::Bundle::Extended -target => 'Test2::Compare::Undef';
2
3my $undef = $CLASS->new();
4my $isdef = $CLASS->new(negate => 1);
5
6isa_ok($undef, $CLASS, 'Test2::Compare::Base');
7isa_ok($isdef, $CLASS, 'Test2::Compare::Base');
8
9subtest name => sub {
10    is($undef->name, '<UNDEF>', "got expected name for undef");
11    is($isdef->name, '<UNDEF>', "got expected name for negated undef");
12};
13
14subtest operator => sub {
15    is($undef->operator(),    'IS', "Operator is 'IS'");
16    is($undef->operator('a'), 'IS', "Operator is 'IS'");
17
18    is($isdef->operator(),    'IS NOT', "Operator is 'IS NOT'");
19    is($isdef->operator('a'), 'IS NOT', "Operator is 'IS NOT'");
20};
21
22subtest verify => sub {
23    ok(!$undef->verify(exists => 0, got => undef), 'does not verify against DNE');
24    ok(!$undef->verify(exists => 1, got => {}),    'ref will not verify');
25    ok(!$undef->verify(exists => 1, got => 'x'),   'not looking for a string');
26    ok(!$undef->verify(exists => 1, got => 1),     'not looking for a number');
27    ok(!$undef->verify(exists => 1, got => 0),     'not looking for a 0');
28    ok($undef->verify(exists => 1, got => undef),  'got undef');
29
30    ok(!$isdef->verify(exists => 0, got => undef), 'does not verify against DNE');
31    ok(!$isdef->verify(exists => 1, got => undef), 'got undef');
32    ok($isdef->verify(exists => 1, got => {}),    'ref is defined');
33    ok($isdef->verify(exists => 1, got => 'x'),   'string is defined');
34    ok($isdef->verify(exists => 1, got => 1),     'number is defined');
35    ok($isdef->verify(exists => 1, got => 0),     '0 is defined');
36};
37
38done_testing;
39