Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / language / module-code / instn-named-bndng-dflt-gen-named.js
blob7d26b46d4afea9642f52bb355216272a925774ea
1 // |reftest| module
2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 description: >
6     Imported binding reflects state of exported default binding ("named"
7     generator function declaration)
8 esid: sec-moduledeclarationinstantiation
9 info: |
10     [...]
11     17. For each element d in lexDeclarations do
12         a. For each element dn of the BoundNames of d do
13            i. If IsConstantDeclaration of d is true, then
14               [...]
15            ii. Else,
16                1. Perform ! envRec.CreateMutableBinding(dn, false).
17            iii. If d is a GeneratorDeclaration production or a
18                 FunctionDeclaration production, then
19                 1. Let fo be the result of performing InstantiateFunctionObject
20                    for d with argument env.
21                 2. Call envRec.InitializeBinding(dn, fo).
22     [...]
24     14.4.12 Runtime Semantics: InstantiateFunctionObject
26     GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
28     1. If the function code for GeneratorDeclaration is strict mode code, let
29        strict be true. Otherwise let strict be false.
30     2. Let F be GeneratorFunctionCreate(Normal, FormalParameters,
31        GeneratorBody, scope, strict).
32     3. Let prototype be ObjectCreate(%GeneratorPrototype%).
33     4. Perform DefinePropertyOrThrow(F, "prototype",
34        PropertyDescriptor{[[Value]]: prototype, [[Writable]]: true,
35        [[Enumerable]]: false, [[Configurable]]: false}).
36     5. Perform SetFunctionName(F, "default").
37     6. Return F.
39     14.4 Generator Function Definitions
41     Syntax
43     GeneratorDeclaration[Yield, Default] :
44          function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody }
45          [+Default] function * ( FormalParameters[Yield] ) { GeneratorBody }
46 flags: [module]
47 features: [generators]
48 ---*/
50 assert.sameValue(g().next().value, 23, 'generator function value is hoisted');
51 assert.sameValue(g.name, 'gName', 'correct name is assigned');
53 import g from './instn-named-bndng-dflt-gen-named.js';
54 export default function* gName() { return 23; };
56 reportCompare(0, 0);