瀏覽代碼

Make vectorsAreEqual() tests slightly fuzzy

Joshua Koo 9 年之前
父節點
當前提交
da612518c6
共有 1 個文件被更改,包括 11 次插入4 次删除
  1. 11 4
      test/unit/extras/curves/ClosedSplineCurve3.js

+ 11 - 4
test/unit/extras/curves/ClosedSplineCurve3.js

@@ -4,15 +4,22 @@
 
 
 module( "ClosedSplineCurve3" );
 module( "ClosedSplineCurve3" );
 
 
+var threshold = 0.000001;
+
 function vectorsAreEqual( check, that ) {
 function vectorsAreEqual( check, that ) {
 
 
 	if ( check.length !== that.length ) return 'Length not equal';
 	if ( check.length !== that.length ) return 'Length not equal';
 
 
 	for ( var i = 0; i < check.length; i ++ ) {
 	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 ];
 		}
 		}
 	}
 	}
 
 
@@ -45,7 +52,7 @@ test( "basic check", function() {
 
 
 	var getPoints = closedSpline.getPoints(10);
 	var getPoints = closedSpline.getPoints(10);
 	var error = vectorsAreEqual( getPoints , closedSplinePoints );
 	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 );
 
 
 });
 });