mirror of https://github.com/tc39/test262.git
Use Promise chaining
This commit is contained in:
parent
919415704b
commit
616978791d
|
@ -44,19 +44,16 @@ async function* asyncGenerator() {
|
|||
}
|
||||
|
||||
var asyncIterator = asyncGenerator();
|
||||
asyncIterator.next().then(function() {
|
||||
var thrownError = { name: "err" };
|
||||
asyncIterator.throw(thrownError).then(
|
||||
function(result) {
|
||||
throw new Test262Error("Promise should be rejected, got: " + result.value);
|
||||
},
|
||||
function(err) {
|
||||
assert.sameValue(err, thrownError);
|
||||
var thrownError = { name: "err" };
|
||||
|
||||
asyncIterator.next().then(function(result) {
|
||||
assert.sameValue(result.value, undefined);
|
||||
assert.sameValue(result.done, true);
|
||||
}).then($DONE, $DONE);
|
||||
}
|
||||
).catch($DONE);
|
||||
}).catch($DONE);
|
||||
asyncIterator.next().then(function() {
|
||||
return asyncIterator.throw(thrownError);
|
||||
}).then(function(result) {
|
||||
throw new Test262Error("Promise should be rejected, got: " + result.value);
|
||||
}, function(err) {
|
||||
assert.sameValue(err, thrownError);
|
||||
return asyncIterator.next().then(function(result) {
|
||||
assert.sameValue(result.value, undefined);
|
||||
assert.sameValue(result.done, true);
|
||||
});
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -47,9 +47,9 @@ async function* asyncGenerator() {
|
|||
|
||||
var asyncIterator = asyncGenerator();
|
||||
asyncIterator.next().then(function() {
|
||||
asyncIterator.return(2).then(function(result) {
|
||||
return asyncIterator.return(2).then(function(result) {
|
||||
assert.sameValue(result.value, 2);
|
||||
assert.sameValue(result.done, true);
|
||||
assert.sameValue(returnGets, 1);
|
||||
}).then($DONE, $DONE);
|
||||
}).catch($DONE);
|
||||
});
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -62,14 +62,11 @@ async function* asyncGenerator() {
|
|||
|
||||
var asyncIterator = asyncGenerator();
|
||||
asyncIterator.next().then(function() {
|
||||
asyncIterator.throw().then(
|
||||
function(result) {
|
||||
throw new Test262Error("Promise should be rejected, got: " + result.value);
|
||||
},
|
||||
function(err) {
|
||||
assert.sameValue(err.constructor, TypeError);
|
||||
assert.sameValue(throwGets, 1);
|
||||
assert.sameValue(returnGets, 1);
|
||||
},
|
||||
).then($DONE, $DONE);
|
||||
}).catch($DONE);
|
||||
return asyncIterator.throw();
|
||||
}).then(function(result) {
|
||||
throw new Test262Error("Promise should be rejected, got: " + result.value);
|
||||
}, function(err) {
|
||||
assert.sameValue(err.constructor, TypeError);
|
||||
assert.sameValue(throwGets, 1);
|
||||
assert.sameValue(returnGets, 1);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
Loading…
Reference in New Issue