From 8a38579fa00e08ea10ff0eee2e4cdb7cd6bb1a3a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 23 Mar 2018 14:02:33 +0000 Subject: util.async: Make parameters to async.runner() optional --- spec/util_async_spec.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec/util_async_spec.lua') diff --git a/spec/util_async_spec.lua b/spec/util_async_spec.lua index 959ad65b..d81b18b5 100644 --- a/spec/util_async_spec.lua +++ b/spec/util_async_spec.lua @@ -94,6 +94,26 @@ describe("util.async", function() assert.equal(last_item, values[#values]); end); + it("should work with no parameters", function () + local item = "fail"; + local r = async.runner(); + local f = spy.new(function () item = "success"; end); + r:run(f); + assert.spy(f).was.called(); + assert.equal(item, "success"); + end); + + it("supports a default error handler", function () + local item = "fail"; + local r = async.runner(); + local f = spy.new(function () error("test error"); end); + assert.error_matches(function () + r:run(f); + end, "test error"); + assert.spy(f).was.called(); + assert.equal(item, "fail"); + end); + describe("#errors", function () describe("should notify", function () local last_processed_item, last_error; -- cgit v1.2.3