mirror of
https://github.com/tc39/test262.git
synced 2025-07-02 19:54:38 +02:00
* Re-generate tests The test generation tool has been modified in the time since these tests were first generated and committed to the project. Re-generate the tests using the latest version of the tool. * Add test cases for Annex B hoisting disqualifiers The "variable-like" function hoisting semantics defined in Annex B extension B.3.3 is only applied if "[...] replacing the FunctionDeclaration f with a VariableStatement that has F as a BindingIdentifier would not produce any Early Errors [...]". Test262 previously included tests for this condition when the disqualifying early error originated from the ScriptBody and FunctionBody productions. Add test cases to assert the behavior when it is disqualified by all other relevant early errors: Block statements, `for` statements, `for-of` statements, `for-in` statements, and Switch statements. * Generate tests * fixup! Add test cases for Annex B hoisting disqualifiers * fixup! Add test cases for Annex B hoisting disqualifiers Correct test case "info" meta-data. * fixup! Add test cases for Annex B hoisting disqualifiers Improve test bodies * fixup! Generate tests
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
// This file was procedurally generated from the following sources:
|
|
// - src/annex-b-fns/eval-func-init.case
|
|
// - src/annex-b-fns/eval-func/direct-block.template
|
|
/*---
|
|
description: Variable binding is initialized to `undefined` in outer scope (Block statement in eval code containing a function declaration)
|
|
esid: sec-web-compat-evaldeclarationinstantiation
|
|
es6id: B.3.3.3
|
|
flags: [generated, noStrict]
|
|
info: |
|
|
B.3.3.3 Changes to EvalDeclarationInstantiation
|
|
|
|
[...]
|
|
a. If declaredFunctionOrVarNames does not contain F, then
|
|
i. If varEnvRec is a global Environment Record, then
|
|
[...]
|
|
ii. Else,
|
|
i. Let bindingExists be varEnvRec.HasBinding(F).
|
|
ii. If bindingExists is false, then
|
|
i. Perform ! varEnvRec.CreateMutableBinding(F, true).
|
|
ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
|
|
[...]
|
|
---*/
|
|
var init, changed;
|
|
|
|
(function() {
|
|
eval(
|
|
'init = f;\
|
|
f = 123;\
|
|
changed = f;{ function f() { } }'
|
|
);
|
|
}());
|
|
|
|
assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
|
|
assert.sameValue(changed, 123, 'binding is mutable');
|
|
assert.throws(ReferenceError, function() {
|
|
f;
|
|
}, 'global binding is not created');
|