aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-01-02 06:52:45 +0100
committerGitHub <noreply@github.com>2023-01-02 06:52:45 +0100
commitee75fcd37eaecbc5db479eb648c41a7d11144e32 (patch)
tree6c5f21b1836452808f0cab19e71911bcffa222f4 /tests/mason-core
parentfeat(functional): add split_every and default_to (#835) (diff)
downloadmason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.tar
mason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.tar.gz
mason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.tar.bz2
mason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.tar.lz
mason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.tar.xz
mason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.tar.zst
mason-ee75fcd37eaecbc5db479eb648c41a7d11144e32.zip
refactor(expr): rename to interpolate (#836)
Diffstat (limited to 'tests/mason-core')
-rw-r--r--tests/mason-core/installer/registry/expr_spec.lua22
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/mason-core/installer/registry/expr_spec.lua b/tests/mason-core/installer/registry/expr_spec.lua
index abd1874e..a52ca48b 100644
--- a/tests/mason-core/installer/registry/expr_spec.lua
+++ b/tests/mason-core/installer/registry/expr_spec.lua
@@ -4,11 +4,11 @@ local Result = require "mason-core.result"
describe("registry expressions", function()
it("should eval simple expressions", function()
- assert.same(Result.success "Hello, world!", expr.eval("Hello, world!", {}))
+ assert.same(Result.success "Hello, world!", expr.interpolate("Hello, world!", {}))
assert.same(
Result.success "Hello, John Doe!",
- expr.eval("Hello, {{firstname}} {{ lastname }}!", {
+ expr.interpolate("Hello, {{firstname}} {{ lastname }}!", {
firstname = "John",
lastname = "Doe",
})
@@ -18,14 +18,14 @@ describe("registry expressions", function()
it("should eval nested access", function()
assert.same(
Result.success "Hello, world!",
- expr.eval("Hello, {{greeting.name}}!", { greeting = { name = "world" } })
+ expr.interpolate("Hello, {{greeting.name}}!", { greeting = { name = "world" } })
)
end)
it("should eval benign expressions", function()
assert.same(
Result.success "Hello, JOHNDOE JR.!",
- expr.eval("Hello, {{greeting.firstname .. greeting.lastname .. tostring(tbl) | to_upper}}!", {
+ expr.interpolate("Hello, {{greeting.firstname .. greeting.lastname .. tostring(tbl) | to_upper}}!", {
greeting = { firstname = "John", lastname = "Doe" },
tbl = setmetatable({}, {
__tostring = function()
@@ -37,7 +37,7 @@ describe("registry expressions", function()
assert.same(
Result.success "Gloves",
- expr.eval("G{{ 'Cloves' | strip_prefix(trim) }}", {
+ expr.interpolate("G{{ 'Cloves' | strip_prefix(trim) }}", {
trim = "C",
})
)
@@ -46,7 +46,7 @@ describe("registry expressions", function()
it("should eval expressions with filters", function()
assert.same(
Result.success "Hello, MR. John!",
- expr.eval("Hello, {{prefix|to_upper}} {{ name | trim }}!", {
+ expr.interpolate("Hello, {{prefix|to_upper}} {{ name | trim }}!", {
prefix = "Mr.",
name = " John ",
})
@@ -54,7 +54,7 @@ describe("registry expressions", function()
assert.same(
Result.success "Hello, Sir MR. John!",
- expr.eval("Hello, {{prefix|to_upper | format 'Sir %s'}} {{ name | trim }}!", {
+ expr.interpolate("Hello, {{prefix|to_upper | format 'Sir %s'}} {{ name | trim }}!", {
prefix = "Mr.",
name = " John ",
})
@@ -63,20 +63,22 @@ 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.interpolate("Hello, {{non_existent}}", {}):err_or_nil()
+ )
)
end)
it("should reject invalid filters", function()
assert.is_true(
match.matches [[^.*Invalid filter expression: "whut"]](
- expr.eval("Hello, {{ value | whut }}", { value = "value" }):err_or_nil()
+ expr.interpolate("Hello, {{ value | whut }}", { value = "value" }):err_or_nil()
)
)
assert.is_true(
match.matches [[^.*Failed to parse filter: "wh%-!uut"]](
- expr.eval("Hello, {{ value | wh-!uut }}", { value = "value" }):err_or_nil()
+ expr.interpolate("Hello, {{ value | wh-!uut }}", { value = "value" }):err_or_nil()
)
)
end)