Debian Codegraph @

js/src/tests/test262/language/module-code/eval-export-dflt-expr-fn-anon.js

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