<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Test2::Compare::Bool;
use strict;
use warnings;

use Carp qw/confess/;

use base 'Test2::Compare::Base';

our $VERSION = '0.000162';

use Test2::Util::HashBase qw/input/;

# Overloads '!' for us.
use Test2::Compare::Negatable;

sub name {
    my $self = shift;
    my $in = $self-&gt;{+INPUT};
    return _render_bool($in);
}

sub operator {
    my $self = shift;
    return '!=' if $self-&gt;{+NEGATE};
    return '==';
}

sub verify {
    my $self = shift;
    my %params = @_;
    my ($got, $exists) = @params{qw/got exists/};

    return 0 unless $exists;

    my $want = $self-&gt;{+INPUT};

    my $match = ($want xor $got) ? 0 : 1;
    $match = $match ? 0 : 1 if $self-&gt;{+NEGATE};

    return $match;
}

sub run {
    my $self = shift;
    my $delta = $self-&gt;SUPER::run(@_) or return;

    my $dne = $delta-&gt;dne || "";
    unless ($dne eq 'got') {
        my $got = $delta-&gt;got;
        $delta-&gt;set_got(_render_bool($got));
    }

    return $delta;
}

sub _render_bool {
    my $bool = shift;
    my $name = $bool ? 'TRUE' : 'FALSE';
    my $val = defined $bool ? $bool : 'undef';
    $val = "''" unless length($val);

    return "&lt;$name ($val)&gt;";
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test2::Compare::Bool - Compare two values as booleans

=head1 DESCRIPTION

Check if two values have the same boolean result (both true, or both false).

=head1 SOURCE

The source code repository for Test2-Suite can be found at
F&lt;https://github.com/Test-More/Test2-Suite/&gt;.

=head1 MAINTAINERS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 AUTHORS

=over 4

=item Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;

=back

=head1 COPYRIGHT

Copyright 2018 Chad Granum E&lt;lt&gt;exodist@cpan.orgE&lt;gt&gt;.

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

See F&lt;http://dev.perl.org/licenses/&gt;

=cut
</pre></body></html>