diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/util_spec.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 5aa49b4c..0c2d620e 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
@@ -72,6 +72,31 @@ describe("luarocks.util #unit", function() | |||
72 | runner.shutdown() | 72 | runner.shutdown() |
73 | end) | 73 | end) |
74 | 74 | ||
75 | describe("util.variable_substitutions", function() | ||
76 | it("replaces variables", function() | ||
77 | local t = { | ||
78 | ["hello"] = "$(KIND) world", | ||
79 | } | ||
80 | util.variable_substitutions(t, { | ||
81 | ["KIND"] = "happy", | ||
82 | }) | ||
83 | assert.are.same({ | ||
84 | ["hello"] = "happy world", | ||
85 | }, t) | ||
86 | end) | ||
87 | |||
88 | it("missing variables are empty", function() | ||
89 | local t = { | ||
90 | ["hello"] = "$(KIND) world", | ||
91 | } | ||
92 | util.variable_substitutions(t, { | ||
93 | }) | ||
94 | assert.are.same({ | ||
95 | ["hello"] = " world", | ||
96 | }, t) | ||
97 | end) | ||
98 | end) | ||
99 | |||
75 | describe("util.sortedpairs", function() | 100 | describe("util.sortedpairs", function() |
76 | local function collect(iter, state, var) | 101 | local function collect(iter, state, var) |
77 | local collected = {} | 102 | local collected = {} |