Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / language / module-code / instn-star-binding.js
blob16bcc86e9c473c73e03ea25973371a4ce2930c0d
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: Immutable binding is created for module namespace object
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            i. Let namespace be ? GetModuleNamespace(importedModule).
14            ii. Perform ! envRec.CreateImmutableBinding(in.[[LocalName]], true).
15            iii. Call envRec.InitializeBinding(in.[[LocalName]], namespace).
16     [...]
17 flags: [module]
18 ---*/
20 assert.sameValue(
21   typeof ns, 'object', 'binding is initialized prior to module evaluation'
24 var original = ns;
26 assert.throws(TypeError, function() {
27   ns = null;
28 }, 'binding rejects assignment');
30 assert.sameValue(ns, original, 'binding value is immutable');
32 import * as ns from './instn-star-binding.js';
34 reportCompare(0, 0);