lib: Add composeManyExtensions

This commit is contained in:
Joe Hermaszewski
2020-11-13 21:37:57 +01:00
committed by Peter Simons
parent bacdeffd80
commit c3b35f21f7
3 changed files with 32 additions and 3 deletions
+20
View File
@@ -87,6 +87,26 @@ runTests {
expected = true;
};
testComposeManyExtensions0 = {
expr = let obj = makeExtensible (self: { foo = true; });
emptyComposition = composeManyExtensions [];
composed = obj.extend emptyComposition;
in composed.foo;
expected = true;
};
testComposeManyExtensions =
let f = self: super: { bar = false; baz = true; };
g = self: super: { bar = super.baz or false; };
h = self: super: { qux = super.bar or false; };
obj = makeExtensible (self: { foo = self.qux; });
in {
expr = let composition = composeManyExtensions [f g h];
composed = obj.extend composition;
in composed.foo;
expected = (obj.extend (composeExtensions f (composeExtensions g h))).foo;
};
testBitAnd = {
expr = (bitAnd 3 10);
expected = 2;