File: 84-func-errors.t

package info (click to toggle)
libtext-micromason-perl 2.13-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 624 kB
  • ctags: 180
  • sloc: perl: 3,222; makefile: 23
file content (29 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w

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

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;

# try_execute can return the $@
ok my ($r, $ok) = try_execute($scr_die);
is $r, undef;
like $ok, qr/MicroMason execution failed/;
like $ok, qr/FooBar/;