Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (98 sloc) 2.705 kb
35a28e7 @abw Added t/wrap.t
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/wrap.t
4 #
5 # Template script testing wrap plugin.
6 #
7 # Written by Andy Wardley <abw@kfs.org>
8 #
9 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
10 #
11 # This is free software; you can redistribute it and/or modify it
12 # under the same terms as Perl itself.
13 #
14 # $Id$
15 #
16 #========================================================================
17
18 use strict;
19 use lib qw( ../lib );
20 use Template qw( :status );
21 use Template::Test;
22 $^W = 1;
23
24 $Template::Test::DEBUG = 0;
a314819 @abw v2.00
authored
25 #$Template::Parser::DEBUG = 1;
26 #$Template::Directive::PRETTY = 1;
35a28e7 @abw Added t/wrap.t
authored
27
28 eval "use Text::Wrap";
29
30 if ($@) {
039bd37 @abw * fixed numerous tests to report proper reason for skipping via skip_all...
authored
31 skip_all('Text::Wrap not installed');
35a28e7 @abw Added t/wrap.t
authored
32 }
33
34 test_expect(\*DATA);
35
36
37 #------------------------------------------------------------------------
38 # test input
39 #------------------------------------------------------------------------
40
41 __DATA__
42 -- test --
43 [% USE Wrap -%]
44 [% text = BLOCK -%]
45 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!
46 [%- END -%]
47 [% text = BLOCK; text FILTER replace('\s+', ' '); END -%]
48 [% Wrap(text, 25,) %]
49 -- expect --
50 This is a long block of
51 text that goes on for a
52 long long time and then
53 carries on some more
54 after that, it's very
55 interesting, NOT!
56
57 -- test --
58 [% FILTER wrap -%]
59 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!
60 [% END %]
61 -- expect --
62 This is a long block of text that goes on for a long long time and then
63 carries on some more after that, it's very interesting, NOT!
64
65 -- test --
66 [% USE wrap -%]
67 [% FILTER wrap(25) -%]
68 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!
69 [% END %]
70 -- expect --
71 This is a long block of
72 text that goes on for a
73 long long time and then
74 carries on some more
75 after that, it's very
76 interesting, NOT!
77
78 -- test --
79 [% FILTER wrap(10, '> ', '+ ') -%]
80 The cat sat on the mat and then sat on the flat.
81 [%- END %]
82 -- expect --
83 > The cat
84 + sat on
85 + the mat
86 + and
87 + then
88 + sat on
89 + the
90 + flat.
91
92 -- test --
a314819 @abw v2.00
authored
93 [% USE wrap -%]
35a28e7 @abw Added t/wrap.t
authored
94 [% FILTER bullet = wrap(40, '* ', ' ') -%]
95 First, attach the transmutex multiplier to the cross-wired quantum
96 homogeniser.
97 [%- END %]
a314819 @abw v2.00
authored
98 [% FILTER remove('\s+(?=\n)') -%]
35a28e7 @abw Added t/wrap.t
authored
99 [% FILTER bullet -%]
100 Then remodulate the shield to match the harmonic frequency, taking
101 care to correct the phase difference.
102 [% END %]
a314819 @abw v2.00
authored
103 [% END %]
35a28e7 @abw Added t/wrap.t
authored
104 -- expect --
105 * First, attach the transmutex
106 multiplier to the cross-wired quantum
107 homogeniser.
108 * Then remodulate the shield to match
a314819 @abw v2.00
authored
109 the harmonic frequency, taking
35a28e7 @abw Added t/wrap.t
authored
110 care to correct the phase difference.
Something went wrong with that request. Please try again.