This file is indexed.

/usr/share/perl5/Test/Deep/JSON.pm is in libtest-deep-json-perl 0.04-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package Test::Deep::JSON;
use strict;
use warnings;
use 5.008_001;
use Test::Deep ();
use Test::Deep::Cmp;
use JSON;
use Exporter::Lite;

our $VERSION = '0.04';

our @EXPORT = qw(json);

sub json ($) {
    my ($expected) = @_;
    return __PACKAGE__->new($expected);
}

sub init {
    my ($self, $expected) = @_;
    $self->{val} = $expected;
}

sub descend {
    my ($self, $got) = @_;
    my $parsed = eval { decode_json($got) };
    if ($@) {
        $self->{error} = $@;
        return 0;
    }
    return Test::Deep::wrap($self->{val})->descend($parsed);
}

sub diagnostics {
    my $self = shift;
    return $self->{error} if defined $self->{error} && length $self->{error};
    return $self->{val}->diagnostics(@_);
}

1;

__END__

=head1 NAME

Test::Deep::JSON - Compare JSON with Test::Deep

=head1 SYNOPSIS

  use Test::Deep;
  use Test::Deep::JSON;

  cmp_deeply {
      foo => 'bar',
      payload => '{"a":1}',
  }, {
      foo => 'bar',
      payload => json({ a => ignore() }),
  };

=head1 DESCRIPTION

Test::Deep::JSON provides C<json($expected)> function to expect that
target can be parsed as a JSON string and matches (by C<cmp_deeply>) with
I<$expected>.

=head1 FUNCTIONS

=over 4

=item json($expected)

Exported by default.

I<$expected> can be anything that C<Test::Deep> recognizes.

This parses the data as a JSON string, and compares the parsed object
and I<$expected> by C<Test::Deep> functionality.

Fails if the data cannot be parsed as a JSON.

=back

=head1 AUTHOR

motemen E<lt>motemen@gmail.comE<gt>

=head1 SEE ALSO

L<Test::Deep>

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut