File: comp_root_ref.t

package info (click to toggle)
libcatalyst-view-mason-perl 0.19-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 372 kB
  • sloc: perl: 2,028; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (5)
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
#!perl

use strict;
use warnings;
use Scalar::Util qw/blessed/;
use Test::More;

eval 'use Test::Exception';
plan skip_all => 'Test::Exception required' if $@;

plan tests => 5;

use FindBin;
use lib "$FindBin::Bin/lib";

use TestApp::FakeCtx;
use TestApp::View::Mason::CompRootRef;

my @comp_roots = (
        { a => 1, },
        \do { my $o = 1 },
        sub { },
        \*STDIN,
);

my $c = TestApp::FakeCtx->new;

for my $comp_root (@comp_roots) {
    my $str = $comp_root . q//;

    throws_ok(sub {
            TestApp::View::Mason::CompRootRef->new($c, {comp_root => $comp_root});
    }, qr/comp_root path '\Q$str\E'/, 'exception when passing '. ref($comp_root) .' reference as comp_root');
}

lives_ok(sub {
        TestApp::View::Mason::CompRootRef->new($c, {
                comp_root => [ [MAIN => $FindBin::Bin] ],
        });
}, "array root as comp_root doesn't get stringified");