Browse Source

property check of special geometry agains simple geometry cant use smartcomparer since there are some properties which are missing. Since this is a normal behavior these properties need to be excluded manually

simonThiele 9 years ago
parent
commit
f12d370be3
2 changed files with 31 additions and 2 deletions
  1. 1 1
      test/unit/extras/geometries/BoxGeometry.tests.js
  2. 30 1
      test/unit/qunit-utils.js

+ 1 - 1
test/unit/extras/geometries/BoxGeometry.tests.js

@@ -21,7 +21,7 @@
 			box = new THREE.BoxGeometry( parameters.width, parameters.height, parameters.depth );
 			cube = new THREE.CubeGeometry( parameters.width, parameters.height, parameters.depth );
 			boxWithSegments = new THREE.BoxGeometry( parameters.width, parameters.height, parameters.depth,
-													 parameters.widthSegments, parameters.heightSegments, parameters.depthSegments );
+													parameters.widthSegments, parameters.heightSegments, parameters.depthSegments );
 
 			geometries = [ box, cube, boxWithSegments ];
 

+ 30 - 1
test/unit/qunit-utils.js

@@ -56,14 +56,43 @@ function checkGeometryClone( geom ) {
 	var copy = geom.clone();
 	QUnit.assert.notEqual( copy.uuid, geom.uuid, "clone uuid should differ from original" );
 	QUnit.assert.notEqual( copy.id, geom.id, "clone id should differ from original" );
-	QUnit.assert.smartEqual( copy, geom, "clone is equal to original" );
 
+	var excludedProperties = [ 'parameters', 'widthSegments', 'heightSegments', 'depthSegments' ];
+	var differingProp = getDifferingProp( geom, copy, excludedProperties );
+	var differingProp = getDifferingProp( copy, geom, excludedProperties );
+
+	ok( differingProp === undefined, 'properties are equal' );
 
 	// json round trip with clone
 	checkGeometryJsonRoundtrip( copy );
 
 }
 
+function getDifferingProp( geometryA, geometryB, excludedProperties ) {
+	var geometryKeys = Object.keys( geometryA );
+	var cloneKeys = Object.keys( geometryB );
+
+	var keysWhichAreNotChecked = [ 'parameters', 'widthSegments', 'heightSegments', 'depthSegments' ];
+	var differingProp = undefined;
+
+	for ( var i = 0, l = geometryKeys.length; i < l; i++ ) {
+
+		var key = geometryKeys[ i ];
+
+		if ( excludedProperties.indexOf(key) >= 0 ) {
+			continue;
+		}
+
+		if ( cloneKeys.indexOf( key ) < 0 ) {
+			differingProp = key;
+			break;
+		}
+
+	}
+
+	return differingProp;
+}
+
 // Compare json file with its source geometry.
 function checkGeometryJsonWriting( geom, json ) {