removing the exception formatter from the util namespace
This commit is contained in:
@@ -439,7 +439,19 @@ jasmine.util.argsToArray = function(args) {
|
||||
var arrayOfArgs = [];
|
||||
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
|
||||
return arrayOfArgs;
|
||||
};//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||
};jasmine.exceptionMessageFor = function(e) {
|
||||
var message = e.name
|
||||
+ ': '
|
||||
+ e.message
|
||||
+ ' in '
|
||||
+ (e.fileName || e.sourceURL || '')
|
||||
+ ' (line '
|
||||
+ (e.line || e.lineNumber || '')
|
||||
+ ')';
|
||||
|
||||
return message;
|
||||
};
|
||||
//TODO: expectation result may make more sense as a presentation of an expectation.
|
||||
jasmine.buildExpectationResult = function(params) {
|
||||
return {
|
||||
type: 'expect',
|
||||
@@ -527,7 +539,7 @@ jasmine.buildExpectationResult = function(params) {
|
||||
}
|
||||
};
|
||||
|
||||
var exceptionFormatter = jasmine.util.formatException;
|
||||
var exceptionFormatter = jasmine.exceptionMessageFor;
|
||||
|
||||
var specConstructor = jasmine.Spec;
|
||||
|
||||
|
||||
1
pages
Submodule
1
pages
Submodule
Submodule pages added at 39dcf87b56
26
spec/core/ExceptionFormatterSpec.js
Normal file
26
spec/core/ExceptionFormatterSpec.js
Normal file
@@ -0,0 +1,26 @@
|
||||
describe("ExceptionFormatter", function() {
|
||||
|
||||
it('formats Firefox exception messages', function() {
|
||||
var sampleFirefoxException = {
|
||||
fileName: 'foo.js',
|
||||
line: '1978',
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
message = jasmine.exceptionMessageFor(sampleFirefoxException);
|
||||
|
||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
|
||||
});
|
||||
|
||||
it('formats Webkit exception messages', function() {
|
||||
var sampleWebkitException = {
|
||||
sourceURL: 'foo.js',
|
||||
lineNumber: '1978',
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
},
|
||||
message = jasmine.exceptionMessageFor(sampleWebkitException);
|
||||
|
||||
expect(message).toEqual('A Classic Mistake: you got your foo in my bar in foo.js (line 1978)');
|
||||
});
|
||||
});
|
||||
@@ -6,32 +6,6 @@ describe('Exceptions:', function() {
|
||||
env.updateInterval = 0;
|
||||
});
|
||||
|
||||
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
||||
var sampleFirefoxException = {
|
||||
fileName: 'foo.js',
|
||||
line: '1978',
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
};
|
||||
|
||||
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
||||
|
||||
expect(jasmine.util.formatException(sampleFirefoxException)).toEqual(expected);
|
||||
});
|
||||
|
||||
it('jasmine.formatException formats Webkit exception messages as expected', function() {
|
||||
var sampleWebkitException = {
|
||||
sourceURL: 'foo.js',
|
||||
lineNumber: '1978',
|
||||
message: 'you got your foo in my bar',
|
||||
name: 'A Classic Mistake'
|
||||
};
|
||||
|
||||
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
||||
|
||||
expect(jasmine.util.formatException(sampleWebkitException)).toEqual(expected);
|
||||
});
|
||||
|
||||
describe('with break on exception', function() {
|
||||
it('should not catch the exception', function() {
|
||||
env.catchExceptions(false);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<script type="text/javascript" src=".././spec/core/CustomMatchersSpec.js"></script>
|
||||
<script type="text/javascript" src=".././spec/core/EnvSpec.js"></script>
|
||||
<script type="text/javascript" src=".././spec/core/ExceptionsSpec.js"></script>
|
||||
<script type="text/javascript" src=".././spec/core/ExceptionFormatterSpec.js"></script>
|
||||
<script type="text/javascript" src=".././spec/core/ExpectationResultSpec.js"></script>
|
||||
<script type="text/javascript" src=".././spec/core/JsApiReporterSpec.js"></script>
|
||||
<script type="text/javascript" src=".././spec/core/MatchersSpec.js"></script>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
var exceptionFormatter = jasmine.util.formatException;
|
||||
var exceptionFormatter = jasmine.exceptionMessageFor;
|
||||
|
||||
var specConstructor = jasmine.Spec;
|
||||
|
||||
|
||||
12
src/core/ExceptionFormatter.js
Normal file
12
src/core/ExceptionFormatter.js
Normal file
@@ -0,0 +1,12 @@
|
||||
jasmine.exceptionMessageFor = function(e) {
|
||||
var message = e.name
|
||||
+ ': '
|
||||
+ e.message
|
||||
+ ' in '
|
||||
+ (e.fileName || e.sourceURL || '')
|
||||
+ ' (line '
|
||||
+ (e.line || e.lineNumber || '')
|
||||
+ ')';
|
||||
|
||||
return message;
|
||||
};
|
||||
@@ -3,6 +3,7 @@ class JasmineDev < Thor
|
||||
:core => [
|
||||
"base.js",
|
||||
"util.js",
|
||||
"ExceptionFormatter.js",
|
||||
"ExpectationResult.js",
|
||||
"Env.js",
|
||||
"Reporter.js",
|
||||
|
||||
Reference in New Issue
Block a user