Debian Codegraph @

js/src/tests/test262/language/statements/generators/yield-identifier-non-strict.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/generators/yield-identifier-non-strict.case
3 // - src/generators/non-strict/declaration.template
4 /*---
5 description: Use of yield as a valid identifier in a function body inside a generator body in non strict mode (Generator function declaration - valid for non-strict only cases)
6 esid: prod-GeneratorDeclaration
7 features: [generators]
8 flags: [generated, noStrict]
9 info: |
10 14.4 Generator Function Definitions
11
12 GeneratorDeclaration[Yield, Await, Default]:
13 function * BindingIdentifier[?Yield, ?Await] ( FormalParameters[+Yield, ~Await] ) { GeneratorBody }
14
15 ---*/
16
17 var callCount = 0;
18
19 function *gen() {
20 callCount += 1;
21 return (function(arg) {
22 var yield = arg + 1;
23 return yield;
24 }(yield))
25 }
26
27 var iter = gen();
28
29 var item = iter.next();
30
31 assert.sameValue(item.done, false);
32 assert.sameValue(item.value, undefined);
33
34 item = iter.next(42);
35
36 assert.sameValue(item.done, true);
37 assert.sameValue(item.value, 43);
38
39 assert.sameValue(callCount, 1);
40
41 reportCompare(0, 0);