Merge branch 'issue-1294' of https://github.com/toubou91/jasmine into toubou91-issue-1294
- Merges #1300 from @toubou91 - Fixes #1294
This commit is contained in:
@@ -97,18 +97,20 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|||||||
'toBeFalsy',
|
'toBeFalsy',
|
||||||
'toBeGreaterThan',
|
'toBeGreaterThan',
|
||||||
'toBeGreaterThanOrEqual',
|
'toBeGreaterThanOrEqual',
|
||||||
'toBeLessThanOrEqual',
|
|
||||||
'toBeLessThan',
|
'toBeLessThan',
|
||||||
|
'toBeLessThanOrEqual',
|
||||||
'toBeNaN',
|
'toBeNaN',
|
||||||
|
'toBeNegativeInfinity',
|
||||||
'toBeNull',
|
'toBeNull',
|
||||||
|
'toBePositiveInfinity',
|
||||||
'toBeTruthy',
|
'toBeTruthy',
|
||||||
'toBeUndefined',
|
'toBeUndefined',
|
||||||
'toContain',
|
'toContain',
|
||||||
'toEqual',
|
'toEqual',
|
||||||
'toHaveBeenCalled',
|
'toHaveBeenCalled',
|
||||||
'toHaveBeenCalledBefore',
|
'toHaveBeenCalledBefore',
|
||||||
'toHaveBeenCalledWith',
|
|
||||||
'toHaveBeenCalledTimes',
|
'toHaveBeenCalledTimes',
|
||||||
|
'toHaveBeenCalledWith',
|
||||||
'toMatch',
|
'toMatch',
|
||||||
'toThrow',
|
'toThrow',
|
||||||
'toThrowError'
|
'toThrowError'
|
||||||
@@ -2894,6 +2896,35 @@ getJasmineRequireObj().toBeNaN = function(j$) {
|
|||||||
return toBeNaN;
|
return toBeNaN;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
getJasmineRequireObj().toBeNull = function() {
|
getJasmineRequireObj().toBeNull = function() {
|
||||||
/**
|
/**
|
||||||
* {@link expect} the actual value to be `null`.
|
* {@link expect} the actual value to be `null`.
|
||||||
@@ -2915,6 +2946,35 @@ getJasmineRequireObj().toBeNull = function() {
|
|||||||
return toBeNull;
|
return toBeNull;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
getJasmineRequireObj().toBeTruthy = function() {
|
getJasmineRequireObj().toBeTruthy = function() {
|
||||||
/**
|
/**
|
||||||
* {@link expect} the actual value to be truthy.
|
* {@link expect} the actual value to be truthy.
|
||||||
|
|||||||
31
spec/core/matchers/toBeNegativeInfinitySpec.js
Normal file
31
spec/core/matchers/toBeNegativeInfinitySpec.js
Normal file
@@ -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.")
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
31
spec/core/matchers/toBePositiveInfinitySpec.js
Normal file
31
spec/core/matchers/toBePositiveInfinitySpec.js
Normal file
@@ -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.")
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@@ -6,18 +6,20 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
|||||||
'toBeFalsy',
|
'toBeFalsy',
|
||||||
'toBeGreaterThan',
|
'toBeGreaterThan',
|
||||||
'toBeGreaterThanOrEqual',
|
'toBeGreaterThanOrEqual',
|
||||||
'toBeLessThanOrEqual',
|
|
||||||
'toBeLessThan',
|
'toBeLessThan',
|
||||||
|
'toBeLessThanOrEqual',
|
||||||
'toBeNaN',
|
'toBeNaN',
|
||||||
|
'toBeNegativeInfinity',
|
||||||
'toBeNull',
|
'toBeNull',
|
||||||
|
'toBePositiveInfinity',
|
||||||
'toBeTruthy',
|
'toBeTruthy',
|
||||||
'toBeUndefined',
|
'toBeUndefined',
|
||||||
'toContain',
|
'toContain',
|
||||||
'toEqual',
|
'toEqual',
|
||||||
'toHaveBeenCalled',
|
'toHaveBeenCalled',
|
||||||
'toHaveBeenCalledBefore',
|
'toHaveBeenCalledBefore',
|
||||||
'toHaveBeenCalledWith',
|
|
||||||
'toHaveBeenCalledTimes',
|
'toHaveBeenCalledTimes',
|
||||||
|
'toHaveBeenCalledWith',
|
||||||
'toMatch',
|
'toMatch',
|
||||||
'toThrow',
|
'toThrow',
|
||||||
'toThrowError'
|
'toThrowError'
|
||||||
|
|||||||
28
src/core/matchers/toBeNegativeInfinity.js
Normal file
28
src/core/matchers/toBeNegativeInfinity.js
Normal file
@@ -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;
|
||||||
|
};
|
||||||
28
src/core/matchers/toBePositiveInfinity.js
Normal file
28
src/core/matchers/toBePositiveInfinity.js
Normal file
@@ -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;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user