1#!/usr/bin/perl -w
2use strict;
3use warnings;
4use Test::More 'no_plan';
5use autodie;
6
7use constant NO_SUCH_FILE => 'this_file_had_better_not_exist';
8use constant MAGIC_STRING => 'xyzzy';
9
10# Opening an eval clears $@, so it's important that we set it
11# inside the eval block to see if it's successfully captured.
12
13eval {
14    $@ = MAGIC_STRING;
15    is($@, MAGIC_STRING, 'Sanity check on start conditions');
16    open(my $fh, '<', NO_SUCH_FILE);
17};
18
19isa_ok($@, 'autodie::exception');
20is($@->eval_error, MAGIC_STRING, 'Previous $@ should be captured');
21