This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pjf: dual life modules
[perl5.git] / lib / autodie / t / open.t
1 #!/usr/bin/perl -w
2 use strict;
3
4 use Test::More 'no_plan';
5
6 use constant NO_SUCH_FILE => "this_file_had_better_not_exist";
7
8 use autodie;
9
10 eval { open(my $fh, '<', NO_SUCH_FILE); };
11 ok($@, "3-arg opening non-existent file fails");
12 like($@, qr/for reading/, "Well-formatted 3-arg open failure");
13
14 eval { open(my $fh, "< ".NO_SUCH_FILE) };
15 ok($@, "2-arg opening non-existent file fails");
16
17 like($@, qr/for reading/, "Well-formatted 2-arg open failure");
18 unlike($@, qr/GLOB\(0x/, "No ugly globs in 2-arg open messsage");