зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1185106 - Part 11.2: Add helper functions for async/await test. r=till
MozReview-Commit-ID: B3lwv5ejz5g
This commit is contained in:
Родитель
5d7377b42e
Коммит
0cfe3ce610
|
@ -0,0 +1,26 @@
|
||||||
|
(function(global) {
|
||||||
|
function getPromiseResult(promise) {
|
||||||
|
var result, error, caught = false;
|
||||||
|
promise.then(r => { result = r; },
|
||||||
|
e => { caught = true; error = e; });
|
||||||
|
drainJobQueue();
|
||||||
|
if (caught)
|
||||||
|
throw error;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertEventuallyEq(promise, expected) {
|
||||||
|
assertEq(getPromiseResult(promise), expected);
|
||||||
|
}
|
||||||
|
global.assertEventuallyEq = assertEventuallyEq;
|
||||||
|
|
||||||
|
function assertEventuallyThrows(promise, expectedErrorType) {
|
||||||
|
assertThrowsInstanceOf(() => getPromiseResult(promise), expectedErrorType);
|
||||||
|
};
|
||||||
|
global.assertEventuallyThrows = assertEventuallyThrows;
|
||||||
|
|
||||||
|
function assertEventuallyDeepEq(promise, expected) {
|
||||||
|
assertDeepEq(getPromiseResult(promise), expected);
|
||||||
|
};
|
||||||
|
global.assertEventuallyDeepEq = assertEventuallyDeepEq;
|
||||||
|
})(this);
|
Загрузка…
Ссылка в новой задаче