Removed unnecessary errorWithStack helper
This commit is contained in:
@@ -721,16 +721,9 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.errorWithStack = function errorWithStack() {
|
|
||||||
// Don't throw and catch. That makes it harder for users to debug their
|
|
||||||
// code with exception breakpoints, and it's unnecessary since all
|
|
||||||
// supported environments populate new Error().stack
|
|
||||||
return new Error();
|
|
||||||
};
|
|
||||||
|
|
||||||
function callerFile() {
|
function callerFile() {
|
||||||
const trace = new j$.StackTrace(util.errorWithStack());
|
const trace = new j$.StackTrace(new Error());
|
||||||
return trace.frames[2].file;
|
return trace.frames[1].file;
|
||||||
}
|
}
|
||||||
|
|
||||||
util.jasmineFile = (function() {
|
util.jasmineFile = (function() {
|
||||||
@@ -3724,7 +3717,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
|
|||||||
|
|
||||||
Deprecator.prototype.stackTrace_ = function() {
|
Deprecator.prototype.stackTrace_ = function() {
|
||||||
const formatter = new j$.ExceptionFormatter();
|
const formatter = new j$.ExceptionFormatter();
|
||||||
return formatter.stack(j$.util.errorWithStack()).replace(/^Error\n/m, '');
|
return formatter.stack(new Error()).replace(/^Error\n/m, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
Deprecator.prototype.report_ = function(runnable, deprecation, options) {
|
Deprecator.prototype.report_ = function(runnable, deprecation, options) {
|
||||||
@@ -4034,7 +4027,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
return function() {
|
return function() {
|
||||||
// Capture the call stack here, before we go async, so that it will contain
|
// Capture the call stack here, before we go async, so that it will contain
|
||||||
// frames that are relevant to the user instead of just parts of Jasmine.
|
// frames that are relevant to the user instead of just parts of Jasmine.
|
||||||
const errorForStack = j$.util.errorWithStack();
|
const errorForStack = new Error();
|
||||||
|
|
||||||
return this.expector
|
return this.expector
|
||||||
.compare(name, matcherFactory, arguments)
|
.compare(name, matcherFactory, arguments)
|
||||||
|
|||||||
@@ -284,16 +284,11 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
matchersUtil = {
|
const matchersUtil = {
|
||||||
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -310,7 +305,7 @@ describe('AsyncExpectation', function() {
|
|||||||
error: undefined,
|
error: undefined,
|
||||||
expected: 'hello',
|
expected: 'hello',
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -329,13 +324,8 @@ describe('AsyncExpectation', function() {
|
|||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -352,7 +342,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
message: '',
|
message: '',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -369,13 +359,8 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -391,7 +376,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -410,13 +395,8 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -432,7 +412,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -446,14 +426,9 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = 'an actual',
|
const actual = 'an actual';
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -469,7 +444,7 @@ describe('AsyncExpectation', function() {
|
|||||||
error: undefined,
|
error: undefined,
|
||||||
expected: 'hello',
|
expected: 'hello',
|
||||||
actual: actual,
|
actual: actual,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -488,14 +463,9 @@ describe('AsyncExpectation', function() {
|
|||||||
buildFailureMessage: function() {
|
buildFailureMessage: function() {
|
||||||
return 'default message';
|
return 'default message';
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = 'an actual',
|
const actual = 'an actual';
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -512,7 +482,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: actual,
|
actual: actual,
|
||||||
message: 'default message',
|
message: 'default message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -529,14 +499,9 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = 'an actual',
|
const actual = 'an actual';
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -552,7 +517,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: actual,
|
actual: actual,
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -569,14 +534,9 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = 'an actual',
|
const actual = 'an actual';
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -592,7 +552,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: actual,
|
actual: actual,
|
||||||
message: '',
|
message: '',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -612,14 +572,9 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
actual = 'an actual',
|
const actual = 'an actual';
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
customAsyncMatchers: matchers,
|
customAsyncMatchers: matchers,
|
||||||
@@ -635,7 +590,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: actual,
|
actual: actual,
|
||||||
message: "I'm a custom message",
|
message: "I'm a custom message",
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -654,13 +609,8 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -676,7 +626,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -693,13 +643,8 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
const expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -715,7 +660,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -734,13 +679,8 @@ describe('AsyncExpectation', function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
addExpectationResult = jasmine.createSpy('addExpectationResult'),
|
const addExpectationResult = jasmine.createSpy('addExpectationResult');
|
||||||
errorWithStack = new Error('errorWithStack');
|
|
||||||
|
|
||||||
spyOn(jasmineUnderTest.util, 'errorWithStack').and.returnValue(
|
|
||||||
errorWithStack
|
|
||||||
);
|
|
||||||
|
|
||||||
let expectation = jasmineUnderTest.Expectation.asyncFactory({
|
let expectation = jasmineUnderTest.Expectation.asyncFactory({
|
||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
@@ -756,7 +696,7 @@ describe('AsyncExpectation', function() {
|
|||||||
actual: 'an actual',
|
actual: 'an actual',
|
||||||
message: 'I am a custom message',
|
message: 'I am a custom message',
|
||||||
error: undefined,
|
error: undefined,
|
||||||
errorForStack: errorWithStack
|
errorForStack: jasmine.any(Error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1524,7 +1524,7 @@ describe('Env integration', function() {
|
|||||||
env = new jasmineUnderTest.Env({
|
env = new jasmineUnderTest.Env({
|
||||||
global: {
|
global: {
|
||||||
setTimeout: function(cb, t) {
|
setTimeout: function(cb, t) {
|
||||||
const stack = jasmine.util.errorWithStack().stack;
|
const stack = new Error().stack;
|
||||||
if (stack.indexOf('ClearStack') >= 0) {
|
if (stack.indexOf('ClearStack') >= 0) {
|
||||||
return realSetTimeout(cb, t);
|
return realSetTimeout(cb, t);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ getJasmineRequireObj().Deprecator = function(j$) {
|
|||||||
|
|
||||||
Deprecator.prototype.stackTrace_ = function() {
|
Deprecator.prototype.stackTrace_ = function() {
|
||||||
const formatter = new j$.ExceptionFormatter();
|
const formatter = new j$.ExceptionFormatter();
|
||||||
return formatter.stack(j$.util.errorWithStack()).replace(/^Error\n/m, '');
|
return formatter.stack(new Error()).replace(/^Error\n/m, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
Deprecator.prototype.report_ = function(runnable, deprecation, options) {
|
Deprecator.prototype.report_ = function(runnable, deprecation, options) {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ getJasmineRequireObj().Expectation = function(j$) {
|
|||||||
return function() {
|
return function() {
|
||||||
// Capture the call stack here, before we go async, so that it will contain
|
// Capture the call stack here, before we go async, so that it will contain
|
||||||
// frames that are relevant to the user instead of just parts of Jasmine.
|
// frames that are relevant to the user instead of just parts of Jasmine.
|
||||||
const errorForStack = j$.util.errorWithStack();
|
const errorForStack = new Error();
|
||||||
|
|
||||||
return this.expector
|
return this.expector
|
||||||
.compare(name, matcherFactory, arguments)
|
.compare(name, matcherFactory, arguments)
|
||||||
|
|||||||
@@ -48,16 +48,9 @@ getJasmineRequireObj().util = function(j$) {
|
|||||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.errorWithStack = function errorWithStack() {
|
|
||||||
// Don't throw and catch. That makes it harder for users to debug their
|
|
||||||
// code with exception breakpoints, and it's unnecessary since all
|
|
||||||
// supported environments populate new Error().stack
|
|
||||||
return new Error();
|
|
||||||
};
|
|
||||||
|
|
||||||
function callerFile() {
|
function callerFile() {
|
||||||
const trace = new j$.StackTrace(util.errorWithStack());
|
const trace = new j$.StackTrace(new Error());
|
||||||
return trace.frames[2].file;
|
return trace.frames[1].file;
|
||||||
}
|
}
|
||||||
|
|
||||||
util.jasmineFile = (function() {
|
util.jasmineFile = (function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user