小编Pau*_*ell的帖子

尝试创建带有模板值的字符串并单元测试模板是否正确处理

我正在尝试创建一个测试文件,使用模板工具包将模板值输入到字符串中,但我不知道要包含哪些检查/测试以确保模板工具包正确处理字符串。这是我的代码:

#!/usr/bin/env perl

use lib ('./t/lib/');

use strict;
use warnings;

use Template;

use Test::More tests => 1;



# options/configuration for template
 my $config = {
     #PRE_PROCESS => 1, # means the templates processed can use the same global vars defined earlier
     #INTERPOLATE => 1,
     #EVAL_PERL => 1,
     RELATIVE => 1,
     OUTPUT_PATH => './out',

 };

my $template = Template->new($config);

# input string
my $text = "This is string number [%num%] ."; 

# template placeholder variables
my $vars = {
     num => …
Run Code Online (Sandbox Code Playgroud)

perl unit-testing template-toolkit

5
推荐指数
1
解决办法
238
查看次数

标签 统计

perl ×1

template-toolkit ×1

unit-testing ×1