File: 6.t

package info (click to toggle)
libtext-quoted-perl 2.05-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 136 kB
  • ctags: 89
  • sloc: perl: 979; makefile: 43
file content (101 lines) | stat: -rw-r--r-- 2,536 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
use strict;
use warnings;
use Text::Quoted;
use Test::More tests => 5;

#########################
# handle nested comments with common >
my $a = <<EOF;
> a
>> b
> c
EOF

my $a_data = 
    [
       [ 
         { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' },
         [ { 'text' => 'b', 'empty' => '', 'quoter' => '>>', 'raw' => '>> b' } ],
         { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' }
       ]
    ];

is_deeply(extract($a),$a_data,"correctly parse >> delimiter");

#############
# when the quoter changes in the middle of things, don't get confused

$a = <<EOF;
> a
=> b
> c
EOF

$a_data = 
    [
       [ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' } ],
       [ { 'text' => 'b', 'empty' => '', 'quoter' => '=>', 'raw' => '=> b' } ],
       [ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' } ]
    ];

is_deeply(extract($a),$a_data,"correctly parse => delimiter");

#############
# when the quoter changes in the middle of things, don't get confused
# blank lines shouldn't affect it

$a = <<EOF;
> a

=> b

> c
EOF

$a_data = 
    [
       [ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' } ],
       { 'text' => '', 'empty' => 1, 'quoter' => '', 'raw' => '' },
       [ { 'text' => 'b', 'empty' => '', 'quoter' => '=>', 'raw' => '=> b' } ],
       { 'text' => '', 'empty' => 1, 'quoter' => '', 'raw' => '' },
       [ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' } ]
    ];

is_deeply(extract($a),$a_data,"correctly parse => delimiter with blank lines");

#############
# one of the real world quoter breakage examples was cpan>
# also, no text is required for the quoter to break things

$a = <<EOF;
>
cpan>
>
EOF

$a_data = 
    [
       [ { 'text' => '', 'empty' => 1, 'quoter' => '>', 'raw' => '>' } ],
       [ { 'text' => '', 'empty' => 1, 'quoter' => 'cpan>', 'raw' => 'cpan>' } ],
       [ { 'text' => '', 'empty' => 1, 'quoter' => '>', 'raw' => '>' } ]
    ];

is_deeply(extract($a),$a_data,"correctly parse cpan> delimiter with no text");

############
# just checking that when the cpan> quoter gets a space, we handle it properly

$a = <<EOF;
> a
cpan > b
> c
EOF

$a_data = 
    [
       [ { 'text' => 'a', 'empty' => '', 'quoter' => '>', 'raw' => '> a' } ],
       { 'text' => 'cpan > b', 'empty' => '', 'quoter' => '', 'raw' => 'cpan > b' },
       [ { 'text' => 'c', 'empty' => '', 'quoter' => '>', 'raw' => '> c' } ],
    ];

is_deeply(extract($a),$a_data,"correctly handles a non-delimiter");