Blame t/string-eval-basic.t

Packit 6427f8
#!/usr/bin/perl -w
Packit 6427f8
use strict;
Packit 6427f8
use warnings;
Packit 6427f8
use Test::More tests => 3;
Packit 6427f8
Packit 6427f8
use constant NO_SUCH_FILE => 'this_file_had_better_not_exist';
Packit 6427f8
Packit 6427f8
# Keep this test alone in its file as it can be hidden by using autodie outside
Packit 6427f8
# the eval.
Packit 6427f8
Packit 6427f8
# Just to make sure we're absolutely not encountering any weird $@ clobbering
Packit 6427f8
# events, we'll capture a result from our string eval.
Packit 6427f8
Packit 6427f8
my $result = eval q{
Packit 6427f8
    use autodie "open";
Packit 6427f8
Packit 6427f8
    open(my $fh, '<', NO_SUCH_FILE);
Packit 6427f8
Packit 6427f8
    1;
Packit 6427f8
};
Packit 6427f8
Packit 6427f8
ok( ! $result, "Eval should fail with autodie/no such file");
Packit 6427f8
ok($@, "enabling autodie in string eval should throw an exception");
Packit 6427f8
isa_ok($@, 'autodie::exception');