File: encoding.t

package info (click to toggle)
libpod-weaver-perl 4.020-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: perl: 1,428; makefile: 2
file content (71 lines) | stat: -rw-r--r-- 1,731 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
60
61
62
63
64
65
66
67
68
69
70
71
use strict;
use warnings;
use utf8;

use Test::More;
use Test::Differences;

use PPI;

use Pod::Elemental;
use Pod::Elemental::Selectors -all;
use Pod::Elemental::Transformer::Pod5;
use Pod::Elemental::Transformer::Nester;

use Pod::Weaver;

my $in_pod   = do { local $/; open my $fh, '<:raw:bytes', 't/eg/encoding.in.pod'; <$fh> };
my $expected = do { local $/; open my $fh, '<:encoding(UTF-8)', 't/eg/encoding.out.pod'; <$fh> };
my $document = Pod::Elemental->read_string($in_pod);

my $perl_document = <<'END';

package Module::Name;
# ABSTRACT: abstract text with UTF-8 paçoca

my $this = 'a test';
END

my $ppi_document  = PPI::Document->new(\$perl_document);

my $weaver = Pod::Weaver->new_with_default_config;

require Software::License::Artistic_1_0;
my $woven = $weaver->weave_document({
  pod_document => $document,
  ppi_document => $ppi_document,

  version  => '1.012078',
  authors  => [
    'Ricardo Signes <rjbs@example.com>',
    'Molly Millions <sshears@orbit.tash>',
  ],
  license  => Software::License::Artistic_1_0->new({
    holder => 'Ricardo Signes',
    year   => 1999,
  }),
});

is(@{ $woven->children }, 11, "we end up with a 11-paragraph document");

for (qw(1 2 4 5 6 7 9 10)) {
  my $para = $woven->children->[ $_ ];
  isa_ok($para, 'Pod::Elemental::Element::Nested', "element $_");
  is($para->command, 'head1', "... and is =head1");
}

is(
  $woven->children->[2]->children->[0]->content,
  'version 1.012078',
  "the version is in the version section",
);

# XXX: This test is extremely risky as things change upstream.
# -- rjbs, 2009-10-23
eq_or_diff(
  [ split /\n/, $woven->as_pod_string ],
  [ split /\n/, $expected ],
  "exactly the pod string we wanted after weaving!",
);

done_testing;