Index: test/mjsunit/es6/tail-call.js |
diff --git a/test/mjsunit/es6/tail-call.js b/test/mjsunit/es6/tail-call.js |
index 318519b3551c0b939e9fdcbfef883c11c384708f..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) { |