Skip to content

Initial Tests for Vector2D #30

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

Merged
merged 3 commits into from
Apr 1, 2017
Merged

Initial Tests for Vector2D #30

merged 3 commits into from
Apr 1, 2017

Conversation

z3dev
Copy link
Member

@z3dev z3dev commented Mar 25, 2017

Let's keep those tests rolling in!!!!

@kaosat-dev
Copy link
Contributor

Great set of tests @z3dev !
Only one issue : failing Travis build due to a single rounding error: is that test passing for you locally ?

@z3dev
Copy link
Member Author

z3dev commented Mar 28, 2017

All test pass on Mac OS. I was wondering if there would be issues with rounding. We need another test for these values, something like "equal within 0.000001"

@kaosat-dev
Copy link
Contributor

Since ava does not support other assertions (avajs/ava#1094)

The simplest solution is this one

const precision = 0.000001
t.deepEqual(Math.abs(expected-observed) < precision) 

and voila ! solved :)
simple and straight to the point I think
if we really want to we could wrap it for re-use

function almostEquals(t, observed, expected, precision=0.0000001){
t.deepEqual(Math.abs(expected-observed) < precision) 
}

and use it like this

almostEquals(t, observed, expected)

@z3dev
Copy link
Member Author

z3dev commented Apr 1, 2017

Looks like a function is required, which is explained here... http://floating-point-gui.de/errors/comparison/

I'll add a helper for this.

@z3dev
Copy link
Member Author

z3dev commented Apr 1, 2017

@kaosat-dev please review the helper function. i tested the different cases of comparisons. Seems to work fine.

@kaosat-dev
Copy link
Contributor

Yup , helper is ok, and all tests are passing, well done !

@kaosat-dev kaosat-dev merged commit a0e21dd into jscad:master Apr 1, 2017
kaosat-dev added a commit that referenced this pull request Jan 14, 2018
* chore(pkg): updated csg.js dependency
* docs(rotate_extrude): added missing parameter to docstrings
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.

2 participants