Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: test/mjsunit/es6/tail-call-simple.js

Issue 1609893003: [es6] Tail calls support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/es6/tail-call-proxies.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax --harmony-tailcalls --stack-size=100
6
7 //
8 // Tail calls work only in strict mode.
9 //
10 (function() {
11 function f(n) {
12 if (n <= 0) {
13 return "foo";
14 }
15 return f(n - 1);
16 }
17 assertThrows(()=>{ f(1e6) });
18 })();
19
20
21 //
22 // Tail call normal functions.
23 //
24 (function() {
25 "use strict";
26 function f(n) {
27 if (n <= 0) {
28 return "foo";
29 }
30 return f(n - 1);
31 }
32 assertEquals("foo", f(1e6));
33 })();
34
35
36 (function() {
37 "use strict";
38 function f(n){
39 if (n <= 0) {
40 return "foo";
41 }
42 return g(n - 1);
43 }
44 function g(n){
45 if (n <= 0) {
46 return "bar";
47 }
48 return f(n - 1);
49 }
50 assertEquals("foo", f(1e6));
51 assertEquals("bar", f(1e6 + 1));
52 })();
53
54
55 //
56 // Tail call bound functions.
57 //
58 (function() {
59 "use strict";
60 function f0(n) {
61 if (n <= 0) {
62 return "foo";
63 }
64 return f(n - 1);
65 }
66 var f = f0.bind({});
67 assertEquals("foo", f(1e6));
68 })();
69
70
71 (function() {
72 "use strict";
73 function f0(n){
74 if (n <= 0) {
75 return "foo";
76 }
77 return g(n - 1);
78 }
79 function g0(n){
80 if (n <= 0) {
81 return "bar";
82 }
83 return f(n - 1);
84 }
85 var f = f0.bind({});
86 var g = g0.bind({});
87
88 assertEquals("foo", f(1e6));
89 assertEquals("bar", f(1e6 + 1));
90 })();
OLDNEW
« no previous file with comments | « test/mjsunit/es6/tail-call-proxies.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698