Skip to content

Commit

Permalink
fix another brown paper bag Future.mapFailure bug
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanueltouzery committed Aug 11, 2018
1 parent 2eb41fd commit 77ed935
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class Future<T> {
* This method is eager, will trigger the underlying Promise.
*/
mapFailure(fn: (x:any)=>any): Future<T> {
const lazy = Lazy.of(()=>this.promise.get().catch(x => {throw [fn(x)]}));
const lazy = Lazy.of(()=>this.promise.get().catch(x => {throw fn(x)}));
lazy.get();
return new Future<T>(lazy);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async function ensureFailedWithValue<T>(val: any, promise:Promise<T>) {
v = await promise;
assert.ok(false);
} catch (err) {
assert.equal(val, err);
assert.deepEqual(val, err);
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ describe("Future.map*", () => {
});
it("mapFailure works", async () => {
return ensureFailedWithValue(
"oops, sorry", Future.failed("sorry").mapFailure(err => "oops, " + err).toPromise());
"SORRY", Future.failed("sorry").mapFailure(err => err.toUpperCase()).toPromise());
});
it("mapFailure is a nop on successful futures", async () => {
assert.deepEqual(5, await Future.ok(5).mapFailure(_ => "oops"));
Expand Down

0 comments on commit 77ed935

Please sign in to comment.