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

Assertion fails when comparing progress #16

Closed
mzaks opened this issue Apr 10, 2014 · 3 comments
Closed

Assertion fails when comparing progress #16

mzaks opened this issue Apr 10, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@mzaks
Copy link

mzaks commented Apr 10, 2014

From Time to time I see assertion failure
https://github.com/b52/OMPromises/blob/master/Classes/Core/OMDeferred.m#L90
NSAssert(self.progress <= progress, @"Progress can only increase");

Even though the progress is equal.

Please have a look at this article.
http://stackoverflow.com/questions/10334688/how-dangerous-is-it-to-compare-floating-point-values

In the comments you can find explanation and solution for the issue.

My suggestion for a quick fix:
NSAssert(self.progress - progress < 0.001, @"Progress can only increase");

@aomader aomader self-assigned this Apr 10, 2014
@aomader aomader added the bug label Apr 10, 2014
@aomader
Copy link
Owner

aomader commented Apr 10, 2014

Interesting point! I never came across that problem myself, but you are completely right:
We should make the comparison less strict and anticipate a bounded error.

I'll fix that and check all similar progress related methods for similar errors.

@mzaks
Copy link
Author

mzaks commented Apr 11, 2014

To be honest, I tried to reproduce this behavior in a unit test and failed :).
However I will monitor this problem closer maybe I will be able to find the exact constellation.

Thanks for the fast reply btw. :)

@aomader
Copy link
Owner

aomader commented Apr 11, 2014

progress: is now less strict and anticipates an uncertainty within FLT_EPSILON, see commit 2a14c4e. I also added a corresponding test.
Do you mind checking if your problem still exists using this version? If so, re-open the ticket please! ;)

@aomader aomader closed this as completed Apr 11, 2014
@aomader aomader added this to the 0.4.0 milestone May 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants