1use strict;
2use Module::CPANfile;
3use Test::More;
4use lib ".";
5use t::Utils;
6
7{
8    my $r = write_cpanfile(<<FILE);
9mirror 'http://www.cpan.org';
10mirror 'http://backpan.cpan.org';
11
12requires 'DBI';
13requires 'Plack', '0.9970';
14
15on 'test' => sub {
16    requires 'Test::More';
17};
18FILE
19
20    my $file = Module::CPANfile->load;
21
22    my $prereq = $file->prereq;
23    is_deeply $prereq->as_string_hash, {
24        test => {
25            requires => { 'Test::More' => 0  },
26        },
27        runtime => {
28            requires => { 'Plack' => '0.9970', 'DBI' => 0 },
29        },
30    };
31
32    my $mirrors = $file->mirrors;
33    is_deeply $mirrors, [ 'http://www.cpan.org', 'http://backpan.cpan.org' ];
34
35    like $file->to_string, qr{mirror 'http://www.cpan.org';};
36    like $file->to_string, qr{mirror 'http://backpan.cpan.org';};
37}
38
39done_testing;
40