1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-10 01:53:09 +09:00

lib.toExtension: init

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
Yueh-Shun Li 2024-07-04 20:37:01 +00:00
parent 6749b1c4bc
commit 11c20cd390
3 changed files with 83 additions and 1 deletions

View file

@ -45,6 +45,7 @@ let
const
escapeXML
evalModules
extends
filter
fix
fold
@ -102,6 +103,7 @@ let
take
testAllTrue
toBaseDigits
toExtension
toHexString
fromHexString
toInt
@ -1239,6 +1241,21 @@ runTests {
expected = {a = "a";};
};
testToExtension = {
expr = [
(fix (final: { a = 0; c = final.a; }))
(fix (extends (toExtension { a = 1; b = 2; }) (final: { a = 0; c = final.a; })))
(fix (extends (toExtension (prev: { a = 1; b = prev.a; })) (final: { a = 0; c = final.a; })))
(fix (extends (toExtension (final: prev: { a = 1; b = prev.a; c = final.a + 1; })) (final: { a = 0; c = final.a; })))
];
expected = [
{ a = 0; c = 0; }
{ a = 1; b = 2; c = 1; }
{ a = 1; b = 0; c = 1; }
{ a = 1; b = 0; c = 2; }
];
};
# GENERATORS
# these tests assume attributes are converted to lists
# in alphabetical order