зеркало из https://github.com/mozilla/gecko-dev.git
Added a unit test for async exceptions.
This commit is contained in:
Родитель
2d0e404b20
Коммит
1a2855c05b
|
@ -0,0 +1,47 @@
|
|||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/async.js");
|
||||
|
||||
Function.prototype.async = Async.sugar;
|
||||
|
||||
function thirdGen() {
|
||||
let self = yield;
|
||||
|
||||
Utils.makeTimerForCall(self.cb);
|
||||
yield;
|
||||
|
||||
throw new Error("intentional failure");
|
||||
}
|
||||
|
||||
function secondGen() {
|
||||
let self = yield;
|
||||
|
||||
thirdGen.async({}, self.cb);
|
||||
try {
|
||||
let result = yield;
|
||||
} catch (e) {
|
||||
do_check_eq(e.message, "Error: intentional failure");
|
||||
throw e;
|
||||
}
|
||||
|
||||
self.done();
|
||||
}
|
||||
|
||||
function runTestGenerator() {
|
||||
let self = yield;
|
||||
|
||||
secondGen.async({}, self.cb);
|
||||
let wasCaught = false;
|
||||
try {
|
||||
let result = yield;
|
||||
} catch (e) {
|
||||
do_check_eq(e.message, "Error: intentional failure");
|
||||
wasCaught = true;
|
||||
}
|
||||
|
||||
do_check_true(wasCaught);
|
||||
self.done();
|
||||
}
|
||||
|
||||
var run_test = makeAsyncTestRunner(runTestGenerator);
|
Загрузка…
Ссылка в новой задаче