File: Scalar.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (40 lines) | stat: -rw-r--r-- 1,016 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
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;