File: guess_meta_license.t

package info (click to toggle)
libsoftware-license-perl 0.104007-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 732 kB
  • sloc: perl: 6,931; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download | duplicates (6)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!perl

use strict;
use warnings;

use Test::More tests => 26;
use Software::LicenseUtils;
use Try::Tiny;

sub _hack_guess_license_from_meta {
  my $license_str = shift;
  my @guess;
  try {
    my $hack = 'license : ' . $license_str;
    @guess = Software::LicenseUtils->guess_license_from_meta($hack);
  };
  return @guess;

}

my @cpan_meta_spec_licence_name = qw(
  agpl_3
  apache_1_1
  apache_2_0
  artistic_1
  artistic_2
  bsd
  freebsd
  gfdl_1_2
  gfdl_1_3
  gpl_1
  gpl_2
  gpl_3
  lgpl_2_1
  lgpl_3_0
  mit
  mozilla_1_0
  mozilla_1_1
  openssl
  perl_5
  qpl_1_0
  ssleay
  sun
  zlib
);

foreach my $license_name (@cpan_meta_spec_licence_name) {
  my @guess = _hack_guess_license_from_meta($license_name);
  ok(@guess, "$license_name -> @guess");
}

is_deeply(
  [ Software::LicenseUtils->guess_license_from_meta_key('artistic_2', 2) ],
  [ 'Software::License::Artistic_2_0' ],
);

is_deeply(
  [ Software::LicenseUtils->guess_license_from_meta_key('gpl_3', 2) ],
  [ 'Software::License::GPL_3' ],
);

is_deeply(
  [ Software::LicenseUtils->guess_license_from_meta_key('gpl_3', 1) ],
  [ ],
);

done_testing;