Added toBeNaN matcher
This commit is contained in:
@@ -1293,6 +1293,17 @@ jasmine.Matchers.prototype.toBeNull = function() {
|
||||
return (this.actual === null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to NaN.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeNaN = function() {
|
||||
this.message = function() {
|
||||
return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
|
||||
};
|
||||
|
||||
return (this.actual !== this.actual);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that boolean not-nots the actual.
|
||||
*/
|
||||
|
||||
@@ -281,6 +281,29 @@ describe("jasmine.Matchers", function() {
|
||||
expect(result.actual).toEqual(actual);
|
||||
});
|
||||
|
||||
it("toBeNaN", function() {
|
||||
expect(match(Number.NaN).toBeNaN()).toPass();
|
||||
expect(match(0).toBeNaN()).toFail();
|
||||
expect(match(1).toBeNaN()).toFail();
|
||||
expect(match(null).toBeNaN()).toFail();
|
||||
expect(match(Number.POSITIVE_INFINITY).toBeNaN()).toFail();
|
||||
expect(match(Number.NEGATIVE_INFINITY).toBeNaN()).toFail();
|
||||
expect(match('NaN').toBeNaN()).toFail();
|
||||
});
|
||||
|
||||
it("toBeNaN to build an ExpectationResult", function() {
|
||||
var actual = 'a';
|
||||
var matcher = match(actual);
|
||||
matcher.toBeNaN();
|
||||
|
||||
var result = lastResult();
|
||||
|
||||
expect(result.matcherName).toEqual("toBeNaN");
|
||||
expect(result.passed()).toFail();
|
||||
expect(result.message).toMatch("Expected 'a' to be NaN.");
|
||||
expect(result.actual).toMatch(actual);
|
||||
});
|
||||
|
||||
it("toBeFalsy", function() {
|
||||
expect(match(false).toBeFalsy()).toPass();
|
||||
expect(match(true).toBeFalsy()).toFail();
|
||||
|
||||
@@ -150,6 +150,17 @@ jasmine.Matchers.prototype.toBeNull = function() {
|
||||
return (this.actual === null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that compares the actual to NaN.
|
||||
*/
|
||||
jasmine.Matchers.prototype.toBeNaN = function() {
|
||||
this.message = function() {
|
||||
return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
|
||||
};
|
||||
|
||||
return (this.actual !== this.actual);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that boolean not-nots the actual.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user