mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.iterators: join: Work even with only a single iterator in the chain
This commit is contained in:
parent
12fc0febf1
commit
08b49654d9
2 changed files with 10 additions and 1 deletions
|
@ -10,6 +10,14 @@ describe("util.iterators", function ()
|
|||
end
|
||||
assert.same(output, expect);
|
||||
end);
|
||||
it("should work with only a single iterator", function ()
|
||||
local expect = { "a", "b", "c" };
|
||||
local output = {};
|
||||
for x in iter.join(iter.values({"a", "b", "c"})) do
|
||||
table.insert(output, x);
|
||||
end
|
||||
assert.same(output, expect);
|
||||
end);
|
||||
end);
|
||||
|
||||
describe("sorted_pairs", function ()
|
||||
|
|
|
@ -240,7 +240,8 @@ function join_methods:prepend(f, s, var)
|
|||
end
|
||||
|
||||
function it.join(f, s, var)
|
||||
return setmetatable({ {f, s, var} }, join_mt);
|
||||
local t = setmetatable({ {f, s, var} }, join_mt);
|
||||
return t, { t, 1 };
|
||||
end
|
||||
|
||||
return it;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue