Commit | Line | Data |
0b09a93a |
1 | #!/usr/bin/perl -w |
2 | use strict; |
3 | use Test::More 'no_plan'; |
4 | use Fcntl; |
5 | |
6 | use autodie qw(sysopen); |
7 | |
8 | use constant NO_SUCH_FILE => "this_file_had_better_not_be_here_at_all"; |
9 | |
10 | my $fh; |
11 | eval { |
12 | sysopen($fh, $0, O_RDONLY); |
13 | }; |
14 | |
15 | is($@, "", "sysopen can open files that exist"); |
16 | |
17 | like(scalar( <$fh> ), qr/perl/, "Data in file read"); |
18 | |
19 | eval { |
20 | sysopen(my $fh2, NO_SUCH_FILE, O_RDONLY); |
21 | }; |
22 | |
23 | isa_ok($@, 'autodie::exception', 'Opening a bad file fails with sysopen'); |