⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.177
Server IP:
50.6.168.112
Server:
Linux server-617809.webnetzimbabwe.com 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.4.10
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
.cpan
/
build
/
Template-Toolkit-3.102-0
/
t
/
View File Name :
stop.t
#============================================================= -*-perl-*- # # t/stop.t # # Test the [% STOP %] directive. # # Written by Andy Wardley
# # Copyright (C) 1996-2000 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. # # $Id$ # #======================================================================== use strict; use lib qw( ./lib ../lib ../blib/lib ../blib/arch ./blib/lib ./blib/arch ); our $DEBUG; use Template::Test; use Template::Parser; use Template::Exception; use File::Spec; # MacOS Catalina won't allow Dynaloader to load from relative paths # Error: file system relative paths not allowed in hardened program @INC = map { File::Spec->rel2abs($_) } @INC; #$Template::Parser::DEBUG = 1; $DEBUG = 1; my $ttblocks = { header => sub { "This is the header\n" }, footer => sub { "This is the footer\n" }, halt1 => sub { die Template::Exception->new('stop', 'big error') }, }; my $ttvars = { halt => sub { die Template::Exception->new('stop', 'big error') }, }; my $ttbare = Template->new(BLOCKS => $ttblocks); my $ttwrap = Template->new({ PRE_PROCESS => 'header', POST_PROCESS => 'footer', BLOCKS => $ttblocks, }); test_expect(\*DATA, [ bare => $ttbare, wrapped => $ttwrap ], $ttvars); __END__ -- test -- This is some text [% STOP %] More text -- expect -- This is some text -- test -- This is some text [% halt %] More text -- expect -- This is some text -- test -- This is some text [% INCLUDE halt1 %] More text -- expect -- This is some text -- test -- This is some text [% INCLUDE myblock1 %] More text [% BLOCK myblock1 -%] This is myblock1 [% STOP %] more of myblock1 [% END %] -- expect -- This is some text This is myblock1 -- test -- This is some text [% INCLUDE myblock2 %] More text [% BLOCK myblock2 -%] This is myblock2 [% halt %] more of myblock2 [% END %] -- expect -- This is some text This is myblock2 #------------------------------------------------------------------------ # ensure 'stop' exceptions get ignored by TRY...END blocks #------------------------------------------------------------------------ -- test -- before [% TRY -%] trying [% STOP -%] tried [% CATCH -%] caught [[% error.type %]] - [% error.info %] [% END %] after -- expect -- before trying #------------------------------------------------------------------------ # ensure PRE_PROCESS and POST_PROCESS templates get added with STOP #------------------------------------------------------------------------ -- test -- -- use wrapped -- This is some text [% STOP %] More text -- expect -- This is the header This is some text This is the footer