File: synopsis3.t

package info (click to toggle)
libio-all-perl 0.86-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 712 kB
  • ctags: 248
  • sloc: perl: 2,055; makefile: 5
file content (48 lines) | stat: -rw-r--r-- 1,469 bytes parent folder | download | duplicates (4)
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
use strict; use warnings;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use Test::More tests => 3;
use IO_All_Test;
use Config;

sub fix {
    local $_ = shift;
    if ($^O eq 'MSWin32') {
        s/"/'/g;
        return qq{"$_"};
    }
    return qq{'$_'};
}

undef $/;
# # Copy STDIN to STDOUT
# io('-')->print(io('-')->slurp);
my $test1 = fix 'io("-")->print(io("-")->slurp)';
open TEST, '-|', qq{$^X -Ilib -MIO::All -e $test1 < $t/mystuff}
  or die "open failed: $!";
test_file_contents(<TEST>, "$t/mystuff");
close TEST;

# # Copy STDIN to STDOUT a block at a time
# my $stdin = io('-');
# my $stdout = io('-');
# $stdout->buffer($stdin->buffer);
# $stdout->write while $stdin->read;
my $test2 = fix 'my $stdin = io("-");my $stdout = io("-");$stdout->buffer($stdin->buffer);$stdout->write while $stdin->read';
open TEST, '-|', qq{$^X -Ilib -MIO::All -e $test2 < $t/mystuff}
  or die "open failed: $!";
test_file_contents(<TEST>, "$t/mystuff");
close TEST;

# # Copy STDIN to a String File one line at a time
# my $stdin = io('-');
# my $string_out = io('$');
# while (my $line = $stdin->getline) {
#     $string_out->print($line);
# }
my $test3 = fix 'my $stdin = io("-");my $string_out = io(q{$});while (my $line = $stdin->getline("")) {$string_out->print($line)} print ${$string_out->string_ref}';
open TEST, '-|', qq{$^X -Ilib -MIO::All -e $test3 < $t/mystuff}
  or die "open failed: $!";
test_file_contents(<TEST>, "$t/mystuff");
close TEST;

del_output_dir();