aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-03-17 17:28:07 +0000
committerMatthew Wild <mwild1@gmail.com>2018-03-17 17:28:07 +0000
commitf0d4a5254e293caa9995dc7f28ac2c43a68b9d89 (patch)
treeba0e2d77d6915d76cae53d08f22749679b773f2c /spec
parent3148c6b4f70a43bf3616bd967c02f51297a3f640 (diff)
downloadprosody-f0d4a5254e293caa9995dc7f28ac2c43a68b9d89.tar.gz
prosody-f0d4a5254e293caa9995dc7f28ac2c43a68b9d89.zip
util.async: ensure change in e77b37de482e applies after out-of-loop resume also
Diffstat (limited to 'spec')
-rw-r--r--spec/util_async_spec.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/util_async_spec.lua b/spec/util_async_spec.lua
index 24f4d8c8..f7d11be0 100644
--- a/spec/util_async_spec.lua
+++ b/spec/util_async_spec.lua
@@ -180,6 +180,31 @@ describe("util.async", function()
assert.spy(runner.watchers.error).was.called(1);
assert.equal(last_item, "two");
end);
+
+ it("should continue to process work items during resume", function ()
+ local wait, done, last_item;
+ local runner_func = spy.new(function (item)
+ if item == "error" then
+ error("test error");
+ elseif item == "wait-error" then
+ wait, done = async.waiter();
+ wait();
+ error("test error");
+ end
+ last_item = item;
+ end);
+ local runner = async.runner(runner_func, { error = spy.new(function () end) });
+ runner:enqueue("one");
+ runner:enqueue("wait-error");
+ runner:enqueue("two");
+ runner:run();
+ done();
+ assert.equal(r.state, "ready");
+ assert.equal(r.state, r.notified_state);
+ assert.spy(runner_func).was.called(3);
+ assert.spy(runner.watchers.error).was.called(1);
+ assert.equal(last_item, "two");
+ end);
end);
end);
describe("#waiter", function()