File: flaws.t

package info (click to toggle)
libstring-license-perl 0.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,900 kB
  • sloc: perl: 1,309; cpp: 360; ansic: 210; python: 27; ruby: 21; xml: 16; sh: 8; makefile: 3
file content (58 lines) | stat: -rw-r--r-- 1,005 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
use v5.20;
use feature qw(signatures);
no warnings qw(experimental::signatures);

use Test2::V0;

use Path::Tiny;

use lib 't/lib';
use Uncruft;

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

plan 20;

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

sub parse ($path_string)
{
	my ( $path, $string, $license );

	$path   = path($path_string);
	$string = uncruft( $path->slurp_utf8 );

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

	return $license;
}

path('t/flaws/fsf_address')->visit(
	sub {
		note $_;
		like parse($_), qr/ \[(?:mis-spelled|obsolete) FSF postal address /;
	}
);

path('t/flaws/no_fsf_address')->visit(
	sub {
		note $_;
		unlike parse($_), qr/ \[(?:mis-spelled|obsolete) FSF postal address /;
	}
);

path('t/flaws/generated')->visit(
	sub {
		note $_;
		like parse($_), qr/\Q [generated file]/;
	}
);

unlike parse('t/SPDX/BSL-1.0.txt'), qr/\Q [generated file]/,
	'false positive: BSL-1.0 license fulltext';

done_testing;