VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.3/external/perl/Text-Template-1.56/t/strict.t@ 96159

最後變更 在這個檔案從96159是 94320,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

檔案大小: 1.2 KB
 
1#!perl
2#
3# Tests for STRICT features
4# These tests first appeared in version 1.48.
5
6use strict;
7use warnings;
8use Test::More tests => 4;
9
10use_ok 'Text::Template' or exit 1;
11
12@Emptyclass1::ISA = 'Text::Template';
13@Emptyclass2::ISA = 'Text::Template';
14
15my $tin = q{The value of $foo is: {$foo}};
16
17Text::Template->always_prepend(q{$foo = "global"});
18
19my $tmpl1 = Text::Template->new(
20 TYPE => 'STRING',
21 SOURCE => $tin);
22
23my $tmpl2 = Text::Template->new(
24 TYPE => 'STRING',
25 SOURCE => $tin,
26 PREPEND => q{$foo = "template"});
27
28$tmpl1->compile;
29$tmpl2->compile;
30
31# strict should cause t1 to contain an error message if wrong variable is used in template
32my $t1 = $tmpl1->fill_in(PACKAGE => 'T1', STRICT => 1, HASH => { bar => 'baz' });
33
34# non-strict still works
35my $t2 = $tmpl2->fill_in(PACKAGE => 'T2', HASH => { bar => 'baz' });
36
37# prepend overrides the hash values
38my $t3 = $tmpl2->fill_in(
39 PREPEND => q{$foo = "fillin"},
40 PACKAGE => 'T3',
41 STRICT => 1,
42 HASH => { foo => 'hashval2' });
43
44like $t1, qr/Global symbol "\$foo" requires explicit package/;
45is $t2, 'The value of $foo is: template', "non-strict hash still works";
46is $t3, "The value of \$foo is: fillin", "hash values with prepend, prepend wins, even under strict.";
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette