Use jasmine.undefined for all comparisons to the undefined value, since undefined itself may be redefined elsewhere
in app code. Thanks to Charlie Meyer at UIUC for the suggestion.
This commit is contained in:
@@ -113,17 +113,17 @@ jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeDefined = function() {
|
||||
return (this.actual !== undefined);
|
||||
return (this.actual !== jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to undefined.
|
||||
* Matcher that compares the actual to jasmine.undefined.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeUndefined = function() {
|
||||
return (this.actual === undefined);
|
||||
return (this.actual === jasmine.undefined);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -252,12 +252,12 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
|
||||
var result = false;
|
||||
var exception = getException_(this.actual, expected);
|
||||
if (exception) {
|
||||
result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||
}
|
||||
|
||||
this.message = function(expected) {
|
||||
var exception = getException_(this.actual, expected);
|
||||
if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
|
||||
} else {
|
||||
return "Expected function to throw an exception.";
|
||||
|
||||
Reference in New Issue
Block a user