Index: test/mjsunit/es7/syntactic-tail-call.js |
diff --git a/test/mjsunit/es6/tail-call.js b/test/mjsunit/es7/syntactic-tail-call.js |
similarity index 82% |
copy from test/mjsunit/es6/tail-call.js |
copy to test/mjsunit/es7/syntactic-tail-call.js |
index 318519b3551c0b939e9fdcbfef883c11c384708f..b65fc450590afff8f051e1323dad6a4ec38ceede 100644 |
--- a/test/mjsunit/es6/tail-call.js |
+++ b/test/mjsunit/es7/syntactic-tail-call.js |
@@ -2,8 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Flags: --allow-natives-syntax --harmony-tailcalls |
-"use strict"; |
+// Flags: --allow-natives-syntax --harmony-explicit-tailcalls |
Error.prepareStackTrace = (error,stack) => { |
error.strace = stack; |
@@ -39,28 +38,28 @@ function f_153(expected_call_stack, a) { |
CheckStackTrace([f1, test]); |
return 10 + a; |
} |
- function g1(a) { return f1(2); } |
+ function g1(a) { return continue f1(2); } |
// Caller has more arguments than callee. |
function f2(a) { |
CheckStackTrace([f2, test]); |
return 10 + a; |
} |
- function g2(a, b, c) { return f2(2); } |
+ function g2(a, b, c) { return continue f2(2); } |
// Caller has less arguments than callee. |
function f3(a, b, c) { |
CheckStackTrace([f3, test]); |
return 10 + a + b + c; |
} |
- function g3(a) { return f3(2, 3, 4); } |
+ function g3(a) { return continue f3(2, 3, 4); } |
// Callee has arguments adaptor frame. |
function f4(a, b, c) { |
CheckStackTrace([f4, test]); |
return 10 + a; |
} |
- function g4(a) { return f4(2); } |
+ function g4(a) { return continue f4(2); } |
function test() { |
assertEquals(12, g1(1)); |
@@ -82,28 +81,28 @@ function f_153(expected_call_stack, a) { |
CheckStackTrace([f1, test]); |
return 10 + a; |
} |
- function g1(a) { return f1(2); } |
+ function g1(a) { return continue f1(2); } |
// Caller has more arguments than callee. |
function f2(a) { |
CheckStackTrace([f2, test]); |
return 10 + a; |
} |
- function g2(a, b, c) { return f2(2); } |
+ function g2(a, b, c) { return continue f2(2); } |
// Caller has less arguments than callee. |
function f3(a, b, c) { |
CheckStackTrace([f3, test]); |
return 10 + a + b + c; |
} |
- function g3(a) { return f3(2, 3, 4); } |
+ function g3(a) { return continue f3(2, 3, 4); } |
// Callee has arguments adaptor frame. |
function f4(a, b, c) { |
CheckStackTrace([f4, test]); |
return 10 + a; |
} |
- function g4(a) { return f4(2); } |
+ function g4(a) { return continue f4(2); } |
function test() { |
assertEquals(12, g1()); |
@@ -128,7 +127,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a; |
} |
var b1 = f1.bind({a: 153}); |
- function g1(a) { return b1(2); } |
+ function g1(a) { return continue b1(2); } |
// Caller has more arguments than callee. |
function f2(a) { |
@@ -137,7 +136,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a; |
} |
var b2 = f2.bind({a: 153}); |
- function g2(a, b, c) { return b2(2); } |
+ function g2(a, b, c) { return continue b2(2); } |
// Caller has less arguments than callee. |
function f3(a, b, c) { |
@@ -146,7 +145,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a + b + c; |
} |
var b3 = f3.bind({a: 153}); |
- function g3(a) { return b3(2, 3, 4); } |
+ function g3(a) { return continue b3(2, 3, 4); } |
// Callee has arguments adaptor frame. |
function f4(a, b, c) { |
@@ -155,7 +154,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a; |
} |
var b4 = f4.bind({a: 153}); |
- function g4(a) { return b4(2); } |
+ function g4(a) { return continue b4(2); } |
function test() { |
assertEquals(12, g1(1)); |
@@ -179,7 +178,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a; |
} |
var b1 = f1.bind({a: 153}); |
- function g1(a) { return b1(2); } |
+ function g1(a) { return continue b1(2); } |
// Caller has more arguments than callee. |
function f2(a) { |
@@ -188,7 +187,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a; |
} |
var b2 = f2.bind({a: 153}); |
- function g2(a, b, c) { return b2(2); } |
+ function g2(a, b, c) { return continue b2(2); } |
// Caller has less arguments than callee. |
function f3(a, b, c) { |
@@ -197,7 +196,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a + b + c; |
} |
var b3 = f3.bind({a: 153}); |
- function g3(a) { return b3(2, 3, 4); } |
+ function g3(a) { return continue b3(2, 3, 4); } |
// Callee has arguments adaptor frame. |
function f4(a, b, c) { |
@@ -206,7 +205,7 @@ function f_153(expected_call_stack, a) { |
return 10 + a; |
} |
var b4 = f4.bind({a: 153}); |
- function g4(a) { return b4(2); } |
+ function g4(a) { return continue b4(2); } |
function test() { |
assertEquals(12, g1()); |
@@ -224,15 +223,15 @@ function f_153(expected_call_stack, a) { |
// Tail calling via various expressions. |
(function() { |
function g1(a) { |
- return f([f, g1, test], false) || f([f, test], true); |
+ return continue f([f, g1, test], false) || f([f, test], true); |
} |
function g2(a) { |
- return f([f, g2, test], true) && f([f, test], true); |
+ return continue f([f, g2, test], true) && f([f, test], true); |
} |
function g3(a) { |
- return f([f, g3, test], 13), f([f, test], 153); |
+ return continue f([f, g3, test], 13), f([f, test], 153); |
} |
function test() { |
@@ -264,7 +263,7 @@ function f_153(expected_call_stack, a) { |
throw new Error("boom"); |
} catch(e) { |
f_153([f_153, tc2, test]); |
- return f_153([f_153, test]); |
+ return continue f_153([f_153, test]); |
} |
} |
@@ -276,7 +275,7 @@ function f_153(expected_call_stack, a) { |
f_153([f_153, tc3, test]); |
} |
f_153([f_153, tc3, test]); |
- return f_153([f_153, test]); |
+ return continue f_153([f_153, test]); |
} |
function test() { |
@@ -308,7 +307,7 @@ function f_153(expected_call_stack, a) { |
throw new Error("boom"); |
} finally { |
f_153([f_153, tf2, test]); |
- return f_153([f_153, test]); |
+ return continue f_153([f_153, test]); |
} |
} |
@@ -318,7 +317,7 @@ function f_153(expected_call_stack, a) { |
} finally { |
f_153([f_153, tf3, test]); |
} |
- return f_153([f_153, test]); |
+ return continue f_153([f_153, test]); |
} |
function test() { |
@@ -365,7 +364,7 @@ function f_153(expected_call_stack, a) { |
f_153([f_153, tcf3, test]); |
} finally { |
f_153([f_153, tcf3, test]); |
- return f_153([f_153, test]); |
+ return continue f_153([f_153, test]); |
} |
} |
@@ -378,7 +377,7 @@ function f_153(expected_call_stack, a) { |
} finally { |
f_153([f_153, tcf4, test]); |
} |
- return f_153([f_153, test]); |
+ return continue f_153([f_153, test]); |
} |
function test() { |
@@ -397,16 +396,25 @@ function f_153(expected_call_stack, a) { |
// Test tail calls from arrow functions. |
(function () { |
function g1(a) { |
- return (() => { return f_153([f_153, test]); })(); |
+ return continue (() => { return continue f_153([f_153, test]); })(); |
} |
function g2(a) { |
- return (() => f_153([f_153, test]))(); |
+ return continue (() => continue f_153([f_153, test]))(); |
+ } |
+ |
+ function g3(a) { |
+ var closure = () => continue f([f, closure, test], true) |
+ ? f_153([f_153, test]) |
+ : f_153([f_153, test]); |
+ |
+ return continue closure(); |
} |
function test() { |
assertEquals(153, g1()); |
assertEquals(153, g2()); |
+ assertEquals(153, g3()); |
} |
test(); |
test(); |