summaryrefslogtreecommitdiff
path: root/rt/lib/t/regression/00-mason-syntax.t
blob: 96674cacf1d14621c0b1cf8e9ccdd5bcf62e1411 (plain)
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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 1;

my $ok = 1;

use File::Find;
find( {
    no_chdir => 1,
    wanted   => sub {
        return if /\.(?:jpe?g|png|gif|rej|\~)$/i;
	if (m!/\.svn$!) {
	    $File::Find::prune = 1;
	    return;
	}
        return unless -f $_;
        diag "testing $_" if $ENV{'TEST_VERBOSE'};
        eval { compile_file($_) } and return;
        $ok = 0;
        diag "error in ${File::Find::name}:\n$@";
    },
}, 'html');
ok($ok, "mason syntax is ok");

use HTML::Mason::Compiler;
use HTML::Mason::Compiler::ToObject;

sub compile_file {
    my $file = shift;

    open my $fh, '<:utf8', $file or die "couldn't open '$file': $!";
    my $text = do { local $/; <$fh> };
    close $fh or die "couldn't close '$file': $!";

    my $compiler = new HTML::Mason::Compiler::ToObject;
    $compiler->compile( comp_source => $text, name => 'my' );
    return 1;
}