1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use lib 't/lib';
7use ExtUtils::MakeMaker;
8use File::Temp qw[tempfile];
9use Test::More 'no_plan';
10
11sub test_abstract {
12    my($code, $package, $want, $name) = @_;
13
14    local $Test::Builder::Level = $Test::Builder::Level + 1;
15
16    my $ok = 0;
17    for my $crlf (0, 1) {
18        my ($fh,$file) = tempfile( DIR => 't', UNLINK => 1 );
19        binmode $fh, $crlf ? ':crlf' : ':raw';
20        print $fh $code;
21        close $fh;
22        # Hack up a minimal MakeMaker object.
23        my $mm = bless { DISTNAME => $package }, "MM";
24        my $have = $mm->parse_abstract($file);
25        $ok += is( $have, $want, "$name :crlf=$crlf" ) ? 1 : 0;
26    }
27    return $ok;
28}
29
30
31test_abstract(<<END, "Foo", "Stuff and things", "Simple abstract");
32=head1 NAME
33
34Foo - Stuff and things
35END
36
37
38test_abstract(<<END, "NEXT", "Provide a pseudo-class NEXT (et al) that allows method redispatch", "Name.pm");
39=head1 NAME
40
41NEXT.pm - Provide a pseudo-class NEXT (et al) that allows method redispatch
42END
43
44
45test_abstract(<<END, "Compress::Raw::Zlib::FAQ", "Frequently Asked Questions about Compress::Raw::Zlib", "double dash");
46=pod
47
48Compress::Raw::Zlib::FAQ -- Frequently Asked Questions about Compress::Raw::Zlib
49END
50
51
52test_abstract(<<END, "Foo", "This is", "Only in POD");
53# =pod
54
55Foo - This is not in pod
56
57=cut
58
59Foo - This isn't in pod either
60
61=pod
62
63Foo - This is
64
65Foo - So is this.
66END
67
68
69test_abstract(<<END, "Foo", "the abstract", "more spaces");
70=pod
71
72Foo   -  the abstract
73END
74
75test_abstract(<<END, "Catalyst::Plugin::Authentication", "Infrastructure plugin for the Catalyst authentication framework.", "contains a line break");
76=pod
77
78=head1 NAME
79
80Catalyst::Plugin::Authentication - Infrastructure plugin for the Catalyst
81authentication framework.
82END
83