(This last because the Test.expectError() call does not seem to handle errors as stated.)
This is actually because you didn't read the docs properly and see that Test.expectError expects a function argument. You have to wrap the call into a function.
Again, I think the data structure add unecessary difficulty.
I feel like you should have three kata: point in poly (4kyu) bezier curve (5 kyu) and this easy kata (5/6 kyu) wich would use both previous kata. Here you chose to give an introduction to point in polygon but not bezier curve. So this kata is a bit misleading as one can think it is about points in a polygon but it is about bezier curves.
Hi wfleet, the Test.expectError call has worked for me in the past, so if I may ask, did you pass it a function that invokes pointInPoly or did you pass pointInPoly or its result directly? That is, was it like this:
Test.expectError(function() { // does what you want
pointInPoly(thisPolygon, thisPoint);
});
or like this:
Test.expectError(pointInPoly(thisPolygon, thisPoint)); // probably won't do what you want
Needs more tests, and random tests.
This comment is hidden because it contains spoiler information about the solution
Images are broken, wrong(wikipedia was never a commercial) links.
[I'll fix them, soon]
This comment is hidden because it contains spoiler information about the solution
This is actually because you didn't read the docs properly and see that
Test.expectError
expects a function argument. You have to wrap the call into a function.Input validation does not add to the problem. Please just don't.
Polygons with points in clockwise order are not tested.
Could somebody subtitle what the defining property of a curve "like this" is? I don't feel like reverse engineering it.
As with http://www.codewars.com/kata/point-in-polygon-1/
Polygons like these were not tested:
And I believe many solutions will fail on convex polygons like that.
Test.expectError
takes a function argument, which it calls and expects an error to occur. You're probably writing something like:rather than,
Note that the first way (the way that didn't work) is equivalent to this:
What's the point of saying a polygon can contain curves, if it can't really contain curves?
Again, I think the data structure add unecessary difficulty.
I feel like you should have three kata: point in poly (4kyu) bezier curve (5 kyu) and this easy kata (5/6 kyu) wich would use both previous kata. Here you chose to give an introduction to point in polygon but not bezier curve. So this kata is a bit misleading as one can think it is about points in a polygon but it is about bezier curves.
Nice kata. I don't get the point of adding lineto and moveto in the polygon description. I think an array of points would suffice.
OK, I was doing the latter, and wondering why it was recieveing the error, and then throwing another error. I should probably rewrite this. Thanks!
Hi wfleet, the
Test.expectError
call has worked for me in the past, so if I may ask, did you pass it a function that invokespointInPoly
or did you passpointInPoly
or its result directly? That is, was it like this:or like this: