9d635600bba997b072f14fa36449e8734a582f13
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / metafile_data.t
1 BEGIN {
2     if( $ENV{PERL_CORE} ) {
3         chdir 't' if -d 't';
4         @INC = ('../lib', 'lib');
5     }
6     else {
7         unshift @INC, 't/lib';
8     }
9 }
10
11 use strict;
12 use Test::More tests => 5;
13
14 use Data::Dumper;
15
16 require ExtUtils::MM_Any;
17
18 my $new_mm = sub {
19     return bless {@_}, 'ExtUtils::MM_Any';
20 };
21
22 {
23     my $mm = $new_mm->(
24         DISTNAME        => 'Foo-Bar',
25         VERSION         => 1.23,
26         PM              => {
27             "Foo::Bar"          => 'lib/Foo/Bar.pm',
28         },
29     );
30
31     is_deeply [$mm->metafile_data], [
32         name            => 'Foo-Bar',
33         version         => 1.23,
34         abstract        => undef,
35         author          => [],
36         license         => 'unknown',
37         distribution_type       => 'module',
38
39         configure_requires      => {
40             'ExtUtils::MakeMaker'       => 0,
41         },
42
43         no_index        => {
44             directory           => [qw(t inc)],
45         },
46
47         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
48         'meta-spec'  => {
49             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
50             version     => 1.4
51         },
52     ];
53
54
55     is_deeply [$mm->metafile_data({}, { no_index => { directory => [qw(foo)] } })], [
56         name            => 'Foo-Bar',
57         version         => 1.23,
58         abstract        => undef,
59         author          => [],
60         license         => 'unknown',
61         distribution_type       => 'module',
62
63         configure_requires      => {
64             'ExtUtils::MakeMaker'       => 0,
65         },
66
67         no_index        => {
68             directory           => [qw(t inc foo)],
69         },
70
71         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
72         'meta-spec'  => {
73             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
74             version     => 1.4
75         },
76     ], 'rt.cpan.org 39348';
77 }
78
79
80 {
81     my $mm = $new_mm->(
82         DISTNAME        => 'Foo-Bar',
83         VERSION         => 1.23,
84         AUTHOR          => 'Some Guy',
85         PREREQ_PM       => {
86             Foo                 => 2.34,
87             Bar                 => 4.56,
88         },
89     );
90
91     is_deeply [$mm->metafile_data(
92         {
93             configure_requires => {
94                 Stuff   => 2.34
95             },
96             wobble      => 42
97         },
98         {
99             no_index    => {
100                 package => "Thing"
101             },
102             wibble      => 23
103         },
104     )],
105     [
106         name            => 'Foo-Bar',
107         version         => 1.23,
108         abstract        => undef,
109         author          => ['Some Guy'],
110         license         => 'unknown',
111         distribution_type       => 'script',
112
113         configure_requires      => {
114             Stuff       => 2.34,
115         },
116         requires       => {
117             Foo                 => 2.34,
118             Bar                 => 4.56,
119         },
120
121         no_index        => {
122             directory           => [qw(t inc)],
123             package             => 'Thing',
124         },
125
126         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
127         'meta-spec'  => {
128             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
129             version     => 1.4
130         },
131
132         wibble  => 23,
133         wobble  => 42,
134     ];
135 }
136
137
138 # Test MIN_PERL_VERSION
139 {
140     my $mm = $new_mm->(
141         DISTNAME        => 'Foo-Bar',
142         VERSION         => 1.23,
143         PM              => {
144             "Foo::Bar"          => 'lib/Foo/Bar.pm',
145         },
146         MIN_PERL_VERSION => 5.006,
147     );
148
149     is_deeply [$mm->metafile_data], [
150         name            => 'Foo-Bar',
151         version         => 1.23,
152         abstract        => undef,
153         author          => [],
154         license         => 'unknown',
155         distribution_type       => 'module',
156
157         configure_requires      => {
158             'ExtUtils::MakeMaker'       => 0,
159         },
160
161         requires        => {
162             perl        => '5.006',
163         },
164
165         no_index        => {
166             directory           => [qw(t inc)],
167         },
168
169         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
170         'meta-spec'  => {
171             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
172             version     => 1.4
173         },
174     ];
175 }
176
177
178 # Test MIN_PERL_VERSION
179 {
180     my $mm = $new_mm->(
181         DISTNAME        => 'Foo-Bar',
182         VERSION         => 1.23,
183         PM              => {
184             "Foo::Bar"          => 'lib/Foo/Bar.pm',
185         },
186         MIN_PERL_VERSION => 5.006,
187         PREREQ_PM => {
188             'Foo::Bar'  => 1.23,
189         },
190     );
191
192     is_deeply [$mm->metafile_data], [
193         name            => 'Foo-Bar',
194         version         => 1.23,
195         abstract        => undef,
196         author          => [],
197         license         => 'unknown',
198         distribution_type       => 'module',
199
200         configure_requires      => {
201             'ExtUtils::MakeMaker'       => 0,
202         },
203
204         requires        => {
205             perl        => '5.006',
206             'Foo::Bar'  => 1.23,
207         },
208
209         no_index        => {
210             directory           => [qw(t inc)],
211         },
212
213         generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
214         'meta-spec'  => {
215             url         => 'http://module-build.sourceforge.net/META-spec-v1.4.html', 
216             version     => 1.4
217         },
218     ];
219 }