diff options
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/misc.nix | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index 6175f15819a7..35a5801c724f 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -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; |