Debian Codegraph @

js/src/tests/test262/language/module-code/instn-named-bndng-trlng-comma.js

raw
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 `var` binding when ImportsList
7 has a trailing comma
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 14. Let declaredVarNames be a new empty List.
25 15. For each element d in varDeclarations do
26 a. For each element dn of the BoundNames of d do
27 i. If dn is not an element of declaredVarNames, then
28 1. Perform ! envRec.CreateMutableBinding(dn, false).
29 2. Call envRec.InitializeBinding(dn, undefined).
30 3. Append dn to declaredVarNames.
31 [...]
32
33 8.1.1.5.5 CreateImportBinding
34
35 [...]
36 5. Create an immutable indirect binding in envRec for N that references M
37 and N2 as its target binding and record that the binding is initialized.
38 6. Return NormalCompletion(empty).
39 flags: [module]
40 ---*/
41
42 assert.sameValue(
43 y,
44 undefined,
45 'binding is initialized to `undefined` prior to module evaulation'
46 );
47
48 assert.throws(TypeError, function() {
49 y = null;
50 }, 'binding rejects assignment');
51
52 assert.sameValue(y, undefined, 'binding value is immutable');
53
54 import { x as y , } from './instn-named-bndng-trlng-comma.js';
55 export var x = 23;
56
57 reportCompare(0, 0);