Atomic-Pipe

 view release on metacpan or  search on metacpan

t/truncated_mixed.t  view on Meta::CPAN

    like($err, qr/invalid state/i, "a message truncated by EOF throws");
};

subtest partial_message_pre_eof_returns_empty => sub {
    my ($r, $w) = Atomic::Pipe->pair(mixed_data_mode => 1);
    syswrite($w->wh, substr($wire, 0, $cut)) or die "syswrite: $!";
    $r->blocking(0);

    my ($err, @got) = one_call($r);
    unlike($err, qr/DEADLINE/, "the call returned instead of spinning");
    is($err, '', "no exception while the writer is still alive");
    ok(!@got, "returned empty: nothing complete yet, caller may retry");

    # Deliver the rest; the reassembled message must come through intact.
    syswrite($w->wh, substr($wire, $cut)) or die "syswrite: $!";
    ($err, @got) = one_call($r);
    is($err, '', "no exception once the message completed");
    my %got = @got;
    is($got{message}, 'A' x 100, "the completed message arrived intact");
};



( run in 1.183 second using v1.01-cache-2.11-cpan-df04353d9ac )