# HG changeset patch # User Matthew Wild # Date 1731410749 0 # Node ID 56e112b890ead97f716c5a7de4c2d75a272c4bd4 # Parent 63492b6e7fb6dacac7064faf10d1b933fc2f7ee5 util.queue: tests: Add test for :replace() method diff -r 63492b6e7fb6 -r 56e112b890ea spec/util_queue_spec.lua --- a/spec/util_queue_spec.lua Mon Nov 11 08:49:57 2024 +0100 +++ b/spec/util_queue_spec.lua Tue Nov 12 11:25:49 2024 +0000 @@ -137,4 +137,23 @@ assert.equal(c, 6); end); end); + describe("replace()", function () + it("should work", function () + local q = queue.new(10); + for i = 1, 5 do + q:push(i); + end + q:replace(6); + local c = 0; + for i in q:consume() do + c = c + 1; + if c > 1 then + assert.is_equal(c, i); + elseif c == 1 then + assert.is_equal(6, i); + end + end + assert.is_equal(5, c); + end); + end); end);