aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-12-26 17:04:53 +0100
committerGitHub <noreply@github.com>2022-12-26 17:04:53 +0100
commit0d14400ab3755f27041f70566d6b78f48c82c54c (patch)
treebd18e1f1c5a02cf359027b72c1a10934b21e9c23 /tests
parentfeat(result): add .try() interface (#804) (diff)
downloadmason-0d14400ab3755f27041f70566d6b78f48c82c54c.tar
mason-0d14400ab3755f27041f70566d6b78f48c82c54c.tar.gz
mason-0d14400ab3755f27041f70566d6b78f48c82c54c.tar.bz2
mason-0d14400ab3755f27041f70566d6b78f48c82c54c.tar.lz
mason-0d14400ab3755f27041f70566d6b78f48c82c54c.tar.xz
mason-0d14400ab3755f27041f70566d6b78f48c82c54c.tar.zst
mason-0d14400ab3755f27041f70566d6b78f48c82c54c.zip
feat(expr): add tbl_interpolate() (#805)
Diffstat (limited to 'tests')
-rw-r--r--tests/mason-core/installer/registry/expr_spec.lua42
1 files changed, 39 insertions, 3 deletions
diff --git a/tests/mason-core/installer/registry/expr_spec.lua b/tests/mason-core/installer/registry/expr_spec.lua
index be9de0d7..abd1874e 100644
--- a/tests/mason-core/installer/registry/expr_spec.lua
+++ b/tests/mason-core/installer/registry/expr_spec.lua
@@ -63,21 +63,57 @@ describe("registry expressions", function()
it("should reject invalid values", function()
assert.is_true(
- match.matches [[^.*Value is nil: "non_existent"%.$]](expr.eval("Hello, {{non_existent}}", {}):err_or_nil())
+ match.matches [[^.*Value is nil: "non_existent"]](expr.eval("Hello, {{non_existent}}", {}):err_or_nil())
)
end)
it("should reject invalid filters", function()
assert.is_true(
- match.matches [[^.*Invalid filter expression: "whut"%.$]](
+ match.matches [[^.*Invalid filter expression: "whut"]](
expr.eval("Hello, {{ value | whut }}", { value = "value" }):err_or_nil()
)
)
assert.is_true(
- match.matches [[^.*Failed to parse filter: "wh%-!uut"%.$]](
+ match.matches [[^.*Failed to parse filter: "wh%-!uut"]](
expr.eval("Hello, {{ value | wh-!uut }}", { value = "value" }):err_or_nil()
)
)
end)
end)
+
+describe("table interpolation", function()
+ it("should interpolate nested values", function()
+ assert.same(
+ Result.success {
+ some = {
+ nested = {
+ value = "here",
+ },
+ },
+ },
+ expr.tbl_interpolate({
+ some = {
+ nested = {
+ value = "{{value}}",
+ },
+ },
+ }, { value = "here" })
+ )
+ end)
+
+ it("should only only interpolate string values", function()
+ assert.same(
+ Result.success {
+ a = 1,
+ b = { c = 2 },
+ d = "Hello!",
+ },
+ expr.tbl_interpolate({
+ a = 1,
+ b = { c = 2 },
+ d = "Hello!",
+ }, {})
+ )
+ end)
+end)