File: wrap.t

package info (click to toggle)
libtemplate-perl 2.14-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 5,496 kB
  • ctags: 667
  • sloc: perl: 15,349; makefile: 62; xml: 7; sh: 5
file content (110 lines) | stat: -rw-r--r-- 2,748 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
#============================================================= -*-perl-*-
#
# t/wrap.t
#
# Template script testing wrap plugin.
#
# Written by Andy Wardley <abw@kfs.org>
#
# Copyright (C) 1996-2000 Andy Wardley.  All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# $Id: wrap.t,v 2.3 2002/08/12 11:07:17 abw Exp $
#
#========================================================================

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

$Template::Test::DEBUG = 0;
#$Template::Parser::DEBUG = 1;
#$Template::Directive::PRETTY = 1;

eval "use Text::Wrap";

if ($@) {
    skip_all('Text::Wrap not installed');
}

test_expect(\*DATA);
 

#------------------------------------------------------------------------
# test input
#------------------------------------------------------------------------

__DATA__
-- test --
[% USE Wrap -%]
[% text = BLOCK -%]
This is a long block of text that goes on for a long long time and then carries on some more after that, it's very interesting, NOT!
[%- END -%]
[% text = BLOCK; text FILTER replace('\s+', ' '); END -%]
[% Wrap(text, 25,) %]
-- expect --
This is a long block of
text that goes on for a
long long time and then
carries on some more
after that, it's very
interesting, NOT!

-- test --
[% FILTER wrap -%]
This is a long block of text that goes on for a long long time and then carries on some more after that, it's very interesting, NOT!
[% END %]
-- expect --
This is a long block of text that goes on for a long long time and then
carries on some more after that, it's very interesting, NOT!

-- test --
[% USE wrap -%]
[% FILTER wrap(25) -%]
This is a long block of text that goes on for a long long time and then carries on some more after that, it's very interesting, NOT!
[% END %]
-- expect --
This is a long block of
text that goes on for a
long long time and then
carries on some more
after that, it's very
interesting, NOT!

-- test --
[% FILTER wrap(10, '> ', '+ ') -%]
The cat sat on the mat and then sat on the flat.
[%- END %]
-- expect --
> The cat
+ sat on
+ the mat
+ and
+ then
+ sat on
+ the
+ flat.

-- test --
[% USE wrap -%]
[% FILTER bullet = wrap(40, '* ', '  ') -%]
First, attach the transmutex multiplier to the cross-wired quantum
homogeniser.
[%- END %]
[% FILTER remove('\s+(?=\n)') -%]
[% FILTER bullet -%]
Then remodulate the shield to match the harmonic frequency, taking 
care to correct the phase difference.
[% END %]
[% END %]
-- expect --
* First, attach the transmutex
  multiplier to the cross-wired quantum
  homogeniser.
* Then remodulate the shield to match
  the harmonic frequency, taking
  care to correct the phase difference.