-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fixed #37. #38
Fixed #37. #38
Conversation
Yeah actually this doesn't make sense. Hold up, yo. |
That's better. |
CGFloat y = (self.contentSize.height / self.originalSize.height) * point.y; | ||
return CGPointMake(round(x), round(y)); | ||
BOOL withinBounds = fabsf(self.originalSize.width) > 0 && fabsf(self.originalSize.height) > 0; | ||
NSAssert(withinBounds, @"originalSize dimension is zero, will result in NaN in returned value."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the name of this variable: "withinBounds"? Is that more like "hasOriginalSize"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's better 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, when contentSize
is zero, you get zero. That's possible, right? and would be assertable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing.
Fixed those issues. |
This definitely needs tests! Since you cannot stub the assert I would extract the asserting code into a function that returns a BOOL and stub it away in a test. |
Also please update CHANGELOG. |
Ah, would you believe that I did update it but I forgot to add it to the staged changes? >.< |
I definitely agree that this should be tested, though I'm not sure that I like the idea of a checking method doing the assertion, instead. Hmm... |
@@ -1,3 +1,7 @@ | |||
### Next | |||
|
|||
* [#37](https://github.com/neilang/NAMapKit/issues/37) - Fix `NAMapView` from returning `{NaN, NaN}`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an - [@ashfurrow](...), see format below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
What do you think of this? Makes it testable without a weird interface. - (BOOL)checkContentSize
{
BOOL hasContentSize = self.hasContentSize;
NSAssert(hasContentSize, @"originalSize dimension is zero, will result in NaN in returned value.");
return hasContentSize;
}
- (BOOL)hasContentSize
{
return fabsf(self.originalSize.width) > 0 && fabsf(self.originalSize.height) > 0;
}
BOOL hasContentSize = [self checkContentSize];
if (...) {
} |
I think we can write a test to expect the raised exception:
|
What do you think? |
I think there're two expectations here to test: one that it raises, but the other that it returns the original point in that case. |
That's a valid point – I just don't like the idea that a method that's checking for a condition and returns success/failure might throw. Seems ... unsavoury somehow. Let me think on this. |
raising an exception and returning the original point is a really weird pattern IMO. I think just raising the exception should be enough, it's to catch programmer errors. |
So maybe get rid of the |
I'm cool with what @orta thinks. This discussion btw would make for a good blog post :) |
👍 You don't have to tell me twice. |
💚 |
@@ -1,3 +1,7 @@ | |||
### Next | |||
|
|||
* [#37](https://github.com/neilang/NAMapKit/issues/37) - Fix `NAMapView` from returning `{NaN, NaN}` - [@ashfurrow](http://github.com/ashfurrow). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say "Added assert inside NAMapView#zoomRelativePoint when returning {NaN, NaN}
"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good
k, merged, thanks for your cooperation and patience with me and @orta, @ashfurrow |
No problem! Does one of you own the pod on trunk? I'll write up a blog post tomorrow. |
I'll do a release at some point soon, for now just use :head. |
|
That's nuts. |
that sounds unintuitive, are you sure that's the behavior? It should do that without the Though it looks like the guides' section on this is broken, sigh. |
Hmmm. Now I'm confused. I thought that was the behaviour, based on this stack overflow question and problems I've had with the ReactiveCocoa podspec. Now I'm not so sure. |
No description provided.