Changeset

9510:8ef46d09386a

util.promise: Fix promise.reject() to return a rejected promise, and fix buggy test for it
author Matthew Wild <mwild1@gmail.com>
date Thu, 18 Oct 2018 12:03:33 +0100
parents 9509:b57353f76c83
children 9511:cb88d729e98d
files spec/util_promise_spec.lua util/promise.lua
diffstat 2 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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