This file is indexed.

/usr/share/perl5/Test2/Compare/Negatable.pm is in libtest2-suite-perl 0.000063-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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package Test2::Compare::Negatable;
use strict;
use warnings;

our $VERSION = '0.000063';

require overload;
require Test2::Util::HashBase;

sub import {
    my ($pkg, $file, $line) = caller;

    my $sub = eval <<"    EOT" or die $@;
package $pkg;
#line $line "$file"
sub { overload->import('!' => 'clone_negate', fallback => 1); Test2::Util::HashBase->import('negate')}
    EOT

    $sub->();

    no strict 'refs';
    *{"$pkg\::clone_negate"} = \&clone_negate;
    *{"$pkg\::toggle_negate"} = \&toggle_negate;
}

sub clone_negate {
    my $self = shift;
    my $clone = $self->clone;
    $clone->toggle_negate;
    return $clone;
}

sub toggle_negate {
    my $self = shift;
    $self->set_negate($self->negate ? 0 : 1);
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::Compare::Negatable - Poor mans 'role' for compare objects that can be negated.

=head1 DESCRIPTION

Using this package inside an L<Test2::Compare::Base> subclass will overload
C<!$obj> and import C<clone_negate()> and C<toggle_negate()>.

=head1 WHY?

Until perl 5.18 the 'fallback' parameter to L<overload> would not be inherited,
so we cannot use inheritance for the behavior we actually want. This module
works around the problem by emulating the C<use overload> call we want for each
consumer class.

=head1 ATTRIBUTES

=over 4

=item $bool = $obj->negate

=item $obj->set_negate($bool)

=item $attr = NEGATE()

The NEGATE attribute will be added via L<Test2::Util::HashBase>.

=back

=head1 METHODS

=over 4

=item $clone = $obj->clone_negate()

Create a shallow copy of the object, and call C<toggle_negate> on it.

=item $obj->toggle_negate()

Toggle the negate attribute. If the attribute was on it will now be off, if it
was off it will now be on.

=back

=head1 SOURCE

The source code repository for Test2-Suite can be found at
F<http://github.com/Test-More/Test2-Suite/>.

=head1 MAINTAINERS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>

=back

=head1 AUTHORS

=over 4

=item Chad Granum E<lt>exodist@cpan.orgE<gt>

=back

=head1 COPYRIGHT

Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>.

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

See F<http://dev.perl.org/licenses/>

=cut