Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fast failing to all remaining curried functions #69

Merged
merged 1 commit into from
Feb 13, 2017
Merged

Conversation

Avaq
Copy link
Member

@Avaq Avaq commented Feb 10, 2017

Finally finally closes #4

I've reverted the commits involved in #66 because it broke multiple of the affected functions. The reason some of the functions broke is because of arguments being passed into class constructors in the wrong order. The reason this wasn't caught by unit-tests is because all I'm asserting for the static constructors, is that they return the expected class instance. The actual test of the class instances themselves use instances created by methods (rather than the static functions affected in this commit).

Now I'm reluctant to merge this until I know that these kind of mistakes would be caught by the unit tests. Maybe I should run all instance tests on several instances, each created in a different way. For now that means that most instance tests would run twice.


function mapRej$mapper(mapper, m){
if(!isFuture(m)) invalidArgument('Future.mapRej', 1, 'be a Future', m);
return new FutureMapRej(m, mapper);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #66, this line incorrectly contained return new FutureMapRej(mapper, m);

fluture.js Outdated

function fold$f$g(f, g, m){
if(!isFuture(m)) invalidArgument('Future.fold', 2, 'be a Future', m);
return new FutureFold(f, g, m);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is also incorrect. The first argument should be m.

fluture.js Outdated

function finally$left(left, right){
if(!isFuture(right)) invalidArgument('Future.finally', 1, 'be a Future', right);
return new FutureFinally(left, right);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These arguments were also flipped compared to the previous version, which was a far less obvious breaking change.

@@ -2,113 +2,65 @@

const expect = require('chai').expect;
const Future = require('../fluture.js');
const FutureAnd = Future.classes.FutureAnd;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this new way of testing, because it tests behavior rather than implementation.

});

//TODO: Argument order.
testInstance((a, b) => Future.and(a, b));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future.and was one of the functions I implemented without a createDispatcher from the start, and I made the same mistake there that caused all this mess now. Essentially the argument order of Future.and is the wrong way around (static functions should be flipped). If I'd fix that now, it would be a breaking change, hence the #TODO.

@codecov-io
Copy link

codecov-io commented Feb 13, 2017

Codecov Report

Merging #69 into master will not change coverage.
The diff coverage is 100%.

@@          Coverage Diff          @@
##           master    #69   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         831    889   +58     
  Branches      182    214   +32     
=====================================
+ Hits          831    889   +58
Impacted Files Coverage Δ
fluture.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b69bce4...d6e60a8. Read the comment docs.

});

//TODO: Argument order.
testInstance((a, b) => Future.both(a, b));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment on future-and.test.js.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's quite expectable that Future.both(ma, mb) would give me Future [a ,b] and not Future [b, a]. I'm going to remove this comment.

@Avaq
Copy link
Member Author

Avaq commented Feb 13, 2017

Functions that turned out to be broken after fixing the tests:

  • mapRej
  • chainRej
  • race
  • finally
  • fold

It's surprising nobody talked to me about experienced issues over the nine days that this was live.

@Avaq Avaq requested review from davidchambers and removed request for davidchambers February 13, 2017 12:34
@Avaq Avaq merged commit fcc8386 into master Feb 13, 2017
@Avaq Avaq deleted the av-fail-fast branch February 14, 2017 14:05
Avaq added a commit that referenced this pull request Feb 23, 2017
Breaking changes

- #74 The argument order of `Future.or()` has been flipped
- #75 `Future.isForkable()` has been removed
- #75 `Future.fromForkable()` has been removed
- #75 `Future.cast()` has been removed

New features

- #70 Add a new ConcurrentFuture type

Bug fixes and improvements

- #4 #69 All curried functions now fail fast
- #59 Update Sanctuary interoperability
- #73 `Future.finally()` now runs `finally` computation when cancelled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail-fast curried functions
2 participants