From bb94648196c68bec55087c4d7f857c13b9435599 Mon Sep 17 00:00:00 2001 From: Thodoris Bais Date: Sun, 19 Mar 2017 01:18:16 +0100 Subject: [PATCH] Added infinity matchers --- lib/jasmine-node/jasmine-1.3.1.js | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/jasmine-node/jasmine-1.3.1.js b/lib/jasmine-node/jasmine-1.3.1.js index 3cb32a8..0e67725 100644 --- a/lib/jasmine-node/jasmine-1.3.1.js +++ b/lib/jasmine-node/jasmine-1.3.1.js @@ -22,6 +22,22 @@ jasmine.unimplementedMethod_ = function() { */ jasmine.undefined = jasmine.___undefined___; +/** + * Use jasmine.POSITIVE_INFINITY instead of Infinity, since Infinity is just + * a plain old variable and may be redefined by somebody else. + * + * @private + */ +jasmine.POSITIVE_INFINITY = Infinity; + +/** + * Use jasmine.NEGATIVE_INFINITY instead of -Infinity, since -Infinity is just + * a plain old variable and may be redefined by somebody else. + * + * @private + */ +jasmine.NEGATIVE_INFINITY = -Infinity; + /** * Show diagnostic messages in the console if set to true * @@ -1414,6 +1430,28 @@ jasmine.Matchers.prototype.toBeNaN = function() { return (this.actual !== this.actual); }; +/** + * Matcher that compares the actual to Infinity. + */ +jasmine.Matchers.prototype.toBePositiveInfinity = function() { + this.message = function() { + return [ "Expected " + jasmine.pp(this.actual) + " to be Infinity." ]; + }; + + return (this.actual === jasmine.POSITIVE_INFINITY); +}; + +/** + * Matcher that compares the actual to -Infinity. + */ +jasmine.Matchers.prototype.toBeNegativeInfinity = function() { + this.message = function() { + return [ "Expected " + jasmine.pp(this.actual) + " to be -Infinity." ]; + }; + + return (this.actual === jasmine.NEGATIVE_INFINITY); +}; + /** * Matcher that boolean not-nots the actual. */