1#!/usr/bin/perl -w
2
3# Things like the CPAN shell rely on the "MakeMaker Parameters" section of the
4# Makefile to learn a module's dependencies so we'd damn well better test it.
5
6BEGIN {
7    unshift @INC, 't/lib';
8}
9
10use strict;
11use warnings;
12
13use ExtUtils::MakeMaker;
14use Test::More tests => 6;
15
16my $mm = bless {}, "MM";
17
18sub process_cmp {
19  my ($args, $expected, $label) = @_;
20  my $got = join '',
21    map "$_\n", $mm->_MakeMaker_Parameters_section($args || ());
22  $got =~ s/^#\s*MakeMaker Parameters:\n+//;
23  is $got, $expected, $label;
24}
25
26process_cmp undef, '', 'nothing';
27process_cmp { NAME => "Foo" }, <<'EXPECT', "name only";
28#     NAME => q[Foo]
29EXPECT
30process_cmp
31  { NAME => "Foo", PREREQ_PM => { "Foo::Bar" => 0 } }, <<'EXPECT', "PREREQ v0";
32#     NAME => q[Foo]
33#     PREREQ_PM => { Foo::Bar=>q[0] }
34EXPECT
35process_cmp
36  { NAME => "Foo", PREREQ_PM => { "Foo::Bar" => 1.23 } },
37  <<'EXPECT', "PREREQ v-non-0";
38#     NAME => q[Foo]
39#     PREREQ_PM => { Foo::Bar=>q[1.23] }
40EXPECT
41
42process_cmp
43  {
44    NAME                => "Foo",
45    PREREQ_PM           => { "Foo::Bar" => 1.23 },
46    BUILD_REQUIRES      => { "Baz"      => 0.12 },
47  },
48  <<'EXPECT', "BUILD_REQUIRES";
49#     BUILD_REQUIRES => { Baz=>q[0.12] }
50#     NAME => q[Foo]
51#     PREREQ_PM => { Baz=>q[0.12], Foo::Bar=>q[1.23] }
52EXPECT
53
54process_cmp
55  {
56    NAME                => "Foo",
57    PREREQ_PM           => { "Foo::Bar" => 1.23, Long => 1.45, Short => 0 },
58    BUILD_REQUIRES      => { "Baz"      => 0.12 },
59  },
60  <<'EXPECT', "ensure sorting";
61#     BUILD_REQUIRES => { Baz=>q[0.12] }
62#     NAME => q[Foo]
63#     PREREQ_PM => { Baz=>q[0.12], Foo::Bar=>q[1.23], Long=>q[1.45], Short=>q[0] }
64EXPECT
65