File: 35_debug.t

package info (click to toggle)
libhtml-template-compiled-perl 0.97-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 756 kB
  • sloc: perl: 4,504; makefile: 5
file content (49 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# $Id: 27_chomp.t 977 2007-10-09 18:24:59Z tinita $
use warnings;
use strict;
use blib;
use lib 't';
use Test::More tests => 3;
use_ok('HTML::Template::Compiled');
use HTC_Utils qw($cache $tdir &cdir);

sub HTML::Template::Compiled::Test::bar {
    return $_[0]->[0]
}
sub HTML::Template::Compiled::Test::baz {
    return $_[0]->[1]
}

local $HTML::Template::Compiled::DEBUG = 1;
{
    local $HTML::Template::Compiled::DEBUG = 1;
    my $htc = HTML::Template::Compiled->new(
        scalarref => \<<'EOM',
<%= /foo.bar %>
<%= /foo.boo %>
<%= /foo.baz %>
EOM
        debug => 0,
    );
    my $obj = bless [23, 24], 'HTML::Template::Compiled::Test';
    $htc->param(foo => $obj);
    my $out;
    eval {
        $out = $htc->output;
    };
    ok($@, "Exception");
    if ($@) {
        #warn __PACKAGE__.':'.__LINE__.": $@\n";
        my $msg = $htc->debug_code;
        my $msg_html = $htc->debug_code(1);;
        #print $msg, $/;
        #print $msg_html, $/;
        cmp_ok($msg, '=~', qr/ ERROR line (\d+)/, 'Error message');
    }
    else {
        ok(0, 'Exception');
    }
}