Deprecate shellwords.pl with a warning
[p5sagit/p5-mst-13.2.git] / lib / autodie / t / exceptions.t
CommitLineData
0b09a93a 1#!/usr/bin/perl -w
2use strict;
3use Test::More;
4
5BEGIN { plan skip_all => "Perl 5.10 only tests" if $] < 5.010; }
6
7# These are tests that depend upon 5.10 (eg, smart-match).
8# Basic tests should go in basic_exceptions.t
9
10use 5.010;
11use constant NO_SUCH_FILE => 'this_file_had_better_not_exist_xyzzy';
12
13plan 'no_plan';
14
15eval {
16 use autodie ':io';
17 open(my $fh, '<', NO_SUCH_FILE);
18};
19
20ok($@, "Exception thrown" );
035fa39e 21ok($@ ~~ 'open', "Exception from open" );
22ok($@ ~~ ':file', "Exception from open / class :file" );
23ok($@ ~~ ':io', "Exception from open / class :io" );
24ok($@ ~~ ':all', "Exception from open / class :all" );
0b09a93a 25
26eval {
27 no warnings 'once'; # To prevent the following close from complaining.
28 close(THIS_FILEHANDLE_AINT_OPEN);
29};
30
31ok(! $@, "Close without autodie should fail silent");
32
33eval {
34 use autodie ':io';
35 close(THIS_FILEHANDLE_AINT_OPEN);
36};
37
38like($@, qr{Can't close filehandle 'THIS_FILEHANDLE_AINT_OPEN'},"Nice msg from close");
39
40ok($@, "Exception thrown" );
035fa39e 41ok($@ ~~ 'close', "Exception from close" );
42ok($@ ~~ ':file', "Exception from close / class :file" );
43ok($@ ~~ ':io', "Exception from close / class :io" );
44ok($@ ~~ ':all', "Exception from close / class :all" );
0b09a93a 45