File: 31-catch_errors.t

package info (click to toggle)
libtext-micromason-perl 2.23-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 600 kB
  • sloc: perl: 3,236; makefile: 23
file content (23 lines) | stat: -rw-r--r-- 660 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w

use strict;
use Test::More tests => 12;

use_ok 'Text::MicroMason', qw( compile execute try_compile try_execute );

######################################################################

my $scr_syn = '<b><% if ( 1 ) %></b>';
is eval { compile($scr_syn) }, undef;
like $@, qr/MicroMason compilation failed/;
like $@, qr/syntax error/;
is try_compile($scr_syn), undef;
is try_execute($scr_syn), undef;

my $scr_die = '<b><% die "FooBar" %></b>';
ok compile($scr_die);
is eval { execute($scr_die) }, undef;
like $@, qr/MicroMason execution failed/;
like $@, qr/FooBar/;
isa_ok try_compile($scr_die), 'CODE';
is try_execute($scr_die), undef;