xref: /openbsd-src/gnu/usr.bin/perl/cpan/autodie/t/sysopen.t (revision b39c515898423c8d899e35282f4b395f7cad3298)
1*b39c5158Smillert#!/usr/bin/perl -w
2*b39c5158Smillertuse strict;
3*b39c5158Smillertuse Test::More 'no_plan';
4*b39c5158Smillertuse Fcntl;
5*b39c5158Smillert
6*b39c5158Smillertuse autodie qw(sysopen);
7*b39c5158Smillert
8*b39c5158Smillertuse constant NO_SUCH_FILE => "this_file_had_better_not_be_here_at_all";
9*b39c5158Smillert
10*b39c5158Smillertmy $fh;
11*b39c5158Smillerteval {
12*b39c5158Smillert	sysopen($fh, $0, O_RDONLY);
13*b39c5158Smillert};
14*b39c5158Smillert
15*b39c5158Smillertis($@, "", "sysopen can open files that exist");
16*b39c5158Smillert
17*b39c5158Smillertlike(scalar( <$fh> ), qr/perl/, "Data in file read");
18*b39c5158Smillert
19*b39c5158Smillerteval {
20*b39c5158Smillert	sysopen(my $fh2, NO_SUCH_FILE, O_RDONLY);
21*b39c5158Smillert};
22*b39c5158Smillert
23*b39c5158Smillertisa_ok($@, 'autodie::exception', 'Opening a bad file fails with sysopen');
24