dwf/rva: exception handling should now work in most cases.
This commit is contained in:
parent
c94496c9fe
commit
145a2253e8
|
@ -92,7 +92,7 @@
|
|||
<file leaf-file-name="bootstrap.js" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="893" column="101" selection-start="27681" selection-end="27681" vertical-scroll-proportion="0.6620553">
|
||||
<state line="861" column="1" selection-start="26398" selection-end="26398" vertical-scroll-proportion="0.6571146">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -101,7 +101,7 @@
|
|||
<file leaf-file-name="jasmine.js" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="246" column="7" selection-start="5573" selection-end="5573" vertical-scroll-proportion="0.4935065">
|
||||
<state line="265" column="7" selection-start="5960" selection-end="5960" vertical-scroll-proportion="0.13286713">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
@ -548,14 +548,14 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/test/bootstrap.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="893" column="101" selection-start="27681" selection-end="27681" vertical-scroll-proportion="0.6620553">
|
||||
<state line="861" column="1" selection-start="26398" selection-end="26398" vertical-scroll-proportion="0.6571146">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/lib/jasmine.js">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="246" column="7" selection-start="5573" selection-end="5573" vertical-scroll-proportion="0.4935065">
|
||||
<state line="265" column="7" selection-start="5960" selection-end="5960" vertical-scroll-proportion="0.13286713">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
|
|
@ -133,14 +133,22 @@ var queuedFunction = function(func, timeout, spec) {
|
|||
next: function () {
|
||||
spec.finish(); // default value is to be done after one function
|
||||
},
|
||||
safeExecute: function () {
|
||||
try {
|
||||
that.func.apply(spec);
|
||||
}
|
||||
catch (e) {
|
||||
spec.results.push({passed:false, message: Jasmine.Util.formatException(e)});
|
||||
}
|
||||
},
|
||||
execute: function () {
|
||||
if (timeout > 0) {
|
||||
setTimeout(function () {
|
||||
that.func.apply(spec);
|
||||
that.safeExecute();
|
||||
that.next();
|
||||
}, timeout);
|
||||
} else {
|
||||
that.func.apply(spec);
|
||||
that.safeExecute();
|
||||
that.next();
|
||||
}
|
||||
}
|
||||
|
@ -252,22 +260,9 @@ var it = function (description, func) {
|
|||
that.finished = true;
|
||||
},
|
||||
|
||||
safeExecute: function(queuedFunc) {
|
||||
try {
|
||||
queuedFunc.execute();
|
||||
}
|
||||
catch (e) {
|
||||
that.results.push({
|
||||
passed: false,
|
||||
message: Jasmine.Util.formatException(e)
|
||||
});
|
||||
queuedFunc.next();
|
||||
}
|
||||
},
|
||||
|
||||
execute: function () {
|
||||
if (that.queue[0]) {
|
||||
that.safeExecute(that.queue[0])
|
||||
that.queue[0].execute();
|
||||
}
|
||||
else {
|
||||
that.finish();
|
||||
|
@ -282,7 +277,7 @@ var it = function (description, func) {
|
|||
if (that.queue.length > 1) {
|
||||
var previousFunction = that.queue[that.queue.length - 2];
|
||||
previousFunction.next = function () {
|
||||
that.safeExecute(currentFunction);
|
||||
currentFunction.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,32 +390,32 @@ Jasmine.Reporters.reporter = function (callbacks) {
|
|||
|
||||
Jasmine.Util = {
|
||||
formatException: function(e) {
|
||||
// if (typeof e === 'String') {
|
||||
// return e;
|
||||
// }
|
||||
var lineNumber;
|
||||
if (e.line) {
|
||||
lineNumber = e.line;
|
||||
}
|
||||
else if (e.lineNumber) {
|
||||
lineNumber = e.lineNumber;
|
||||
}
|
||||
// if (typeof e === 'String') {
|
||||
// return e;
|
||||
// }
|
||||
var lineNumber;
|
||||
if (e.line) {
|
||||
lineNumber = e.line;
|
||||
}
|
||||
else if (e.lineNumber) {
|
||||
lineNumber = e.lineNumber;
|
||||
}
|
||||
|
||||
var file;
|
||||
var file;
|
||||
|
||||
if (e.sourceURL) {
|
||||
file = e.sourceURL;
|
||||
}
|
||||
else if (e.fileName) {
|
||||
file = e.fileName;
|
||||
}
|
||||
if (e.sourceURL) {
|
||||
file = e.sourceURL;
|
||||
}
|
||||
else if (e.fileName) {
|
||||
file = e.fileName;
|
||||
}
|
||||
|
||||
var message = e.name + ': ' + e.message;
|
||||
if (file && lineNumber) {
|
||||
message += ' in ' + file +' (line ' + lineNumber + ')';
|
||||
}
|
||||
var message = e.name + ': ' + e.message;
|
||||
if (file && lineNumber) {
|
||||
message += ' in ' + file + ' (line ' + lineNumber + ')';
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -858,29 +858,29 @@ var testHandlesExceptions = function () {
|
|||
});
|
||||
});
|
||||
|
||||
// it('should be another test that fails because it throws an exception after a wait', function() {
|
||||
// runs(function () {
|
||||
// var foo = 'foo';
|
||||
// });
|
||||
// waits(250);
|
||||
// runs(function () {
|
||||
// fakeObject2.fakeMethod2();
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
||||
// runs(function () {
|
||||
// this.expects_that(true).should_equal(true);
|
||||
// });
|
||||
// });
|
||||
it('should be another test that fails because it throws an exception after a wait', function() {
|
||||
runs(function () {
|
||||
var foo = 'foo';
|
||||
});
|
||||
waits(250);
|
||||
runs(function () {
|
||||
fakeObject3.fakeMethod();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
||||
runs(function () {
|
||||
this.expects_that(true).should_equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
runner.execute();
|
||||
|
||||
setTimeout(function() {
|
||||
reporter.test((runner.suites[0].specResults.length === 3),
|
||||
'Should have found 3 spec results, got ' + runner.suites[0].specResults.length);
|
||||
reporter.test((runner.suites[0].specResults.length === 5),
|
||||
'Should have found 4 spec results, got ' + runner.suites[0].specResults.length);
|
||||
|
||||
reporter.test((runner.suites[0].specs[0].expectationResults[0].passed === false),
|
||||
'First test should have failed, got passed');
|
||||
|
@ -892,13 +892,19 @@ var testHandlesExceptions = function () {
|
|||
'Second test should have a failing first result, got passed');
|
||||
|
||||
reporter.test((typeof runner.suites[0].specs[1].expectationResults[0].message.search(/fakeObject2/) !== -1),
|
||||
'First test should have contained /fakeObject/, got ' + runner.suites[0].specs[1].expectationResults[0].message);
|
||||
'Second test should have contained /fakeObject2/, got ' + runner.suites[0].specs[1].expectationResults[0].message);
|
||||
|
||||
reporter.test((runner.suites[0].specs[1].expectationResults[1].passed === true),
|
||||
'Second expectation in second test should have still passed');
|
||||
|
||||
reporter.test((runner.suites[0].specs[2].expectationResults[0].passed === true),
|
||||
'Third test should have passed, got failed');
|
||||
|
||||
reporter.test((runner.suites[0].specs[3].expectationResults[0].passed === false),
|
||||
'Fourth test should have a failing first result, got passed');
|
||||
|
||||
reporter.test((typeof runner.suites[0].specs[3].expectationResults[0].message.search(/fakeObject3/) !== -1),
|
||||
'Fourth test should have contained /fakeObject3/, got ' + runner.suites[0].specs[3].expectationResults[0].message);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue