util.promise: Fix promise.reject() to return a rejected promise, and fix buggy test for it
authorMatthew Wild <mwild1@gmail.com>
Thu, 18 Oct 2018 12:03:33 +0100
changeset 9513 8ef46d09386a
parent 9512 b57353f76c83
child 9514 cb88d729e98d
util.promise: Fix promise.reject() to return a rejected promise, and fix buggy test for it
spec/util_promise_spec.lua
util/promise.lua
--- a/spec/util_promise_spec.lua	Thu Oct 18 00:49:29 2018 +0200
+++ b/spec/util_promise_spec.lua	Thu Oct 18 12:03:33 2018 +0100
@@ -253,7 +253,7 @@
 		it("returns a rejected promise", function ()
 			local p = promise.reject("foo");
 			local cb = spy.new(function () end);
-			p:next(cb);
+			p:catch(cb);
 			assert.spy(cb).was_called(1);
 			assert.spy(cb).was_called_with("foo");
 		end);
--- a/util/promise.lua	Thu Oct 18 00:49:29 2018 +0200
+++ b/util/promise.lua	Thu Oct 18 12:03:33 2018 +0100
@@ -119,7 +119,7 @@
 end
 
 local function reject(v)
-	return new(function (_reject)
+	return new(function (_, _reject)
 		_reject(v);
 	end);
 end