Ugly test script to verify $@ out-of-scope issue is fixed.
[catagits/Catalyst-Plugin-Static-Simple.git] / t / 12check_error_scope.t
1 #!perl
2
3 use strict;
4 use warnings;
5 no strict 'refs';
6 no warnings 'redefine';
7
8 use FindBin;
9 use lib "$FindBin::Bin/lib";
10
11 use Test::More tests => 3;
12 use Catalyst::Test 'TestApp';
13
14 TestApp->config->{ static }->{ dirs } = [ qr{stuff/} ];
15 my $orig_sub = *Catalyst::Plugin::Static::Simple::prepare_action{CODE};
16
17 *Catalyst::Plugin::Static::Simple::prepare_action = sub {
18         my ($c) = @_;
19
20         eval { my $var = 1 / 0 };
21
22         ok ($@, '$@ has a value.');
23         return $orig_sub->( $c );
24 };
25
26 ok( my $res = request("http://localhost/"), 'request ok' );
27 ok( $res->code == 200, q{Previous error doesn't crash static::simple} );