Backed out 3 changesets (bug 1892041) for causing failures on async-module-does-not...
[gecko.git] / js / src / tests / test262 / language / global-code / script-decl-lex.js
blobb61b38afb320d35b49239cf644a7c0d62151d8d6
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-globaldeclarationinstantiation
5 es6id: 15.1.8
6 description: Declaration of lexical bindings
7 info: |
8   [...]
9   16. For each element d in lexDeclarations do
10       a. NOTE Lexically declared names are only instantiated here but not
11          initialized.
12       b. For each element dn of the BoundNames of d do
13          i. If IsConstantDeclaration of d is true, then
14             1. Perform ? envRec.CreateImmutableBinding(dn, true).
15          ii. Else,
16              1. Perform ? envRec.CreateMutableBinding(dn, false).
17   [...]
18 ---*/
20 // Extensibility of the global object should have no bearing on lexical
21 // declarations.
22 Object.preventExtensions(this);
24 $262.evalScript('let test262let = 1;');
26 test262let = 2;
28 assert.sameValue(test262let, 2, '`let` binding is mutable');
29 assert.sameValue(
30   this.hasOwnProperty('test262let'),
31   false,
32   'property not created on the global object (let)'
35 $262.evalScript('const test262const = 3;');
37 assert.throws(TypeError, function() {
38   test262const = 4;
39 }, '`const` binding is strictly immutable');
40 assert.sameValue(test262const, 3, '`const` binding cannot be modified');
41 assert.sameValue(
42   this.hasOwnProperty('test262const'),
43   false,
44   'property not created on the global object (const)'
47 $262.evalScript('class test262class {}');
49 test262class = 5;
51 assert.sameValue(test262class, 5, '`class` binding is mutable');
52 assert.sameValue(
53   this.hasOwnProperty('test262class'),
54   false,
55   'property not created on the global object (class)'
58 reportCompare(0, 0);