Blame t/exceptions.t

Packit 6427f8
#!/usr/bin/perl -w
Packit 6427f8
use strict;
Packit 6427f8
use Test::More;
Packit 6427f8
Packit 6427f8
BEGIN { plan skip_all => "Perl 5.10 only tests" if $] < 5.010; }
Packit 6427f8
Packit 6427f8
# These are tests that depend upon 5.10 (eg, smart-match).
Packit 6427f8
# Basic tests should go in basic_exceptions.t
Packit 6427f8
Packit 6427f8
use 5.010;
Packit 6427f8
use constant NO_SUCH_FILE => 'this_file_had_better_not_exist_xyzzy';
Packit 6427f8
no if $] >= 5.017011, warnings => "experimental::smartmatch";
Packit 6427f8
Packit 6427f8
plan 'no_plan';
Packit 6427f8
Packit 6427f8
eval {
Packit 6427f8
	use autodie ':io';
Packit 6427f8
	open(my $fh, '<', NO_SUCH_FILE);
Packit 6427f8
};
Packit 6427f8
Packit 6427f8
ok($@,			"Exception thrown"		        );
Packit 6427f8
ok($@ ~~ 'open',	"Exception from open"		        );
Packit 6427f8
ok($@ ~~ ':file',	"Exception from open / class :file"	);
Packit 6427f8
ok($@ ~~ ':io',		"Exception from open / class :io"	);
Packit 6427f8
ok($@ ~~ ':all',	"Exception from open / class :all"	);
Packit 6427f8
Packit 6427f8
eval {
Packit 6427f8
    no warnings 'once';    # To prevent the following close from complaining.
Packit 6427f8
	close(THIS_FILEHANDLE_AINT_OPEN);
Packit 6427f8
};
Packit 6427f8
Packit 6427f8
ok(! $@, "Close without autodie should fail silent");
Packit 6427f8
Packit 6427f8
eval {
Packit 6427f8
	use autodie ':io';
Packit 6427f8
	close(THIS_FILEHANDLE_AINT_OPEN);
Packit 6427f8
};
Packit 6427f8
Packit 6427f8
like($@, qr{Can't close filehandle 'THIS_FILEHANDLE_AINT_OPEN'},"Nice msg from close");
Packit 6427f8
Packit 6427f8
ok($@,			"Exception thrown"		        );
Packit 6427f8
ok($@ ~~ 'close',	"Exception from close"		        );
Packit 6427f8
ok($@ ~~ ':file',	"Exception from close / class :file"	);
Packit 6427f8
ok($@ ~~ ':io',		"Exception from close / class :io"	);
Packit 6427f8
ok($@ ~~ ':all',	"Exception from close / class :all"	);
Packit 6427f8
Packit 6427f8
ok $@ eq $@.'',                 "string overloading is complete (eq)";
Packit 6427f8
ok( ($@ cmp $@.'') == 0,        "string overloading is complete (cmp)" );