summaryrefslogtreecommitdiffstats
path: root/t/basic.t
blob: 0df64955db452c72d9fcfe5e6c6098fbfd7245e1 (plain) (blame)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use IO::Pty::Easy;

my $pty = IO::Pty::Easy->new(handle_pty_size => 0);

my $script = <<'SCRIPT';
use strict;
use warnings;
use Term::Filter::Callback;
my $term = Term::Filter::Callback->new;
$term->run($^X, '-ple', q[last if /^$/]);
print "done\n";
SCRIPT

my $crlf = "\x0d\x0a";

$pty->spawn($^X, '-Ilib', '-e', $script);

# just in case
alarm 60;

$pty->write("foo\n");
is($pty->read(undef, 5), "foo$crlf");
is($pty->read(undef, 5), "foo$crlf");
$pty->write("bar\nbaz\n");
is($pty->read(undef, 5), "bar$crlf");
is($pty->read(undef, 5), "baz$crlf");
is($pty->read(undef, 5), "bar$crlf");
is($pty->read(undef, 5), "baz$crlf");
$pty->write("\n");
is($pty->read(undef, 2), "$crlf");
is($pty->read(undef, 6), "done\n");

done_testing;