File: exceptions-smartmatch.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (37 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w
use strict;
use Test::More;
use Fatal ();

BEGIN { plan skip_all => "requires perl with smartmatch support" unless Fatal::SMARTMATCH_ALLOWED; }

# These are tests that depend upon smartmatch.
# Basic tests should go in basic_exceptions.t

use 5.010;
use warnings ();
use constant NO_SUCH_FILE => 'this_file_had_better_not_exist_xyzzy';
no if Fatal::SMARTMATCH_CATEGORY, 'warnings', Fatal::SMARTMATCH_CATEGORY;

plan 'no_plan';

eval {
	use autodie ':io';
	open(my $fh, '<', NO_SUCH_FILE);
};

ok($@,			"Exception thrown"		        );
ok('open' ~~ $@,	"Exception from open"		        );
ok(':file' ~~ $@,	"Exception from open / class :file"	);
ok(':io' ~~ $@,		"Exception from open / class :io"	);
ok(':all' ~~ $@,	"Exception from open / class :all"	);

eval {
	use autodie ':io';
	close(THIS_FILEHANDLE_AINT_OPEN);
};

ok('close' ~~ $@,	"Exception from close"		        );
ok(':file' ~~ $@,	"Exception from close / class :file"	);
ok(':io' ~~ $@,		"Exception from close / class :io"	);
ok(':all' ~~ $@,	"Exception from close / class :all"	);