mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
ECMA262 allows for an arbitrary number of "ScriptJob"s to run in a given realm. Although there is no standard mechanism for enqueuing these jobs, many implementations offer this functionality through custom APIs. In those hosts, the semantics describing script interactions are directly observable. In order to guarantee conformance to the specification in advance of a standardized API, Test262 now requires that hosts provide a $.evalScript function whose behavior is defined in the project's "INTERPRETING.md" file. Use this host-provided API to ensure that implementations correctly observe the specification text that dictates script interactions. (In writing these tests, I noticed some gaps in coverage that are observable from a single script execution. This patch includes a dedicated commit for these tests that do not require $.evalScript.) * Improve coverage of GlobalDeclarationInstantiation * Add tests for script interactions Use the host-provied `$.evalScript` method to assert conformance to the specification text that defines script interactions. * fixup! Improve coverage of GlobalDeclarationInstantiation
53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
// Copyright (C) 2016 the V8 project authors. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
esid: sec-globaldeclarationinstantiation
|
|
es6id: 15.1.8
|
|
description: Declaration of lexical bindings
|
|
info: |
|
|
[...]
|
|
16. For each element d in lexDeclarations do
|
|
a. NOTE Lexically declared names are only instantiated here but not
|
|
initialized.
|
|
b. For each element dn of the BoundNames of d do
|
|
i. If IsConstantDeclaration of d is true, then
|
|
1. Perform ? envRec.CreateImmutableBinding(dn, true).
|
|
ii. Else,
|
|
1. Perform ? envRec.CreateMutableBinding(dn, false).
|
|
[...]
|
|
---*/
|
|
|
|
let test262let = 1;
|
|
|
|
test262let = 2;
|
|
|
|
assert.sameValue(test262let, 2, '`let` binding is mutable');
|
|
assert.sameValue(
|
|
this.hasOwnProperty('test262let'),
|
|
false,
|
|
'property not created on the global object (let)'
|
|
);
|
|
|
|
const test262const = 3;
|
|
|
|
assert.throws(TypeError, function() {
|
|
test262const = 4;
|
|
}, '`const` binding is strictly immutable');
|
|
assert.sameValue(test262const, 3, '`const` binding cannot be modified');
|
|
assert.sameValue(
|
|
this.hasOwnProperty('test262const'),
|
|
false,
|
|
'property not created on the global object (const)'
|
|
);
|
|
|
|
class test262class {}
|
|
|
|
test262class = 5;
|
|
|
|
assert.sameValue(test262class, 5, '`class` binding is mutable');
|
|
assert.sameValue(
|
|
this.hasOwnProperty('test262class'),
|
|
false,
|
|
'property not created on the global object (class)'
|
|
);
|