forked from jslicense/spdx-satisfies.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cases.js
93 lines (80 loc) · 3.39 KB
/
cases.js
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
const satisfies = {
valid: [
[true, 'MIT', 'MIT'],
[true, 'GPL-1.0+', 'GPL-2.0'],
[true, 'GPL-2.0', 'GPL-1.0+'],
[true, 'GPL-1.0+', 'GPL-2.0+'],
[false, 'MIT', 'Apache-2.0'],
[true, 'MIT AND Apache-2.0', 'MIT AND Apache-2.0'],
[false, 'MIT AND Apache-2.0', 'MIT'],
[false, 'MIT AND Apache-2.0', 'Apache-2.0'],
[false, 'MIT AND Apache-2.0', 'MIT AND GPL-1.0'],
[false, 'MIT AND Apache-2.0', 'GPL-1.0 AND Apache-2.0'],
[true, 'MIT OR Apache-2.0', 'MIT'],
[true, 'MIT OR Apache-2.0', 'Apache-2.0'],
[true, 'MIT OR Apache-2.0', 'MIT OR GPL-1.0'],
[true, 'MIT OR Apache-2.0', 'GPL-1.0 OR Apache-2.0'],
[false, 'MIT OR Apache-2.0', 'GPL-1.0 OR 0BSD'],
[true, 'MIT AND (Apache-2.0 OR GPL-1.0)', 'MIT AND Apache-2.0'],
[true, 'MIT AND (Apache-2.0 OR GPL-1.0)', 'MIT AND GPL-1.0'],
[false, 'MIT AND (Apache-2.0 OR GPL-1.0)', 'MIT AND 0BSD'],
[false, 'MIT AND (Apache-2.0 OR GPL-1.0)', '0BSD AND Apache-2.0'],
[false, 'MIT AND (Apache-2.0 OR GPL-1.0)', '0BSD AND GPL-1.0'],
[true, '(MIT OR 0BSD) AND (Apache-2.0 OR GPL-1.0)', 'MIT AND Apache-2.0'],
[true, '(MIT OR 0BSD) AND (Apache-2.0 OR GPL-1.0)', '0BSD AND Apache-2.0'],
[true, '(MIT OR 0BSD) AND (Apache-2.0 OR GPL-1.0)', 'MIT AND GPL-1.0'],
[true, '(MIT OR 0BSD) AND (Apache-2.0 OR GPL-1.0)', '0BSD AND GPL-1.0'],
[false, '(MIT OR 0BSD) AND (Apache-2.0 OR GPL-1.0)', 'MIT AND GFDL-1.1'],
[false, '(MIT OR 0BSD) AND (Apache-2.0 OR GPL-1.0)', 'GFDL-1.1 AND Apache-2.0'],
[true, 'GPL-2.0+ WITH Bison-exception-2.2', 'GPL-2.0+ WITH Bison-exception-2.2'],
[false, 'GPL-2.0+ WITH Bison-exception-2.2', 'GPL-2.0+ WITH Bootloader-exception'],
[false, 'GPL-2.0+', 'GPL-2.0+ WITH Bootloader-exception']
],
error: [
['Both arguments must be string.', ['MIT'], 'Apache-2.0'],
['Both arguments must be string.', 'MIT', ['Apache-2.0']]
]
}
const satisfiesWithArrayErrors = [
['First argument must be string.', ['MIT'], ['Apache-2.0']],
['Second argument must be array.', 'MIT', 'Apache-2.0'],
['AND and OR operators are not allowed.', 'MIT', ['Apache-2.0', 'MIT AND GPL-1.0']],
['AND and OR operators are not allowed.', 'MIT', ['Apache-2.0', 'MIT OR GPL-1.0']]
]
const satisfiesAny = {
valid: [
[true, 'MIT', ['MIT']],
[false, 'MIT', ['GPL-1.0']],
[true, 'MIT OR GPL-1.0', ['MIT']],
[true, 'MIT OR GPL-1.0', ['GPL-1.0']],
[true, 'MIT OR GPL-1.0', ['MIT', 'GPL-1.0']],
[false, 'MIT OR GPL-1.0', ['Apache-2.0']],
[true, '(MIT AND GPL-1.0) OR Apache-2.0', ['Apache-2.0']],
[false, 'MIT AND GPL-1.0', ['GPL-1.0']],
[false, 'MIT AND GPL-1.0', ['MIT']],
[false, 'MIT AND GPL-1.0', ['MIT', 'GPL-1.0']],
[false, 'MIT AND GPL-1.0', ['Apache-2.0']]
],
error: satisfiesWithArrayErrors
}
const satisfiesAll = {
valid: [
[true, 'MIT', ['MIT']],
[false, 'MIT', ['GPL-1.0']],
[true, 'MIT AND GPL-1.0', ['GPL-1.0', 'MIT']],
[true, 'MIT AND GPL-1.0 AND Apache-2.0', ['GPL-1.0', 'MIT', 'Apache-2.0']],
[true, 'MIT AND GPL-1.0 OR Apache-2.0', ['Apache-2.0']],
[false, 'MIT AND GPL-1.0', ['GPL-1.0']],
[false, 'MIT AND GPL-1.0', ['Apache-2.0']],
[true, 'MIT OR GPL-1.0', ['MIT']],
[true, 'MIT OR GPL-1.0', ['GPL-1.0']],
[false, 'MIT OR GPL-1.0', ['MIT', 'GPL-1.0']],
[false, 'MIT OR GPL-1.0', ['Apache-2.0']]
],
error: satisfiesWithArrayErrors
}
module.exports = {
satisfies,
satisfiesAny,
satisfiesAll
}