Debian Codegraph @

js/src/tests/test262/language/eval-code/direct/var-env-func-init-local-new.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 description: Initialization of new local binding
6 info: |
7 [...]
8 15. For each production f in functionsToInitialize, do
9 a. Let fn be the sole element of the BoundNames of f.
10 b. Let fo be the result of performing InstantiateFunctionObject for f
11 with argument lexEnv.
12 c. If varEnvRec is a global Environment Record, then
13 [...]
14 d. Else,
15 i. Let bindingExists be varEnvRec.HasBinding(fn).
16 ii. If bindingExists is false, then
17 1. Let status be ! varEnvRec.CreateMutableBinding(fn, true).
18 2. Assert: status is not an abrupt completion because of
19 validation preceding step 12.
20 3. Perform ! varEnvRec.InitializeBinding(fn, fo).
21 [...]
22 flags: [noStrict]
23 ---*/
24
25 var initial, postAssignment;
26 (function() {
27 eval('initial = f; f = 5; postAssignment = f; function f() { return 33; }');
28 }());
29
30 assert.sameValue(typeof initial, 'function');
31 assert.sameValue(initial(), 33);
32 assert.sameValue(postAssignment, 5, 'binding is mutable');
33 assert.throws(ReferenceError, function() {
34 f;
35 });
36
37 reportCompare(0, 0);