tor-browser

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

eval-export-dflt-expr-fn-anon.js (1359B)


      1 // |reftest| module async
      2 // Copyright (C) 2018 Rick Waldron. All rights reserved.
      3 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      4 // This code is governed by the BSD license found in the LICENSE file.
      5 /*---
      6 description: >
      7    Default AssignmentExpression (which can be recognized as an "anonymous"
      8    function declaration) is correctly initialized upon evaluation
      9 esid: sec-moduleevaluation
     10 info: |
     11    [...]
     12    16. Let result be the result of evaluating module.[[ECMAScriptCode]].
     13    [...]
     14 
     15    15.2.3.11 Runtime Semantics: Evaluation
     16 
     17    ExportDeclaration : export default AssignmentExpression;
     18 
     19    [...]
     20    3. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then
     21       a. Let hasNameProperty be ? HasOwnProperty(value, "name").
     22       b. If hasNameProperty is false, perform SetFunctionName(value,
     23          "default").
     24    4. Let env be the running execution context's LexicalEnvironment.
     25    5. Perform ? InitializeBoundName("*default*", value, env).
     26    [...]
     27 flags: [async, module]
     28 features: [dynamic-import]
     29 ---*/
     30 
     31 export default (function() { return 99; });
     32 import('./eval-export-dflt-expr-fn-anon.js').then(imported => {
     33  assert.sameValue(imported.default(), 99, 'binding initialized');
     34  assert.sameValue(imported.default.name, 'default', 'correct name is assigned');
     35 }).then($DONE, $DONE).catch($DONE);