File: from_prereqs.t

package info (click to toggle)
libmodule-cpanfile-perl 1.1004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 196 kB
  • sloc: perl: 531; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 757 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use strict;
use Test::More;

use Module::CPANfile;
use lib ".";
use t::Utils;

{
    my $r = write_cpanfile(<<FILE);
requires 'perl', '5.008001';
requires 'DBI';
requires 'Plack', '1.0001';
test_requires 'Test::More', '0.90, != 0.91';
FILE

    my $prereqs = Module::CPANfile->load->prereqs;
    my $file = Module::CPANfile->from_prereqs($prereqs->as_string_hash);

    is_deeply $file->prereq_specs, $prereqs->as_string_hash;

    is $file->to_string, <<FILE;
requires 'DBI';
requires 'Plack', '1.0001';
requires 'perl', '5.008001';

on test => sub {
    requires 'Test::More', '>= 0.90, != 0.91';
};
FILE

    $file->save('cpanfile');

    my $content = do { local $/; open my $in, 'cpanfile'; <$in> };
    is $content, $file->to_string;
}

done_testing;