File: from-lol.t

package info (click to toggle)
libpod-elemental-perl 0.103006-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 396 kB
  • sloc: perl: 1,471; makefile: 7
file content (71 lines) | stat: -rw-r--r-- 1,754 bytes parent folder | download | duplicates (6)
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
#!perl
use strict;
use warnings;

use Test::More 'no_plan';
use Pod::Elemental::Document;

use Test::Differences;

my $pod_string = do {
  local $/;
  open my $fh, '<', 't/eg/from-lol.pod' or die "can't read test data: $!";
  <$fh>;
};

my $flat_lol = [
  [ '=head1' => "This is a head." ],
  [ '=head2' => "This is a subhead." ],
  [ (undef)  => "Ordinary 1"  ],
  [ (undef)  => "Ordinary 2"  ],
  [ '=begin' => ':pod_region' ],
    [ (undef)  => "Ordinary 3"  ],
    [ (undef)  => "Ordinary 4"  ],
    [ '=head1' => 'This is a head.' ],
    [ '=begin'  => 'nonpod_region' ],
      [ (undef)  => "Data 1"  ],
      [ (undef)  => "Data 2"  ],
      [ (undef)  => "Data 3"  ],
    [ '=end'    => 'nonpod_region' ],
  [ '=end'    => ':pod_region'   ],
  [ '=begin' => ':empty' ],
  [ '=end'   => ':empty' ],
];

{
  my $document = Pod::Elemental::Document->new_from_lol($flat_lol);
  isa_ok($document, 'Pod::Elemental::Document');
  is(
    $document->as_pod_string,
    $pod_string,
    "from_lol stringifies to what we want",
  );
}

# my $nested_lol = [
#   [ '=head1' => "This is a head."    ],
#   [ '=head2' => "This is a subhead." ],
#   [ (undef)  => "Ordinary 1" ],
#   [ (undef)  => "Ordinary 2" ],
#   [ ':pod_region' => [
#     [ (undef)  => "Ordinary 3" ],
#     [ (undef)  => "Ordinary 4" ],
#     [ '=head1' => 'This is a head.' ],
#     [ nonpod_region => [
#       [ (undef)  => "Data 1" ],
#       [ (undef)  => "Data 2" ],
#       [ (undef)  => "Data 3" ],
#     ] ],
#   ] ],
# ];
# 
# {
#   my $document = Pod::Elemental::Document->new_from_lol($nested_lol);
#   isa_ok($document, 'Pod::Elemental::Document');
#   eq_or_diff(
#     $document->as_pod_string,
#     $pod_string,
#     "from_lol stringifies to what we want",
#   );
# }