File: outline.t

package info (click to toggle)
libtemplate-perl 2.27-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 2,632 kB
  • sloc: perl: 14,750; makefile: 11; sh: 5
file content (119 lines) | stat: -rw-r--r-- 2,341 bytes parent folder | download
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#============================================================= -*-perl-*-
#
# t/outline.t
#
# Test the OUTLINE_TAG option.
#
# Written by Andy Wardley <abw@wardley.org>
#
# Copyright (C) 1996-2014 Andy Wardley.  All Rights Reserved.
# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#========================================================================

use strict;
use lib qw( ./lib ../lib );
use Template::Test;
$^W = 1;

$Template::Test::DEBUG = 0;

ok(1);

my $tt_vanilla = Template->new;
my $tt_outline = Template->new({
    TAG_STYLE => 'outline',
});
my $tt_outtag = Template->new({
    OUTLINE_TAG => '%%',
});
my $tt_shell = Template->new({
    OUTLINE_TAG => quotemeta '$ ',
});

my $engines = [
    default => $tt_vanilla,
    outline => $tt_outline,
    outtag  => $tt_outtag,
    shell   => $tt_shell,
];


test_expect(\*DATA, $engines, callsign);

__DATA__
-- test --
-- name TAGS outline --
# Outline tags are not enabled by default
%% [% r %] and [% j %]
# Turn them on like so
[% TAGS outline -%]
%% IF a     # outline tags can contain comments
a is set to [% a %]
%% ELSE
a is not set
%% END
# Turn them off again
[% TAGS default -%]
%% [% f %] and [% t %]
-- expect --
%% romeo and juliet
a is set to alpha
%% foxtrot and tango

-- test --
-- name TAGS <start> <end> <outline> --
%% [% r %] and [% j %]
# You can also use TAGS to specify your own <start_tag> <end_tag> <outline_tag>
[% TAGS {{ }} >> -%]
>> IF b
b is set to {{b}}
>> ELSE
b is not set
>> END
-- expect --
%% romeo and juliet
b is set to bravo

-- test --
-- name TAG_STYLE outline --
-- use outline --
# This engine should already have TAG_STYLE set to 'outline'
%% IF c
c is set to [% c %]
%% ELSE
c is not set
%% END
# Turn them off again
[% TAGS default -%]
%% [% f %] and [% t %]
-- expect --
c is set to charlie
%% foxtrot and tango

-- test --
-- name OUTLINE_TAG --
-- use outtag --
# This engine should already have OUTLINE_TAG set to '%%'
%% IF d
d is set to [% d %]
%% ELSE
d is not set
%% END
-- expect --
d is set to delta

-- test --
-- name OUTLINE_TAG shell --
-- use shell --
# This engine should already have OUTLINE_TAG set to '$ '
$ IF e
e is set to [% e %]
$ ELSE
e is not set
$ END
-- expect --
e is set to echo