mirror of https://github.com/tc39/test262.git
Add a test for Generator (#3729)
This commit is contained in:
parent
c63d53ad9c
commit
957ab22773
|
@ -0,0 +1,28 @@
|
|||
// Copyright (C) 2022 Bo Pang. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-generator.prototype.return
|
||||
description: >
|
||||
When a generator is paused within a `try` block of a `try..finally`
|
||||
statement, `return` should interrupt control flow as if a `return`
|
||||
statement had appeared at that location in the function body.
|
||||
The `finally` block is still evaluated, and may override the return value.
|
||||
features: [generators]
|
||||
---*/
|
||||
|
||||
|
||||
var obj = { foo: 'not modified' };
|
||||
function* g() {
|
||||
try {
|
||||
obj.foo = yield;
|
||||
} finally {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
var iter = g();
|
||||
var result;
|
||||
|
||||
iter.next();
|
||||
result = iter.return(45).value;
|
||||
assert.sameValue(obj.foo, 'not modified', '`obj.foo` must not be set');
|
||||
assert.sameValue(result, 1, 'finally block must supersede return value');
|
Loading…
Reference in New Issue