Debian Codegraph @

js/src/tests/test262/language/global-code/decl-func.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-globaldeclarationinstantiation
5 es6id: 15.1.8
6 description: Declaration of function where permissible
7 info: |
8 [...]
9 9. Let declaredFunctionNames be a new empty List.
10 10. For each d in varDeclarations, in reverse list order do
11 a. If d is neither a VariableDeclaration or a ForBinding, then
12 i. Assert: d is either a FunctionDeclaration or a
13 GeneratorDeclaration.
14 ii. NOTE If there are multiple FunctionDeclarations for the same name,
15 the last declaration is used.
16 iii. Let fn be the sole element of the BoundNames of d.
17 iv. If fn is not an element of declaredFunctionNames, then
18 1. Let fnDefinable be ? envRec.CanDeclareGlobalFunction(fn).
19 2. If fnDefinable is false, throw a TypeError exception.
20 3. Append fn to declaredFunctionNames.
21 4. Insert d as the first element of functionsToInitialize.
22 [...]
23 17. For each production f in functionsToInitialize, do
24 a. Let fn be the sole element of the BoundNames of f.
25 b. Let fo be the result of performing InstantiateFunctionObject for f
26 with argument env.
27 c. Perform ? envRec.CreateGlobalFunctionBinding(fn, fo, false).
28 [...]
29
30 8.1.1.4.16 CanDeclareGlobalFunction
31
32 1. Let envRec be the global Environment Record for which the method was
33 invoked.
34 2. Let ObjRec be envRec.[[ObjectRecord]].
35 3. Let globalObject be the binding object for ObjRec.
36 4. Let existingProp be ? globalObject.[[GetOwnProperty]](N).
37 5. If existingProp is undefined, return ? IsExtensible(globalObject).
38 includes: [propertyHelper.js]
39 ---*/
40
41 assert.sameValue(
42 typeof brandNew, 'function', 'new binding on an extensible global object'
43 );
44 verifyProperty(this, 'brandNew', {
45 writable: true,
46 enumerable: true,
47 configurable: false,
48 });
49
50 function brandNew() {}
51
52 reportCompare(0, 0);