File: 81-func-basics.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 (38 lines) | stat: -rw-r--r-- 829 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl -w

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

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

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

{
    my $scr_hello = <<'ENDSCRIPT';
% my $noun = 'World';
Hello <% $noun %>!
How are ya?
ENDSCRIPT

    my $res_hello = <<'ENDSCRIPT';
Hello World!
How are ya?
ENDSCRIPT

    is execute($scr_hello), $res_hello;
    is compile($scr_hello)->(), $res_hello;

    ok my $scriptlet = compile($scr_hello);
    is $scriptlet->(), $res_hello;
    is $scriptlet->(), $res_hello;
    is $scriptlet->(), $res_hello;
}

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

{
    my $scr_bold = '<b><% $ARGS{label} %></b>';
    is execute($scr_bold, label=>'Foo'), '<b>Foo</b>';
    is compile($scr_bold)->(label=>'Foo'), '<b>Foo</b>';
}