diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2022-06-06 15:43:58 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2022-06-06 17:14:52 -0300 |
commit | 42c5886178e5ca0cf4796ad45b1594087cb8da4e (patch) | |
tree | c778efabbb593d14a7ba826a3b82a6ad3f3744a7 /spec | |
parent | 781a8f8495fc9adea5af2840333c7ab14e9aa183 (diff) | |
download | luarocks-42c5886178e5ca0cf4796ad45b1594087cb8da4e.tar.gz luarocks-42c5886178e5ca0cf4796ad45b1594087cb8da4e.tar.bz2 luarocks-42c5886178e5ca0cf4796ad45b1594087cb8da4e.zip |
tests: tests for util.variable_substitutions
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 = {} |