mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
lib/tests: add tests for lib.licenses
This commit is contained in:
@@ -76,7 +76,7 @@
|
||||
- [exception] Exception to apply
|
||||
*/
|
||||
WITH = license: exception: {
|
||||
licenseType = "compound";
|
||||
licenseType = "exception";
|
||||
operator = "WITH";
|
||||
inherit license exception;
|
||||
};
|
||||
@@ -88,8 +88,8 @@
|
||||
# Example
|
||||
|
||||
```nix
|
||||
PLUS lib.licenses.lgpl21Only
|
||||
=> { licenseType = "plus"; operator = "+"; license = lib.licenses.lgpl21Only; };
|
||||
PLUS lib.licenses.eupl11
|
||||
=> { licenseType = "plus"; operator = "+"; license = lib.licenses.eupl11; };
|
||||
```
|
||||
|
||||
# Type
|
||||
|
||||
@@ -5012,4 +5012,103 @@ runTests {
|
||||
testReplaceElemAtOutOfRange = testingThrow (lib.replaceElemAt [ 1 2 3 ] 5 "a");
|
||||
|
||||
testReplaceElemAtNegative = testingThrow (lib.replaceElemAt [ 1 2 3 ] (-1) "a");
|
||||
|
||||
testIsFree = {
|
||||
expr = lib.licenses.isFree (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [
|
||||
lib.licenses.free
|
||||
lib.licenses.unfree
|
||||
])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
testIsUnfree = {
|
||||
expr = lib.licenses.isFree (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [ lib.licenses.unfree ])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = false;
|
||||
};
|
||||
|
||||
testIsRedistributable = {
|
||||
expr = lib.licenses.isRedistributable (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [
|
||||
lib.licenses.free
|
||||
lib.licenses.unfree
|
||||
])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
testIsUnredistributable = {
|
||||
expr = lib.licenses.isRedistributable (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [ lib.licenses.unfree ])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = false;
|
||||
};
|
||||
|
||||
testContainsLicenses = {
|
||||
expr = lib.licenses.containsLicenses [ lib.licenses.mit ] (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [
|
||||
lib.licenses.free
|
||||
lib.licenses.unfree
|
||||
])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = true;
|
||||
};
|
||||
|
||||
testToSPDX = {
|
||||
expr = lib.licenses.toSPDX (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [
|
||||
lib.licenses.free
|
||||
lib.licenses.unfree
|
||||
])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = "MIT AND (LicenseRef-nixos-free OR LicenseRef-nixos-unfree) AND (Apache-2.0 WITH LLVM-exception) AND EUPL-1.1+";
|
||||
};
|
||||
|
||||
testEvaluateProperty = {
|
||||
expr = lib.licenses.evaluateProperty (x: x.deprecated) true (
|
||||
lib.licenses.AND [
|
||||
(lib.licenses.mit)
|
||||
(lib.licenses.OR [
|
||||
lib.licenses.free
|
||||
lib.licenses.unfree
|
||||
])
|
||||
(lib.licenses.WITH lib.licenses.asl20 lib.licenses.llvm-exception)
|
||||
(lib.licenses.PLUS lib.licenses.eupl11)
|
||||
]
|
||||
);
|
||||
expected = false;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user