Evaluate custom equality testers before any others.

This commit is contained in:
Christian Williams
2010-03-08 21:56:04 -08:00
parent e9a2b0dcdb
commit 9830952461
2 changed files with 79 additions and 6 deletions

View File

@@ -181,6 +181,12 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
for (var i = 0; i < this.equalityTesters_.length; i++) {
var equalityTester = this.equalityTesters_[i];
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
if (result !== jasmine.undefined) return result;
}
if (a === b) return true;
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
@@ -207,12 +213,6 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
}
for (var i = 0; i < this.equalityTesters_.length; i++) {
var equalityTester = this.equalityTesters_[i];
var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
if (result !== jasmine.undefined) return result;
}
//Straight check
return (a === b);
};