Mercurial > prosody-hg
comparison spec/util_smqueue_spec.lua @ 12058:4860da718e87
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.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 16 Dec 2021 12:16:45 +0100 |
| parents | daced16154fa |
| children | 6163c8b17ea9 |
comparison
equal
deleted
inserted
replaced
| 12057:e880f5a13080 | 12058:4860da718e87 |
|---|---|
| 50 local resume = {} | 50 local resume = {} |
| 51 for _, i in q:resume() do resume[i] = true end | 51 for _, i in q:resume() do resume[i] = true end |
| 52 assert.same({ [7] = true; [8] = true; [9] = true; [10] = true; [11] = true; [12] = true }, resume); | 52 assert.same({ [7] = true; [8] = true; [9] = true; [10] = true; [11] = true; [12] = true }, resume); |
| 53 end) | 53 end) |
| 54 end) | 54 end) |
| 55 | |
| 56 describe("#table", function () | |
| 57 it("produces a compat layer", function () | |
| 58 local q = smqueue.new(10); | |
| 59 for i = 1,10 do q:push(i); end | |
| 60 do | |
| 61 local t = q:table(); | |
| 62 assert.same({ 1; 2; 3; 4; 5; 6; 7; 8; 9; 10 }, t); | |
| 63 end | |
| 64 do | |
| 65 for i = 11,20 do q:push(i); end | |
| 66 local t = q:table(); | |
| 67 assert.same({ 11; 12; 13; 14; 15; 16; 17; 18; 19; 20 }, t); | |
| 68 end | |
| 69 do | |
| 70 q:ack(15); | |
| 71 local t = q:table(); | |
| 72 assert.same({ 16; 17; 18; 19; 20 }, t); | |
| 73 end | |
| 74 do | |
| 75 q:ack(20); | |
| 76 local t = q:table(); | |
| 77 assert.same({}, t); | |
| 78 end | |
| 79 end) | |
| 80 end) | |
| 55 end); | 81 end); |
