aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_cache_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-02-05 16:14:06 +0100
committerKim Alvefur <zash@zash.se>2021-02-05 16:14:06 +0100
commitfdacac857f8e2f0eb7307a2a8a7b81d18e1bb5af (patch)
tree2ae8076df020533e67b8db37698665e20bead9ca /spec/util_cache_spec.lua
parent196c9f070e695676e8b329d67666b083876e01fa (diff)
downloadprosody-fdacac857f8e2f0eb7307a2a8a7b81d18e1bb5af.tar.gz
prosody-fdacac857f8e2f0eb7307a2a8a7b81d18e1bb5af.zip
util.cache: Add test for :table (fails on Lua 5.1)
Diffstat (limited to 'spec/util_cache_spec.lua')
-rw-r--r--spec/util_cache_spec.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/util_cache_spec.lua b/spec/util_cache_spec.lua
index 15e86ee9..d57e25ac 100644
--- a/spec/util_cache_spec.lua
+++ b/spec/util_cache_spec.lua
@@ -311,6 +311,30 @@ describe("util.cache", function()
expect_kv("e", 5, c5:head());
expect_kv("c", 3, c5:tail());
+
+ end);
+
+ (_VERSION=="Lua 5.1" and pending or it)(":table works", function ()
+ local t = cache.new(3):table();
+ assert.is.table(t);
+ t["a"] = "1";
+ assert.are.equal(t["a"], "1");
+ t["b"] = "2";
+ assert.are.equal(t["b"], "2");
+ t["c"] = "3";
+ assert.are.equal(t["c"], "3");
+ t["d"] = "4";
+ assert.are.equal(t["d"], "4");
+ assert.are.equal(t["a"], nil);
+
+ local i = spy.new(function () end);
+ for k, v in pairs(t) do
+ i(k,v)
+ end
+ assert.spy(i).was_called();
+ assert.spy(i).was_called_with("b", "2");
+ assert.spy(i).was_called_with("c", "3");
+ assert.spy(i).was_called_with("d", "4");
end);
end);
end);