tor-browser

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

instn-named-bndng-var.js (1940B)


      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: Imported binding reflects state of exported `var` binding
      6 esid: sec-moduledeclarationinstantiation
      7 info: |
      8    [...]
      9    12. For each ImportEntry Record in in module.[[ImportEntries]], do
     10        a. Let importedModule be ? HostResolveImportedModule(module,
     11           in.[[ModuleRequest]]).
     12        b. If in.[[ImportName]] is "*", then
     13           [...]
     14        c. Else,
     15           i. Let resolution be ?
     16              importedModule.ResolveExport(in.[[ImportName]], « », « »).
     17           ii. If resolution is null or resolution is "ambiguous", throw a
     18               SyntaxError exception.
     19           iii. Call envRec.CreateImportBinding(in.[[LocalName]],
     20                resolution.[[Module]], resolution.[[BindingName]]).
     21    [...]
     22    14. Let declaredVarNames be a new empty List.
     23    15. For each element d in varDeclarations do
     24        a. For each element dn of the BoundNames of d do
     25           i. If dn is not an element of declaredVarNames, then
     26              1. Perform ! envRec.CreateMutableBinding(dn, false).
     27              2. Call envRec.InitializeBinding(dn, undefined).
     28              3. Append dn to declaredVarNames.
     29    [...]
     30 
     31    8.1.1.5.5 CreateImportBinding
     32 
     33    [...]
     34    5. Create an immutable indirect binding in envRec for N that references M
     35       and N2 as its target binding and record that the binding is initialized.
     36    6. Return NormalCompletion(empty).
     37 flags: [module]
     38 ---*/
     39 
     40 assert.sameValue(
     41  y,
     42  undefined,
     43  'binding is initialized to `undefined` prior to module evaulation'
     44 );
     45 
     46 assert.throws(TypeError, function() {
     47  y = null;
     48 }, 'binding rejects assignment');
     49 
     50 assert.sameValue(y, undefined, 'binding value is immutable');
     51 
     52 import { x as y } from './instn-named-bndng-var.js';
     53 export var x = 23;
     54 
     55 reportCompare(0, 0);