Debian Codegraph @

js/src/tests/test262/language/expressions/object/method-definition/computed-property-name-yield-expression.js

raw
1 // Copyright (C) 2020 Rick Waldron. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 When the `yield` keyword occurs within the PropertyName of a
7 non-generator MethodDefinition within a generator function, it behaves as a
8 YieldExpression.
9 info: |
10 ComputedPropertyName:
11 [ AssignmentExpression ]
12
13 AssignmentExpression[In, Yield, Await]:
14 [+Yield]YieldExpression[?In, ?Await]
15
16 features: [computed-property-names, generators]
17 flags: [noStrict]
18 ---*/
19
20 function * g() {
21 let o = {
22 [yield 10]: 1,
23 a: 'a'
24 };
25
26 yield 20;
27 return o;
28 }
29
30 let iter = g();
31 assert.sameValue(iter.next().value, 10);
32 assert.sameValue(iter.next().value, 20);
33
34 let outcome = iter.next().value;
35
36 assert.sameValue(outcome[undefined], 1);
37 assert.sameValue(outcome.a, 'a');
38
39
40 reportCompare(0, 0);