Software / code / prosody
Comparison
spec/util_async_spec.lua @ 8616:a15c891c6232
util.async: ensure change in e77b37de482e applies after out-of-loop resume also
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 17 Mar 2018 17:28:07 +0000 |
| parent | 8615:e77b37de482e |
| child | 8617:fafb4036771c |
comparison
equal
deleted
inserted
replaced
| 8615:e77b37de482e | 8616:a15c891c6232 |
|---|---|
| 178 assert.equal(r.state, r.notified_state); | 178 assert.equal(r.state, r.notified_state); |
| 179 assert.spy(runner_func).was.called(3); | 179 assert.spy(runner_func).was.called(3); |
| 180 assert.spy(runner.watchers.error).was.called(1); | 180 assert.spy(runner.watchers.error).was.called(1); |
| 181 assert.equal(last_item, "two"); | 181 assert.equal(last_item, "two"); |
| 182 end); | 182 end); |
| 183 | |
| 184 it("should continue to process work items during resume", function () | |
| 185 local wait, done, last_item; | |
| 186 local runner_func = spy.new(function (item) | |
| 187 if item == "error" then | |
| 188 error("test error"); | |
| 189 elseif item == "wait-error" then | |
| 190 wait, done = async.waiter(); | |
| 191 wait(); | |
| 192 error("test error"); | |
| 193 end | |
| 194 last_item = item; | |
| 195 end); | |
| 196 local runner = async.runner(runner_func, { error = spy.new(function () end) }); | |
| 197 runner:enqueue("one"); | |
| 198 runner:enqueue("wait-error"); | |
| 199 runner:enqueue("two"); | |
| 200 runner:run(); | |
| 201 done(); | |
| 202 assert.equal(r.state, "ready"); | |
| 203 assert.equal(r.state, r.notified_state); | |
| 204 assert.spy(runner_func).was.called(3); | |
| 205 assert.spy(runner.watchers.error).was.called(1); | |
| 206 assert.equal(last_item, "two"); | |
| 207 end); | |
| 183 end); | 208 end); |
| 184 end); | 209 end); |
| 185 describe("#waiter", function() | 210 describe("#waiter", function() |
| 186 it("should error outside of async context", function () | 211 it("should error outside of async context", function () |
| 187 assert.has_error(function () | 212 assert.has_error(function () |