Skip to content

Commit

Permalink
Make vectorsAreEqual() tests slightly fuzzy
Browse files Browse the repository at this point in the history
  • Loading branch information
zz85 committed Nov 26, 2015
1 parent e3d2617 commit da61251
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/unit/extras/curves/ClosedSplineCurve3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@

module( "ClosedSplineCurve3" );

var threshold = 0.000001;

function vectorsAreEqual( check, that ) {

if ( check.length !== that.length ) return 'Length not equal';

for ( var i = 0; i < check.length; i ++ ) {

if ( ! check[ i ] .equals( that[ i ] ) ) {
var a = check[ i ], b = that[ i ];
console.log( a.distanceToSquared( b ) )

if ( a.distanceToSquared( b ) > threshold ) {

return 'Vector differs at index ' + i;
return 'Vector differs at index ' + i +
'. Should be ' + [ a.x, a.y, a.z ] +
' instead of ' + [ b.x, b.y, b.z ];
}
}

Expand Down Expand Up @@ -45,7 +52,7 @@ test( "basic check", function() {

var getPoints = closedSpline.getPoints(10);
var error = vectorsAreEqual( getPoints , closedSplinePoints );
ok( getPoints.length == 11, 'getPoints are equal.' + error );
ok( !error, 'Points are equal.' + error );
ok( getPoints.length == 11, 'getPoints should be equal.');
ok( !error, 'Lists of Vectors3 should be equal.' + error );

});

0 comments on commit da61251

Please sign in to comment.