File: SPDX.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 (60 lines) | stat: -rw-r--r-- 1,325 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
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::SPDX;

plan 88;

my %crufty = (
	'AGPL-3.0'             => undef,
	'BSD-2-Clause'         => undef,
	'CC-BY-1.0'            => undef,
	'CC-BY-NC-ND-1.0'      => undef,
	'CC-BY-NC-ND-2.0'      => undef,
	'CC-BY-NC-ND-2.5'      => undef,
	'CC-BY-NC-ND-3.0'      => undef,
	'CC-BY-ND-1.0'         => undef,
	'CC-BY-ND-2.0'         => undef,
	'CC-BY-ND-2.5'         => undef,
	'CC-BY-ND-3.0'         => undef,
	'LGPL-2.0'             => undef,
	'LGPL-2.1'             => undef,
	'Python-2.0'           => undef,
	Zlib                   => undef,
	'zlib-acknowledgement' => undef,
);

# TODO: Report SPDX bug: Missing versioning
my %Debian2SPDX = (
	'AGPLv3'  => 'AGPL-3.0',
	'LGPL-2'  => 'LGPL-2.0',
	'WTFPL-2' => 'WTFPL',
);

my $naming = String::License::Naming::SPDX->new;

sub scanner
{
	my $expected = $_->basename('.txt');
	my $string   = $_->slurp_utf8;
	$string = uncruft($string)
		if exists $crufty{$expected};

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

	is $Debian2SPDX{$license} || $license, $expected, "Corpus file $_";
}

path("t/SPDX")->visit( \&scanner );

done_testing;