File: separator.t

package info (click to toggle)
libtext-quoted-perl 2.10-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: perl: 1,536; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,831 bytes parent folder | download | duplicates (2)
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

use Test::More tests => 5;
BEGIN { use_ok('Text::Quoted') };

use Data::Dumper;

my $text = <<EOF;
foo
============
bar
============
baz
EOF

is_deeply(extract($text), [
        {text => 'foo', quoter => '', raw => 'foo'},
        {text => '============', quoter => '', raw => '============', separator => 1 },
        {text => 'bar', quoter => '', raw => 'bar'},
        {text => '============', quoter => '', raw => '============', separator => 1 },
        {text => 'baz', quoter => '', raw => 'baz'},
    ],
    "Sample text is organized properly"
) or diag Dumper(extract($text));

is_deeply(extract($text, { no_separators => 1 }), [
        {text => "foo\n============\nbar\n============\nbaz", quoter => '', raw => "foo\n============\nbar\n============\nbaz"},
    ],
    "Sample text is organized properly (no separators)"
) or diag Dumper(extract($text, { no_separators => 1 }));

$text = <<EOF;
foo
> bar
> ============
> baz
> ============
EOF

is_deeply(extract($text), [
        {text => 'foo', quoter => '', raw => 'foo'},
        [
            {text => 'bar', quoter => '>', raw => '> bar'},
            {text => '============', quoter => '>', raw => '> ============', separator => 1 },
            {text => 'baz', quoter => '>', raw => '> baz'},
            {text => '============', quoter => '>', raw => '> ============', separator => 1 },
        ],
    ],
    "Sample text is organized properly"
) or diag Dumper(extract($text));

is_deeply(extract($text, { no_separators => 1 }), [
        {text => 'foo', quoter => '', raw => 'foo'},
        [
            {text => "bar\n============\nbaz\n============", quoter => '>', raw => "> bar\n> ============\n> baz\n> ============"},
        ],
    ],
    "Sample text is organized properly (no separators)"
) or diag Dumper(extract($text, { no_separators => 1 }));