Skip to content
Snippets Groups Projects
  • jugglinmike's avatar
    a41b7111
    Annex b skip fib (#704) · a41b7111
    jugglinmike authored
    * 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
    a41b7111
    History
    Annex b skip fib (#704)
    jugglinmike authored
    * 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
block-decl-func-block-scoping.js 1.50 KiB
// This file was procedurally generated from the following sources:
// - src/annex-b-fns/func-block-scoping.case
// - src/annex-b-fns/func/block.template
/*---
description: A block-scoped binding is created (Block statement in function scope containing a function declaration)
esid: sec-web-compat-functiondeclarationinstantiation
es6id: B.3.3.1
flags: [generated, noStrict]
info: |
    13.2.14 Runtime Semantics: BlockDeclarationInstantiation

    [...]
    4. For each element d in declarations do
       a. For each element dn of the BoundNames of d do
          i. If IsConstantDeclaration of d is true, then
             [...]
          ii. Else,
              2. Perform ! envRec.CreateMutableBinding(dn, false).

       b. If d is a GeneratorDeclaration production or a FunctionDeclaration
          production, then
          i. Let fn be the sole element of the BoundNames of d.
          ii. Let fo be the result of performing InstantiateFunctionObject for
              d with argument env.
          iii. Perform envRec.InitializeBinding(fn, fo). 
---*/
var initialBV, currentBV, varBinding;

(function() {
  

  {
    function f() { initialBV = f; f = 123; currentBV = f; return 'decl'; }
  }

  varBinding = f;
  f();
}());


assert.sameValue(
  initialBV(),
  'decl',
  'Block-scoped binding value is function object at execution time'
);
assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable');
assert.sameValue(
  varBinding(),
  'decl',
  'Block-scoped binding is independent of outer var-scoped binding'
);