| Index: test/mjsunit/es6/tail-call.js
|
| diff --git a/test/mjsunit/es6/tail-call.js b/test/mjsunit/es6/tail-call.js
|
| index 3df53230ff25ecd57bf377b81ea8dd8d72551a23..d3e35d6e1cc73253f44d267772a3431d0ceba946 100644
|
| --- a/test/mjsunit/es6/tail-call.js
|
| +++ b/test/mjsunit/es6/tail-call.js
|
| @@ -247,6 +247,52 @@ function f_153(expected_call_stack, a) {
|
| })();
|
|
|
|
|
| +// Tail calling from various statements.
|
| +(function() {
|
| + function g1() {
|
| + for (var v in {a:0}) {
|
| + return f_153([f_153, g1, test]);
|
| + }
|
| + }
|
| +
|
| + function g2() {
|
| + for (var v of [1, 2, 3]) {
|
| + return f_153([f_153, g2, test]);
|
| + }
|
| + }
|
| +
|
| + function g3() {
|
| + for (var i = 0; i < 10; i++) {
|
| + return f_153([f_153, test]);
|
| + }
|
| + }
|
| +
|
| + function g4() {
|
| + while (true) {
|
| + return f_153([f_153, test]);
|
| + }
|
| + }
|
| +
|
| + function g5() {
|
| + do {
|
| + return f_153([f_153, test]);
|
| + } while (true);
|
| + }
|
| +
|
| + function test() {
|
| + assertEquals(153, g1());
|
| + assertEquals(153, g2());
|
| + assertEquals(153, g3());
|
| + assertEquals(153, g4());
|
| + assertEquals(153, g5());
|
| + }
|
| + test();
|
| + test();
|
| + %OptimizeFunctionOnNextCall(test);
|
| + test();
|
| +})();
|
| +
|
| +
|
| // Test tail calls from try-catch constructs.
|
| (function() {
|
| function tc1(a) {
|
| @@ -392,3 +438,24 @@ function f_153(expected_call_stack, a) {
|
| %OptimizeFunctionOnNextCall(test);
|
| test();
|
| })();
|
| +
|
| +
|
| +// Test tail calls from arrow functions.
|
| +(function () {
|
| + function g1(a) {
|
| + return (() => { return f_153([f_153, test]); })();
|
| + }
|
| +
|
| + function g2(a) {
|
| + return (() => f_153([f_153, test]))();
|
| + }
|
| +
|
| + function test() {
|
| + assertEquals(153, g1());
|
| + assertEquals(153, g2());
|
| + }
|
| + test();
|
| + test();
|
| + %OptimizeFunctionOnNextCall(test);
|
| + test();
|
| +})();
|
|
|