File: autotie.t

package info (click to toggle)
libio-all-perl 0.87-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 716 kB
  • sloc: perl: 2,017; makefile: 5
file content (32 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (3)
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
use strict; use warnings;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use File::Spec::Functions;
use Test::More;
use IO::All;
use IO_All_Test;

my $f = catfile($t, 'mystuff');
my @lines = read_file_lines($f);
plan(tests => 1 + @lines + 1 + 7);

{
my $io = io($f)->tie;
is($io->autoclose(0) . '', $f);
while (<$io>) {
    is($_, shift @lines);
}
ok(close $io);
}

{
my $f = catfile($t, 'mystuff2');
my @lines = ('This ', 'is ', 'a ', 'silly ', "example\n");
my $io = io($f)->separator(q( ))->tie;
is($io->autoclose(0) . '', $f);
while (<$io>) {
    is($_, shift @lines, $_);
}
ok(close $io);
}

del_output_dir();