File: 16_switch.t

package info (click to toggle)
libhtml-template-compiled-perl 1.003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 772 kB
  • sloc: perl: 4,759; makefile: 5
file content (42 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (2)
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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl HTML-Template-Compiled.t'

use Test::More tests => 4;
use Data::Dumper;
use File::Spec;
use strict;
use warnings;
local $Data::Dumper::Indent = 1; local $Data::Dumper::Sortkeys = 1;
BEGIN { use_ok('HTML::Template::Compiled') };
my $cache = File::Spec->catfile('t', 'cache');

{
	my $htc = HTML::Template::Compiled->new(
		scalarref => \<<'EOM',
<tmpl_switch .lang>
    <tmpl_case en>
	english
	<tmpl_case de,fr>
		german or french
		<tmpl_switch lang>
		<tmpl_case de>german
		</tmpl_switch>
	<tmpl_case>
		default case
</tmpl_switch>
<tmpl_switch .lang>
	<tmpl_case fr,default>
    french or default
</tmpl_switch>
EOM
		debug => 0,
	);
	$htc->param(
		lang => 'de',
	);
	my $out = $htc->output;
    #print $out,$/;
	ok($out =~ m/german or french.*german/s, "switch 1");
    cmp_ok($out,"!~","default case", "switch 2");
	ok($out =~ m/french or default/s, "switch default");
}