| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use Test::More; |
| 4 |
use Fatal (); |
| 5 |
|
| 6 |
BEGIN { plan skip_all => "requires perl with smartmatch support" unless Fatal::SMARTMATCH_ALLOWED; } |
| 7 |
|
| 8 |
# These are tests that depend upon smartmatch. |
| 9 |
# Basic tests should go in basic_exceptions.t |
| 10 |
|
| 11 |
use 5.010; |
| 12 |
use warnings (); |
| 13 |
use constant NO_SUCH_FILE => 'this_file_had_better_not_exist_xyzzy'; |
| 14 |
no if Fatal::SMARTMATCH_CATEGORY, 'warnings', Fatal::SMARTMATCH_CATEGORY; |
| 15 |
|
| 16 |
plan 'no_plan'; |
| 17 |
|
| 18 |
eval { |
| 19 |
use autodie ':io'; |
| 20 |
open(my $fh, '<', NO_SUCH_FILE); |
| 21 |
}; |
| 22 |
|
| 23 |
ok($@, "Exception thrown" ); |
| 24 |
ok('open' ~~ $@, "Exception from open" ); |
| 25 |
ok(':file' ~~ $@, "Exception from open / class :file" ); |
| 26 |
ok(':io' ~~ $@, "Exception from open / class :io" ); |
| 27 |
ok(':all' ~~ $@, "Exception from open / class :all" ); |
| 28 |
|
| 29 |
eval { |
| 30 |
use autodie ':io'; |
| 31 |
close(THIS_FILEHANDLE_AINT_OPEN); |
| 32 |
}; |
| 33 |
|
| 34 |
ok('close' ~~ $@, "Exception from close" ); |
| 35 |
ok(':file' ~~ $@, "Exception from close / class :file" ); |
| 36 |
ok(':io' ~~ $@, "Exception from close / class :io" ); |
| 37 |
ok(':all' ~~ $@, "Exception from close / class :all" ); |