Ticket #3510: testrunner.js.patch
File testrunner.js.patch, 2.3 KB (added by , 12 years ago) 


testrunner.js
399 399 var args = Array.prototype.slice.apply(arguments); 400 400 var eq = true; // equivalent until we can explicitely say it's not! 401 401 var a, b; // compares a and b (1st and 2nd argument) 402 var len; // for iterating array's length memoization402 var i, len; // for iterating over objects convenience and for iterating array's length memoization 403 403 404 404 if (args.length < 2) { 405 405 return true; // nothing to compare together … … 428 428 if (len !== b.length) { // safe and faster 429 429 return false; 430 430 } 431 for ( var i = 0; i < len; i++) {432 eq = eq && equiv(a[i], b[i]);431 for (i = 0; i < len && eq; i++) { 432 eq = equiv(a[i], b[i]); 433 433 } 434 434 return eq; 435 435 } … … 443 443 } 444 444 445 445 if (typeof a === "object") { 446 // Verify properties equivalence in both ways: 447 448 // Everything in a should be in b and equivalent and ... 449 for (var i in a) { 450 if (a.hasOwnProperty(i)) { 451 eq = eq && equiv(a[i], b[i]); 452 } 453 } 454 455 // ... everything in b should be in a and equivalent 456 for (var i in b) { 457 if (b.hasOwnProperty(i)) { 458 eq = eq && equiv(b[i], a[i]); 459 } 460 } 461 462 return eq; 446 // With Markus Staab's help 447 // see http://groups.google.com/group/jquerydev/browse_thread/thread/9447a950b40574f 448 449 // Verify a's properties with b's properties equivalence 450 for (i in a) { 451 if (a.hasOwnProperty(i)) { 452 if (!b.hasOwnProperty(i)  !equiv(a[i], b[i])) { 453 return false; 454 } 455 } 456 } 457 458 // Need only to verify that b's property are also a's property 459 for (i in b) { 460 if (b.hasOwnProperty(i) && !a.hasOwnProperty(i)) { 461 return false; 462 } 463 } 464 465 return true; 463 466 } 464 467 465 468 if (typeof a === "function") {