auto
  @   �Zƒ›Ù«{‹„„-i[D<†ªo_’I|¥‰ÓMjqØ‚¦ð¬÷a–Ü4ý(Ô¾R( 	Å ‚~ãO)‹FÿÂ  $    ‹      sËÌIUÈË/QHË/ÍKÑã +�©!     ,   ˆl–Ãa¾”d
hŠy@7q¶n JbÑ¿Å„d¶_‡I|¥„ØyeÀÄ ?÷     use strict;
use warnings;
# HARNESS-NO-PRELOAD

my $CLASS;
my %BEFORE_LOAD;

BEGIN {
    my $old = select STDOUT;
    $BEFORE_LOAD{STDOUT} = $|;
    select STDERR;
    $BEFORE_LOAD{STDERR} = $|;
    select $old;

    require Test2::Formatter::TAP;
    $CLASS = 'Test2::Formatter::TAP';
    *OUT_STD = $CLASS->can('OUT_STD') or die "Could not get OUT_STD constant";
    *OUT_ERR = $CLASS->can('OUT_ERR') or die "Could not get OUT_ERR constant";
}

use Test2::Tools::Tiny;
use Test2::API qw/context/;

BEGIN {
    eval {
        require PerlIO;
        PerlIO->VERSION(1.02); # required for PerlIO::get_layers
    } or do {
        print "1..0 # SKIP Don't have PerlIO 1.02\n";
        exit 0;
    }
}

sub grabber {
    my ($std, $err);
    open( my $stdh, '>', \$std ) || die "Ooops";
    open( my $errh, '>', \$err ) || die "Ooops";

    my $it = $CLASS->new(
        handles => [$stdh, $errh, $stdh],
    );

    return ($it, \$std, \$err);
}

tests "IO handle stuff" => sub {
    ok($CLASS->can($_), "$CLASS has the '$_' method") for qw/no_numbers handles/;
    ok($CLASS->isa('Test2::Formatter'), "$CLASS isa Test2::Formatter");

    ok(!$BEFORE_LOAD{STDOUT}, "AUTOFLUSH was not on for STDOUT before load");
    ok(!$BEFORE_LOAD{STDERR}, "AUTOFLUSH was not on for STDERR before load");
    my $old = select STDOUT;
    ok($|, "AUTOFLUSH was turned on for STDOUT");
    select STDERR;
    ok($|, "AUTOFLUSH was turned on for STDERR");
    select $old;

    ok(my $one = $CLASS->new, "Created a new instance");
    my $handles = $one->handles;
    is(@$handles, 2, "Got 2 handles");
    ok($handles->[0] != $handles->[1], "First and second handles are not the same");
    my $layers = {map { $_ => 1 } PerlIO::get_layers($handles->[0])};

    if (${^UNICODE} & 2) {    # 2 means STDIN
        ok($layers->{utf8}, "'S' is set in PERL_UNICODE, or in -C, honor it, utf8 should be on");
    }
    else {
        ok(!$layers->{utf8}, "Not utf8 by default");
    }

    $one->encoding('utf8');
    is($one->encoding, 'utf8', "Got encoding");
    $handles = $one->handles;
    is(@$handles, 2, "Got 2 handles");
    $layers = {map { $_ => 1 } PerlIO::get_layers($handles->[OUT_STD])};
    ok($layers->{utf8}, "Now utf8");

    my $two = $CLASS->new(encoding => 'utf8');
    $handles = $two->handles;
    is(@$handles, 2, "Got 2 handles");
    $layers = {map { $_ => 1 } PerlIO::get_layers($handles->[OUT_STD])};
    ok($layers->{utf8}, "Now utf8");

    $old = select $handles->[OUT_STD];
    ok($|, "AUTOFLUSH was turned on for copy-STDOUT");
    select select $handles->[OUT_ERR];
    ok($|, "AUTOFLUSH was turned on for copy-STDERR");
    select $old;

    ok($CLASS->hide_buffered, "TAP will hide buffered events");
    ok(!$CLASS->no_subtest_space, "Default formatter does not have subtest space");
};

tests optimal_pass => sub {
    my ($it, $out, $err) = grabber();

    my $fail = Test2::Event::Fail->new;
    ok(!$it->print_optimal_pass($fail, 1), "Not gonna print a non-pass");

    $fail = Test2::Event::Ok->new(pass => 0);
    ok(!$it->print_optimal_pass($fail, 1), "Not gonna print a non-pass");

    my $pass = Test2::Event::Pass->new();
    $pass->add_amnesty({tag => 'foo', details => 'foo'});
    ok(!$it->print_optimal_pass($pass, 1), "Not gonna print amnesty");

    $pass = Test2::Event::Ok->new(pass => 1, todo => '');
    ok(!$it->print_optimal_pass($pass, 1), "Not gonna print todo (even empty todo)");

    $pass = Test2::Event::Ok->new(pass => 1, name => "foo # bar");
    ok(!$it->print_optimal_pass($pass, 1), "Not gonna pritn a name with a hash");

    $pass = Test2::Event::Ok->new(pass => 1, name => "foo \n bar");
    ok(!$it->print_optimal_pass($pass, 1), "Not gonna pritn a name with a newline");

    ok(!$$out, "No std output yet");
    ok(!$$err, "No err output yet");

    $pass = Test2::Event::Pass->new();
    ok($it->print_optimal_pass($pass, 1), "Printed a simple pass witho