Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issue-1294' of https://github.com/toubou91/jasmine into…
- Loading branch information
Showing
6 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe("toBeNegativeInfinity", function() { | ||
it("fails for anything that isn't -Infinity", function() { | ||
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), | ||
result; | ||
|
||
result = matcher.compare(1); | ||
expect(result.pass).toBe(false); | ||
|
||
result = matcher.compare(Number.NaN); | ||
expect(result.pass).toBe(false); | ||
|
||
result = matcher.compare(null); | ||
expect(result.pass).toBe(false); | ||
}); | ||
|
||
it("has a custom message on failure", function() { | ||
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), | ||
result = matcher.compare(0); | ||
|
||
expect(result.message()).toEqual("Expected 0 not to be -Infinity.") | ||
}); | ||
|
||
it("succeeds for -Infinity", function() { | ||
var matcher = jasmineUnderTest.matchers.toBeNegativeInfinity(), | ||
result = matcher.compare(Number.NEGATIVE_INFINITY); | ||
|
||
expect(result.pass).toBe(true); | ||
expect(result.message).toEqual("Expected actual to be -Infinity.") | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe("toBePositiveInfinity", function() { | ||
it("fails for anything that isn't Infinity", function() { | ||
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), | ||
result; | ||
|
||
result = matcher.compare(1); | ||
expect(result.pass).toBe(false); | ||
|
||
result = matcher.compare(Number.NaN); | ||
expect(result.pass).toBe(false); | ||
|
||
result = matcher.compare(null); | ||
expect(result.pass).toBe(false); | ||
}); | ||
|
||
it("has a custom message on failure", function() { | ||
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), | ||
result = matcher.compare(0); | ||
|
||
expect(result.message()).toEqual("Expected 0 not to be Infinity.") | ||
}); | ||
|
||
it("succeeds for Infinity", function() { | ||
var matcher = jasmineUnderTest.matchers.toBePositiveInfinity(), | ||
result = matcher.compare(Number.POSITIVE_INFINITY); | ||
|
||
expect(result.pass).toBe(true); | ||
expect(result.message).toEqual("Expected actual to be Infinity.") | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
getJasmineRequireObj().toBeNegativeInfinity = function(j$) { | ||
/** | ||
* {@link expect} the actual value to be `-Infinity` (-infinity). | ||
* @function | ||
* @name matchers#toBeNegativeInfinity | ||
* @example | ||
* expect(thing).toBeNegativeInfinity(); | ||
*/ | ||
function toBeNegativeInfinity() { | ||
return { | ||
compare: function(actual) { | ||
var result = { | ||
pass: (actual === Number.NEGATIVE_INFINITY) | ||
}; | ||
|
||
if (result.pass) { | ||
result.message = 'Expected actual to be -Infinity.'; | ||
} else { | ||
result.message = function() { return 'Expected ' + j$.pp(actual) + ' not to be -Infinity.'; }; | ||
} | ||
|
||
return result; | ||
} | ||
}; | ||
} | ||
|
||
return toBeNegativeInfinity; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
getJasmineRequireObj().toBePositiveInfinity = function(j$) { | ||
/** | ||
* {@link expect} the actual value to be `Infinity` (infinity). | ||
* @function | ||
* @name matchers#toBePositiveInfinity | ||
* @example | ||
* expect(thing).toBePositiveInfinity(); | ||
*/ | ||
function toBePositiveInfinity() { | ||
return { | ||
compare: function(actual) { | ||
var result = { | ||
pass: (actual === Number.POSITIVE_INFINITY) | ||
}; | ||
|
||
if (result.pass) { | ||
result.message = 'Expected actual to be Infinity.'; | ||
} else { | ||
result.message = function() { return 'Expected ' + j$.pp(actual) + ' not to be Infinity.'; }; | ||
} | ||
|
||
return result; | ||
} | ||
}; | ||
} | ||
|
||
return toBePositiveInfinity; | ||
}; |