tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

block-decl-func-skip-arguments.js (1775B)


      1 // Copyright (C) 2017 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Functions named 'arguments' have legacy hoisting semantics
      6 esid: sec-web-compat-functiondeclarationinstantiation
      7 flags: [noStrict]
      8 info: |
      9    FunctionDeclarationInstantiation ( _func_, _argumentsList_ )
     10 
     11    [...]
     12    7. Let _parameterNames_ be the BoundNames of _formals_.
     13    [...]
     14    22. If argumentsObjectNeeded is true, then
     15      f. Append "arguments" to parameterNames.
     16 
     17    Changes to FunctionDeclarationInstantiation
     18 
     19    [...]
     20    ii. If replacing the |FunctionDeclaration| _f_ with a |VariableStatement| that has _F_
     21        as a |BindingIdentifier| would not produce any Early Errors for _func_ and _F_ is
     22        not an element of _parameterNames_, then
     23      [...]
     24 ---*/
     25 
     26 // Simple parameters
     27 (function() {
     28  assert.sameValue(arguments.toString(), "[object Arguments]");
     29  {
     30    assert.sameValue(arguments(), undefined);
     31    function arguments() {}
     32    assert.sameValue(arguments(), undefined);
     33  }
     34  assert.sameValue(arguments.toString(), "[object Arguments]");
     35 }());
     36 
     37 // Single named parameter
     38 (function(x) {
     39  assert.sameValue(arguments.toString(), "[object Arguments]");
     40  {
     41    assert.sameValue(arguments(), undefined);
     42    function arguments() {}
     43    assert.sameValue(arguments(), undefined);
     44  }
     45  assert.sameValue(arguments.toString(), "[object Arguments]");
     46 }());
     47 
     48 // Non-simple parameters
     49 (function(..._) {
     50  assert.sameValue(arguments.toString(), "[object Arguments]");
     51  {
     52    assert.sameValue(arguments(), undefined);
     53    function arguments() {}
     54    assert.sameValue(arguments(), undefined);
     55  }
     56  assert.sameValue(arguments.toString(), "[object Arguments]");
     57 }());
     58 
     59 reportCompare(0, 0);