summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/module-code/instn-iee-bndng-gen.js
blob: 51ea4f600121afd200d2d5651cb3de9759a0758d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// |reftest| module
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: >
    Imported binding reflects state of indirectly-exported generator function
    binding
esid: sec-moduledeclarationinstantiation
info: |
    [...]
    12. For each ImportEntry Record in in module.[[ImportEntries]], do
        a. Let importedModule be ? HostResolveImportedModule(module,
           in.[[ModuleRequest]]).
        b. If in.[[ImportName]] is "*", then
           [...]
        c. Else,
           i. Let resolution be ?
              importedModule.ResolveExport(in.[[ImportName]], « », « »).
           ii. If resolution is null or resolution is "ambiguous", throw a
               SyntaxError exception.
           iii. Call envRec.CreateImportBinding(in.[[LocalName]],
                resolution.[[Module]], resolution.[[BindingName]]).
    [...]
    16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
    17. For each element d in lexDeclarations do
        a. For each element dn of the BoundNames of d do
           i, If IsConstantDeclaration of d is true, then
              [...]
           ii. Else,
               1. Perform ! envRec.CreateMutableBinding(dn, false).
           iii. If d is a GeneratorDeclaration production or a
                FunctionDeclaration production, then
                [...]

    8.1.1.5.5 CreateImportBinding

    [...]
    5. Create an immutable indirect binding in envRec for N that references M
       and N2 as its target binding and record that the binding is initialized.
    6. Return NormalCompletion(empty).
flags: [module]
features: [generators]
---*/

assert.sameValue(
  B().next().value,
  455,
  'binding is initialized to function value prior to module evaluation'
);

assert.throws(TypeError, function() {
  B = null;
});

assert.sameValue(B().next().value, 455, 'binding value is immutable');

import { B, results } from './instn-iee-bndng-gen_FIXTURE.js';
export function* A () { return 455; }

assert.sameValue(results.length, 4);
assert.sameValue(results[0], 'ReferenceError');
assert.sameValue(results[1], 'undefined');
assert.sameValue(results[2], 'ReferenceError');
assert.sameValue(results[3], 'undefined');

reportCompare(0, 0);