tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

instn-iee-bndng-gen.js (2312B)


      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 indirectly-exported generator function
      7    binding
      8 esid: sec-moduledeclarationinstantiation
      9 info: |
     10    [...]
     11    12. For each ImportEntry Record in in module.[[ImportEntries]], do
     12        a. Let importedModule be ? HostResolveImportedModule(module,
     13           in.[[ModuleRequest]]).
     14        b. If in.[[ImportName]] is "*", then
     15           [...]
     16        c. Else,
     17           i. Let resolution be ?
     18              importedModule.ResolveExport(in.[[ImportName]], « », « »).
     19           ii. If resolution is null or resolution is "ambiguous", throw a
     20               SyntaxError exception.
     21           iii. Call envRec.CreateImportBinding(in.[[LocalName]],
     22                resolution.[[Module]], resolution.[[BindingName]]).
     23    [...]
     24    16. Let lexDeclarations be the LexicallyScopedDeclarations of code.
     25    17. For each element d in lexDeclarations do
     26        a. For each element dn of the BoundNames of d do
     27           i, If IsConstantDeclaration of d is true, then
     28              [...]
     29           ii. Else,
     30               1. Perform ! envRec.CreateMutableBinding(dn, false).
     31           iii. If d is a GeneratorDeclaration production or a
     32                FunctionDeclaration production, then
     33                [...]
     34 
     35    8.1.1.5.5 CreateImportBinding
     36 
     37    [...]
     38    5. Create an immutable indirect binding in envRec for N that references M
     39       and N2 as its target binding and record that the binding is initialized.
     40    6. Return NormalCompletion(empty).
     41 flags: [module]
     42 features: [generators]
     43 ---*/
     44 
     45 assert.sameValue(
     46  B().next().value,
     47  455,
     48  'binding is initialized to function value prior to module evaluation'
     49 );
     50 
     51 assert.throws(TypeError, function() {
     52  B = null;
     53 });
     54 
     55 assert.sameValue(B().next().value, 455, 'binding value is immutable');
     56 
     57 import { B, results } from './instn-iee-bndng-gen_FIXTURE.js';
     58 export function* A () { return 455; }
     59 
     60 assert.sameValue(results.length, 4);
     61 assert.sameValue(results[0], 'ReferenceError');
     62 assert.sameValue(results[1], 'undefined');
     63 assert.sameValue(results[2], 'ReferenceError');
     64 assert.sameValue(results[3], 'undefined');
     65 
     66 reportCompare(0, 0);