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