Commit | Line | Data |
0b09a93a |
1 | #!/usr/bin/perl -w |
2 | use strict; |
3 | |
4 | use Test::More tests => 13; |
5 | |
6 | use constant NO_SUCH_FILE => "this_file_had_better_not_exist"; |
7 | |
8 | eval { |
9 | use autodie ':io'; |
10 | open(my $fh, '<', NO_SUCH_FILE); |
11 | }; |
12 | |
13 | like($@, qr/Can't open '\w+' for reading: /, "Prety printed open msg"); |
14 | like($@, qr{\Q$0\E}, "Our file mention in error message"); |
15 | |
16 | like($@, qr{for reading: '.+'}, "Error should be in single-quotes"); |
17 | like($@->errno,qr/./, "Errno should not be empty"); |
18 | |
19 | like($@, qr{\n$}, "Errors should end with a newline"); |
20 | is($@->file, $0, "Correct file"); |
21 | is($@->function, 'CORE::open', "Correct dying sub"); |
22 | is($@->package, __PACKAGE__, "Correct package"); |
23 | is($@->caller,__PACKAGE__."::__ANON__", "Correct caller"); |
24 | is($@->args->[1], '<', 'Correct mode arg'); |
25 | is($@->args->[2], NO_SUCH_FILE, 'Correct filename arg'); |
26 | ok($@->matches('open'), 'Looks like an error from open'); |
27 | ok($@->matches(':io'), 'Looks like an error from :io'); |