Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/call/tco-non-eval-function.js

raw
1 // Copyright (C) 2017 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-function-calls-runtime-semantics-evaluation
6 description: >
7 Tail-call with identifier named "eval" in function environment.
8 info: |
9 12.3.4.1 Runtime Semantics: Evaluation
10 ...
11 6. If Type(ref) is Reference and IsPropertyReference(ref) is false and
12 GetReferencedName(ref) is "eval", then
13 a. If SameValue(func, %eval%) is true, then
14 ...
15 ...
16 9. Return ? EvaluateCall(func, ref, arguments, tailCall).
17
18 12.3.4.2 Runtime Semantics: EvaluateCall( func, ref, arguments, tailPosition )
19 ...
20 7. If tailPosition is true, perform PrepareForTailCall().
21 8. Let result be Call(func, thisValue, argList).
22 ...
23
24 flags: [noStrict]
25 features: [tail-call-optimization]
26 includes: [tcoHelper.js]
27 ---*/
28
29 var callCount = 0;
30
31 (function() {
32 function f(n) {
33 "use strict";
34 if (n === 0) {
35 callCount += 1
36 return;
37 }
38 return eval(n - 1);
39 }
40 var eval = f;
41 f($MAX_ITERATIONS);
42 })();
43
44 assert.sameValue(callCount, 1);