use jasmineMatches for equality testing of complicated matchers

This commit is contained in:
gvanhove
2011-03-15 08:23:38 -07:00
parent 4f2fcff15a
commit 67ec0af254
4 changed files with 154 additions and 6 deletions

View File

@@ -230,12 +230,12 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return a.getTime() == b.getTime();
}
if (a instanceof jasmine.Matchers.Any) {
return a.matches(b);
if (a.jasmineMatches) {
return a.jasmineMatches(b);
}
if (b instanceof jasmine.Matchers.Any) {
return b.matches(a);
if (b.jasmineMatches) {
return b.jasmineMatches(a);
}
if (a instanceof jasmine.Matchers.ObjectContaining) {

View File

@@ -345,7 +345,7 @@ jasmine.Matchers.Any = function(expectedClass) {
this.expectedClass = expectedClass;
};
jasmine.Matchers.Any.prototype.matches = function(other) {
jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
if (this.expectedClass == String) {
return typeof other == 'string' || other instanceof String;
}

View File

@@ -23,7 +23,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
this.emitScalar('null');
} else if (value === jasmine.getGlobal()) {
this.emitScalar('<global>');
} else if (value.hasOwnProperty("jasmineToString")) {
} else if (value.jasmineToString) {
this.emitScalar(value.jasmineToString());
} else if (typeof value === 'string') {
this.emitString(value);