5 BEGIN { plan skip_all => "Perl 5.10 only tests" if $] < 5.010; }
7 # These are tests that depend upon 5.10 (eg, smart-match).
8 # Basic tests should go in basic_exceptions.t
11 use constant NO_SUCH_FILE => 'this_file_had_better_not_exist_xyzzy';
17 open(my $fh, '<', NO_SUCH_FILE);
20 ok($@, "Exception thrown" );
21 ok('open' ~~ $@, "Exception from open" );
22 ok(':file' ~~ $@, "Exception from open / class :file" );
23 ok(':io' ~~ $@, "Exception from open / class :io" );
24 ok(':all' ~~ $@, "Exception from open / class :all" );
27 no warnings 'once'; # To prevent the following close from complaining.
28 close(THIS_FILEHANDLE_AINT_OPEN);
31 ok(! $@, "Close without autodie should fail silent");
35 close(THIS_FILEHANDLE_AINT_OPEN);
38 like($@, qr{Can't close filehandle 'THIS_FILEHANDLE_AINT_OPEN'},"Nice msg from close");
40 ok($@, "Exception thrown" );
41 ok('close' ~~ $@, "Exception from close" );
42 ok(':file' ~~ $@, "Exception from close / class :file" );
43 ok(':io' ~~ $@, "Exception from close / class :io" );
44 ok(':all' ~~ $@, "Exception from close / class :all" );