test262/test/language/global-code/script-decl-lex-var.js
jugglinmike b9e21138cc Add tests for script interactions (#689)
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
2016-07-19 18:02:05 -07:00

32 lines
857 B
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: Let binding collision with existing var declaration
info: |
[...]
5. For each name in lexNames, do
a. If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
exception.
---*/
var test262Var;
function test262Fn() {}
assert.throws(SyntaxError, function() {
$.evalScript('var x; let test262Var;');
}, 'variable');
assert.throws(ReferenceError, function() {
x;
}, 'no bindings created (script shadowing variable)');
assert.throws(SyntaxError, function() {
$.evalScript('var x; let test262Fn;');
}, 'function');
assert.throws(ReferenceError, function() {
x;
}, 'no bindings created (script shadowing function)');