File: Ref.t

package info (click to toggle)
libtest-simple-perl 1.302211-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,972 kB
  • sloc: perl: 19,894; makefile: 7
file content (37 lines) | stat: -rw-r--r-- 896 bytes parent folder | download | duplicates (9)
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
use Test2::Bundle::Extended -target => 'Test2::Compare::Ref';

my $ref = sub { 1 };
my $one = $CLASS->new(input => $ref);
isa_ok($one, $CLASS, 'Test2::Compare::Base');

like($one->name, qr/CODE\(.*\)/, "Got Name");
is($one->operator, '==', "got operator");

ok($one->verify(exists => 1, got => $ref), "verified ref");
ok(!$one->verify(exists => 1, got => sub { 1 }), "different ref");
ok(!$one->verify(exists => 0, got => $ref), "value must exist");

is(
    [ 'a', $ref ],
    [ 'a', $one ],
    "Did a ref check"
);

ok(!$one->verify(exists => 1, got => 'a'), "not a ref");

$one->set_input('a');
ok(!$one->verify(exists => 1, got => $ref), "input not a ref");

like(
    dies { $CLASS->new() },
    qr/'input' is a required attribute/,
    "Need input"
);

like(
    dies { $CLASS->new(input => 'a') },
    qr/'input' must be a reference, got 'a'/,
    "Input must be a ref"
);

done_testing;