Debian Codegraph @

js/src/tests/test262/language/eval-code/indirect/non-definable-global-function.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-evaldeclarationinstantiation
5 es6id: 18.2.1.2
6 description: Throws a TypeError if a global function cannot be defined.
7 info: |
8 Runtime Semantics: EvalDeclarationInstantiation( body, varEnv, lexEnv, strict)
9
10 ...
11 8. For each d in varDeclarations, in reverse list order do
12 a. If d is neither a VariableDeclaration or a ForBinding, then
13 i. Assert: d is either a FunctionDeclaration or a 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. If varEnvRec is a global Environment Record, then
19 a. Let fnDefinable be varEnvRec.CanDeclareGlobalFunction(fn).
20 b. ReturnIfAbrupt(fnDefinable).
21 c. If fnDefinable is false, throw TypeError exception.
22 ...
23 ---*/
24
25 assert.throws(TypeError, function() {
26 (0,eval)("function NaN() {}");
27 });
28
29 reportCompare(0, 0);