4 use Test::More 'no_plan';
6 use constant NO_SUCH_FILE => "this_file_had_better_not_exist";
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");
14 eval { open(my $fh, "< ".NO_SUCH_FILE) };
15 ok($@, "2-arg opening non-existent file fails");
17 like($@, qr/for reading/, "Well-formatted 2-arg open failure");
18 unlike($@, qr/GLOB\(0x/, "No ugly globs in 2-arg open messsage");
20 # RT 47520. 2-argument open without mode would repeat the file
26 open(my $fh, NO_SUCH_FILE);
29 isa_ok($@, 'autodie::exception');
30 like( $@, qr/at \S+ line \d+/, "At least one mention");
31 unlike($@, qr/at \S+ line \d+\s+at \S+ line \d+/, "...but not too mentions");
33 # RT 47520-ish. 2-argument open without a mode should be marked
35 like($@, qr/for reading/, "Well formatted 2-arg open without mode");
37 # We also shouldn't get repeated messages, even if the default mode
38 # was used. Single-arg open always falls through to the default
44 open( NO_SUCH_FILE . "" );
47 isa_ok($@, 'autodie::exception');
48 like( $@, qr/at \S+ line \d+/, "At least one mention");
49 unlike($@, qr/at \S+ line \d+\s+at \S+ line \d+/, "...but not too mentions");