File: 03-modes.t

package info (click to toggle)
libtext-microtemplate-perl 0.24-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 296 kB
  • sloc: perl: 1,725; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;
use Test::More tests => 9;
use Text::MicroTemplate qw(:all);

# comment
is render_mt(<<'...')->as_string, "aaa\nbbb\n";
aaa
?# 
bbb
?# 
...
is render_mt(<<'...')->as_string, "aaa\nbbb\n";
aaa
?##############################################
?#
?# h2. comment title
?#
?# comment body
?#
?##############################################
bbb
?# 
...
is render_mt('aaa<?# a ?>bbb')->as_string, "aaabbb";

# expression and raw expression
do {
    is render_mt('<?= $_[0] ?>', 'foo<a')->as_string, 'foo&lt;a';
    my $rs = encoded_string('foo<a');
    is render_mt('<?= $_[0] ?>', $rs)->as_string, 'foo<a';

    # overload
    is $rs, 'foo<a';
    is render_mt('<?= $_[0] ?>', $rs), 'foo<a';
};
do {
    use utf8;
    is render_mt('あ<?= $_[0] ?>う', 'い<')->as_string, 'あい&lt;う';
    my $rs = encoded_string('い<');
    is render_mt('あ<?= $_[0] ?>う', $rs)->as_string, 'あい<う';
}