aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-16 12:16:45 +0100
committerKim Alvefur <zash@zash.se>2021-12-16 12:16:45 +0100
commit081647ea1ffaf7bf932e727c9311e765b642da5b (patch)
treede2384b2981bf7c5f94fe5ca3547bb09b86a984e /spec
parent81d747b6a48402d86b97442866842e4feffca8b9 (diff)
downloadprosody-081647ea1ffaf7bf932e727c9311e765b642da5b.tar.gz
prosody-081647ea1ffaf7bf932e727c9311e765b642da5b.zip
util.smqueue: Simplify compat table, fix dependent modules (thanks Martin)
There was an off-by-one in the modulo calculation. Switching to a plain old array-table makes the apparent size of the queue wrong, but since some of the queue may not be available this is likely for the best.
Diffstat (limited to 'spec')
-rw-r--r--spec/util_smqueue_spec.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/util_smqueue_spec.lua b/spec/util_smqueue_spec.lua
index 991a656b..0a02a60b 100644
--- a/spec/util_smqueue_spec.lua
+++ b/spec/util_smqueue_spec.lua
@@ -52,4 +52,30 @@ describe("util.smqueue", function()
assert.same({ [7] = true; [8] = true; [9] = true; [10] = true; [11] = true; [12] = true }, resume);
end)
end)
+
+ describe("#table", function ()
+ it("produces a compat layer", function ()
+ local q = smqueue.new(10);
+ for i = 1,10 do q:push(i); end
+ do
+ local t = q:table();
+ assert.same({ 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 }, t);
+ end
+ do
+ for i = 11,20 do q:push(i); end
+ local t = q:table();
+ assert.same({ 11; 12; 13; 14; 15; 16; 17; 18; 19; 20 }, t);
+ end
+ do
+ q:ack(15);
+ local t = q:table();
+ assert.same({ 16; 17; 18; 19; 20 }, t);
+ end
+ do
+ q:ack(20);
+ local t = q:table();
+ assert.same({}, t);
+ end
+ end)
+ end)
end);