lib.generators.toLua: asBindings option
Allows to generate code block for setting of global variables
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
with import ../default.nix;
|
||||
|
||||
let
|
||||
testingThrow = expr: {
|
||||
expr = (builtins.tryEval (builtins.seq expr "didn't throw"));
|
||||
expected = { success = false; value = false; };
|
||||
};
|
||||
testingDeepThrow = expr: testingThrow (builtins.deepSeq expr expr);
|
||||
|
||||
testSanitizeDerivationName = { name, expected }:
|
||||
let
|
||||
@@ -962,6 +967,41 @@ runTests {
|
||||
expected = ''{ 41, 43 }'';
|
||||
};
|
||||
|
||||
testToLuaEmptyBindings = {
|
||||
expr = generators.toLua { asBindings = true; } {};
|
||||
expected = "";
|
||||
};
|
||||
|
||||
testToLuaBindings = {
|
||||
expr = generators.toLua { asBindings = true; } { x1 = 41; _y = { a = 43; }; };
|
||||
expected = ''
|
||||
_y = {
|
||||
["a"] = 43
|
||||
}
|
||||
x1 = 41
|
||||
'';
|
||||
};
|
||||
|
||||
testToLuaPartialTableBindings = {
|
||||
expr = generators.toLua { asBindings = true; } { "x.y" = 42; };
|
||||
expected = ''
|
||||
x.y = 42
|
||||
'';
|
||||
};
|
||||
|
||||
testToLuaIndentedBindings = {
|
||||
expr = generators.toLua { asBindings = true; indent = " "; } { x = { y = 42; }; };
|
||||
expected = " x = {\n [\"y\"] = 42\n }\n";
|
||||
};
|
||||
|
||||
testToLuaBindingsWithSpace = testingThrow (
|
||||
generators.toLua { asBindings = true; } { "with space" = 42; }
|
||||
);
|
||||
|
||||
testToLuaBindingsWithLeadingDigit = testingThrow (
|
||||
generators.toLua { asBindings = true; } { "11eleven" = 42; }
|
||||
);
|
||||
|
||||
testToLuaBasicExample = {
|
||||
expr = generators.toLua {} {
|
||||
cmd = [ "typescript-language-server" "--stdio" ];
|
||||
|
||||
Reference in New Issue
Block a user