File: license.t

package info (click to toggle)
libstring-license-perl 0.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,892 kB
  • sloc: perl: 1,519; cpp: 360; ansic: 210; python: 27; ruby: 21; xml: 16; sh: 8; makefile: 3
file content (116 lines) | stat: -rw-r--r-- 3,502 bytes parent folder | download
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use Test2::V0;
use Test2::Require::Module 'Regexp::Pattern::License' => '3.9.0';

use Path::Tiny;

use lib 't/lib';
use Uncruft;

use String::License;
use String::License::Naming::Custom;

plan 35;

my %crufty = (
	'artistic-2-0-modules.pm'     => undef,
	'bsd-1-clause-1.c'            => undef,
	'bsd.f'                       => undef,
	'bsd-3-clause.cpp'            => undef,
	'gpl-1'                       => undef,
	'gpl-2+'                      => undef,
	'gpl-2+.scm'                  => undef,
	'gpl-3.sh'                    => undef,
	'gpl-3-only.c'                => undef,
	'gpl-3+'                      => undef,
	'gpl-3+-with-rem-comment.xml' => undef,
	'gpl-variation.c'             => undef,
	'gpl-3+.el'                   => undef,
	'comments-detection.h'        => undef,
	'mpl-1.1.sh'                  => undef,
	'mpl-2.0.sh'                  => undef,
	'mpl-2.0-comma.sh'            => undef,
	'cddl.h'                      => undef,
	'libuv-isc.am'                => undef,
	'info-at-eof.h'               => undef,
);

my $naming
	= String::License::Naming::Custom->new(
	schemes => [qw(debian spdx internal)] );

sub parse
{
	my $path   = path(shift);
	my $string = $path->slurp_utf8;
	$string = uncruft($string)
		if exists $crufty{ $path->relative('t/devscripts') };

	my $license = String::License->new(
		string => $string,
		naming => $naming,
	)->as_text;

	return $license;
}

like parse('t/devscripts/academic.h'), 'AFL-3.0';

like parse('t/grant/Apache/one_helper.rb'), 'Apache-2.0';

like parse('t/devscripts/artistic-2-0-modules.pm'), 'Artistic-2.0';
like parse('t/devscripts/artistic-2-0.txt'),        'Artistic-2.0';

like parse('t/devscripts/beerware.cpp'), 'Beerware';

like parse('t/devscripts/bsd-1-clause-1.c'), 'BSD-1-Clause';

like parse('t/devscripts/bsd.f'), 'BSD-2-clause';

like parse('t/devscripts/bsd-3-clause.cpp'),          'BSD-3-clause';
like parse('t/devscripts/bsd-3-clause-authorsany.c'), 'BSD-3-clause';
like parse('t/devscripts/mame-style.c'),              'BSD-3-clause';

like parse('t/devscripts/boost.h'), 'BSL-1.0';

like parse('t/devscripts/epl.h'), 'EPL-1.0';

# Lisp Lesser General Public License (BTS #806424)
# see http://opensource.franz.com/preamble.html
like parse('t/devscripts/llgpl.lisp'), 'LLGPL';

like parse('t/devscripts/gpl-no-version.h'), 'GPL';

like parse('t/devscripts/gpl-1'), 'GPL-1+';

like parse('t/devscripts/gpl-2'),                   'GPL-2';
like parse('t/devscripts/bug-559429'),              'GPL-2';
like parse('t/devscripts/gpl-2-comma.sh'),          'GPL-2';
like parse('t/devscripts/gpl-2-incorrect-address'), 'GPL-2';

like parse('t/devscripts/gpl-2+'),     'GPL-2+';
like parse('t/devscripts/gpl-2+.scm'), 'GPL-2+';

like parse('t/devscripts/gpl-3.sh'),     'GPL-3';
like parse('t/devscripts/gpl-3-only.c'), 'GPL-3';

like parse('t/devscripts/gpl-3+'),                      'GPL-3+';
like parse('t/devscripts/gpl-3+-with-rem-comment.xml'), 'GPL-3+';
like parse('t/devscripts/gpl-variation.c'),             'GPL-3+';

like parse('t/devscripts/gpl-3+.el'),            'GPL-3+';
like parse('t/devscripts/comments-detection.h'), 'GPL-3+';

like parse('t/devscripts/mpl-1.1.sh'), 'MPL-1.1';

like parse('t/devscripts/mpl-2.0.sh'),       'MPL-2.0';
like parse('t/devscripts/mpl-2.0-comma.sh'), 'MPL-2.0';

like parse('t/devscripts/freetype.c'), 'FTL';

like parse('t/devscripts/cddl.h'), 'CDDL';

like parse('t/devscripts/libuv-isc.am'), 'ISC';

like parse('t/devscripts/info-at-eof.h'), 'Expat';

done_testing;