1*b39c5158Smillert#!/usr/bin/perl -w 2*b39c5158Smillertuse strict; 3*b39c5158Smillertuse warnings; 4*b39c5158Smillertuse Test::More tests => 3; 5*b39c5158Smillert 6*b39c5158Smillertuse constant NO_SUCH_FILE => 'this_file_had_better_not_exist'; 7*b39c5158Smillert 8*b39c5158Smillert# Keep this test alone in its file as it can be hidden by using autodie outside 9*b39c5158Smillert# the eval. 10*b39c5158Smillert 11*b39c5158Smillert# Just to make sure we're absolutely not encountering any weird $@ clobbering 12*b39c5158Smillert# events, we'll capture a result from our string eval. 13*b39c5158Smillert 14*b39c5158Smillertmy $result = eval q{ 15*b39c5158Smillert use autodie "open"; 16*b39c5158Smillert 17*b39c5158Smillert open(my $fh, '<', NO_SUCH_FILE); 18*b39c5158Smillert 19*b39c5158Smillert 1; 20*b39c5158Smillert}; 21*b39c5158Smillert 22*b39c5158Smillertok( ! $result, "Eval should fail with autodie/no such file"); 23*b39c5158Smillertok($@, "enabling autodie in string eval should throw an exception"); 24*b39c5158Smillertisa_ok($@, 'autodie::exception'); 25