| 1 | use strictscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 strict/; |
| 2 | use warningsscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 warnings/; |
| 3 | |
| 4 | use Test::Morescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Test/More/; |
| 5 | use Test::Exceptionscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Test/Exception/; |
| 6 | use Moose::Autobox 0.10scip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Moose/`Autobox 0.10`/; |
| 7 | |
| 8 | use PPIscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 PPI/; |
| 9 | |
| 10 | use Pod::Elementalscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Elemental/; |
| 11 | use Pod::Elemental::Selectorsscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Elemental/Selectors/ -all; |
| 12 | use Pod::Elemental::Transformer::Pod5scip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Elemental/Transformer/Pod5/; |
| 13 | use Pod::Elemental::Transformer::Nesterscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Elemental/Transformer/Nester/; |
| 14 | |
| 15 | use Pod::Weaverscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Weaver/; |
| 16 | |
| 17 | requirescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/require(). Software::License::Artistic_1_0; |
| 18 | |
| 19 | sub slurp_filescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/slurp_file(). { |
| 20 | do { local $/scip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/`$/`.; openscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/open(). my $fh, '<', shiftscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/shift().; <$fh> }; |
| 21 | } |
| 22 | |
| 23 | sub read_podscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/read_pod(). { |
| 24 | Pod::Elemental->read_stringscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Elemental/read_string().(slurp_filescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/slurp_file().(shiftscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/shift().)); |
| 25 | } |
| 26 | |
| 27 | my $perl_document = do { local $/scip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/`$/`.; <DATA> }; |
| 28 | my $ppi_document = PPI::Document->newscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 PPI/Document/new().(\$perl_document); |
| 29 | |
| 30 | sub try_weavescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/try_weave(). { |
| 31 | my ($weaver, $pod_document) = @_scip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/`@_`.; |
| 32 | |
| 33 | my $woven = $weaver->weave_documentscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/weave_document().({ |
| 34 | pod_document => $pod_document, |
| 35 | ppi_document => $ppi_document, |
| 36 | |
| 37 | version => '1.012078', |
| 38 | authors => [ |
| 39 | 'Ricardo Signes <[email protected]>', |
| 40 | 'Molly Millions <[email protected]>', |
| 41 | ], |
| 42 | license => Software::License::Artistic_1_0->newscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Software/License/Artistic_1_0/new().({ |
| 43 | holder => 'Ricardo Signes', |
| 44 | year => 1999, |
| 45 | }), |
| 46 | }); |
| 47 | return $woven; |
| 48 | } |
| 49 | |
| 50 | my $no_dups_pod = read_podscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/read_pod(). 't/eg/no-duplicates.pod'; |
| 51 | |
| 52 | my $inexact_dup_pod = read_podscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/read_pod(). 't/eg/inexact-duplicate.pod'; |
| 53 | |
| 54 | my @dup_pods = mapscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/map(). { read_podscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/read_pod(). "t/eg/$_" } |
| 55 | qw( duplicate-leftovers.pod |
| 56 | duplicate-synopsis.pod |
| 57 | with-author-section.pod ); |
| 58 | |
| 59 | my $weaver = Pod::Weaver->new_from_configscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Weaver/new_from_config().({ root => 't/eg' }); |
| 60 | my $strict_weaver = Pod::Weaver->new_from_configscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 Pod/Weaver/new_from_config().({ root => 't/eg/strict' }); |
| 61 | |
| 62 | my $error_regex = qr{The following headers appear multiple times}; |
| 63 | |
| 64 | lives_okscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/lives_ok(). { |
| 65 | try_weavescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/try_weave().($weaver, $no_dups_pod); |
| 66 | } "doesn't throw error on a POD document with no duplicated headings."; |
| 67 | |
| 68 | throws_okscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/throws_ok(). { |
| 69 | try_weavescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/try_weave().($weaver, $inexact_dup_pod); |
| 70 | } $error_regex, 'Non-strict mode throws error on inexact duplicate headers'; |
| 71 | |
| 72 | lives_okscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/lives_ok(). { |
| 73 | try_weavescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/try_weave().($strict_weaver, $inexact_dup_pod); |
| 74 | } 'Strict mode does not throw error on inexact duplicate headers'; |
| 75 | |
| 76 | for my $pod (@dup_pods) { |
| 77 | throws_okscip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/throws_ok().{ |
| 78 | try_weavescip-perl cpan Pod-Weaver-Plugin-EnsureUniqueSections 0.163250 main/try_weave().($weaver, $pod); |
| 79 | } $error_regex, 'throws error on pod with duplicate sections, whether pre-existing or generated.'; |
| 80 | } |
| 81 | |
| 82 | done_testing; |
| 83 | |
| 84 | __DATA__ |
| 85 | |
| 86 | package Module::Name; |
| 87 | # ABSTRACT: abstract text |
| 88 | |
| 89 | my $this = 'a test'; |