File: open_strict.t

package info (click to toggle)
libtest-mockfile-perl 0.037-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: perl: 4,110; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 543 bytes parent folder | download
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
#!/usr/bin/perl -w

use strict;
use warnings;

use Test2::Bundle::Extended;
use Test2::Plugin::NoWarnings;

use Test::MockFile;

pipe my $fh, my $wfh;
my $fh_str = "$fh";

my $err = dies { open my $fh2, '<', $fh };
like(
    $err,
    qr<\Q$fh_str\E>,
    'open() to read a filehandle fails',
);

ok(
    lives { open my $fh2, '<&', fileno $fh },
    'open() to dup a file descriptor works',
) or note $@;

ok(
    lives { open my $fh2, '<&=', fileno $fh },
    'open() to re-perlify a file descriptor works',
) or note $@;

done_testing;

1;