Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/call/tco-non-eval-with.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 object 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 var f, scope = {};
32 with (scope) {
33 f = function (n) {
34 "use strict";
35 if (n === 0) {
36 callCount += 1
37 return;
38 }
39 return eval(n - 1);
40 }
41 }
42 scope.eval = f;
43
44 f($MAX_ITERATIONS);
45
46 assert.sameValue(callCount, 1);