1#!/usr/bin/perl -w
2use strict;
3use Test::More;
4use Fatal ();
5
6BEGIN { 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
11use 5.010;
12use warnings ();
13use constant NO_SUCH_FILE => 'this_file_had_better_not_exist_xyzzy';
14no if Fatal::SMARTMATCH_CATEGORY, 'warnings', Fatal::SMARTMATCH_CATEGORY;
15
16plan 'no_plan';
17
18eval {
19	use autodie ':io';
20	open(my $fh, '<', NO_SUCH_FILE);
21};
22
23ok($@,			"Exception thrown"		        );
24ok('open' ~~ $@,	"Exception from open"		        );
25ok(':file' ~~ $@,	"Exception from open / class :file"	);
26ok(':io' ~~ $@,		"Exception from open / class :io"	);
27ok(':all' ~~ $@,	"Exception from open / class :all"	);
28
29eval {
30	use autodie ':io';
31	close(THIS_FILEHANDLE_AINT_OPEN);
32};
33
34ok('close' ~~ $@,	"Exception from close"		        );
35ok(':file' ~~ $@,	"Exception from close / class :file"	);
36ok(':io' ~~ $@,		"Exception from close / class :io"	);
37ok(':all' ~~ $@,	"Exception from close / class :all"	);
38