This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update ExtUtils-MakeMaker to CPAN version 7.02
[perl5.git] / cpan / ExtUtils-MakeMaker / t / MakeMaker_Parameters.t
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
6 BEGIN {
7     unshift @INC, 't/lib';
8 }
9
10 use strict;
11 use warnings;
12
13 use ExtUtils::MakeMaker;
14 use Test::More;
15
16 my $mm = bless {}, "MM";
17
18 sub 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
26 process_cmp undef, '', 'nothing';
27 process_cmp { NAME => "Foo" }, <<'EXPECT', "name only";
28 #     NAME => q[Foo]
29 EXPECT
30 process_cmp
31   { NAME => "Foo", PREREQ_PM => { "Foo::Bar" => 0 } }, <<'EXPECT', "PREREQ v0";
32 #     NAME => q[Foo]
33 #     PREREQ_PM => { Foo::Bar=>q[0] }
34 EXPECT
35 process_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] }
40 EXPECT
41
42 process_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] }
52 EXPECT
53
54 process_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] }
64 EXPECT
65
66 done_testing();