Software /
code /
prosody
Comparison
spec/util_iterators_spec.lua @ 12744:e894677359e5
util.iterators: join: Work even with only a single iterator in the chain
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 06 Oct 2022 18:34:40 +0100 |
parent | 9328:a9592107021b |
comparison
equal
deleted
inserted
replaced
12743:19113f232423 | 12744:e894677359e5 |
---|---|
4 describe("join", function () | 4 describe("join", function () |
5 it("should produce a joined iterator", function () | 5 it("should produce a joined iterator", function () |
6 local expect = { "a", "b", "c", 1, 2, 3 }; | 6 local expect = { "a", "b", "c", 1, 2, 3 }; |
7 local output = {}; | 7 local output = {}; |
8 for x in iter.join(iter.values({"a", "b", "c"})):append(iter.values({1, 2, 3})) do | 8 for x in iter.join(iter.values({"a", "b", "c"})):append(iter.values({1, 2, 3})) do |
9 table.insert(output, x); | |
10 end | |
11 assert.same(output, expect); | |
12 end); | |
13 it("should work with only a single iterator", function () | |
14 local expect = { "a", "b", "c" }; | |
15 local output = {}; | |
16 for x in iter.join(iter.values({"a", "b", "c"})) do | |
9 table.insert(output, x); | 17 table.insert(output, x); |
10 end | 18 end |
11 assert.same(output, expect); | 19 assert.same(output, expect); |
12 end); | 20 end); |
13 end); | 21 end); |