add tests to cover lset and requireTo aliases

This commit is contained in:
Dmitriy Pleshevskiy 2024-05-20 00:08:38 +03:00
parent b447430d99
commit da13688260
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2

View file

@ -178,6 +178,10 @@ with nix2lua; pkgs.lib.runTests {
expr = toLua (local (set "parser_config.d2" { })); expr = toLua (local (set "parser_config.d2" { }));
expected = "local parser_config.d2 = { }"; expected = "local parser_config.d2 = { }";
}; };
"test returns a short variant of setting a value to the local variable" = {
expr = toLua (lset "parser_config.d2" { });
expected = "local parser_config.d2 = { }";
};
"test returns all operations" = { "test returns all operations" = {
expr = toLua (spaceBetween [ expr = toLua (spaceBetween [
(set "a" (eq (mul (add 1 2) (sub 2 1)) 3)) (set "a" (eq (mul (add 1 2) (sub 2 1)) 3))
@ -235,4 +239,8 @@ with nix2lua; pkgs.lib.runTests {
expr = toLua (ifelse (eq 10 10) return_void (return 10)); expr = toLua (ifelse (eq 10 10) return_void (return 10));
expected = ''if (10 == 10) then return else return 10 end''; expected = ''if (10 == 10) then return else return 10 end'';
}; };
"test returns a definition of a variable with require function" = {
expr = toLua (requireTo "ls" "luasnip");
expected = ''local ls = require("luasnip")'';
};
} }