summaryrefslogtreecommitdiff
path: root/ocaml-binary-annot/testsuite/tests/basic/tailcalls.ml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml-binary-annot/testsuite/tests/basic/tailcalls.ml')
-rw-r--r--ocaml-binary-annot/testsuite/tests/basic/tailcalls.ml28
1 files changed, 28 insertions, 0 deletions
diff --git a/ocaml-binary-annot/testsuite/tests/basic/tailcalls.ml b/ocaml-binary-annot/testsuite/tests/basic/tailcalls.ml
new file mode 100644
index 0000000000..23b7353598
--- /dev/null
+++ b/ocaml-binary-annot/testsuite/tests/basic/tailcalls.ml
@@ -0,0 +1,28 @@
+let rec tailcall4 a b c d =
+ if a < 0
+ then b
+ else tailcall4 (a-1) (b+1) (c+2) (d+3)
+
+let rec tailcall8 a b c d e f g h =
+ if a < 0
+ then b
+ else tailcall8 (a-1) (b+1) (c+2) (d+3) (e+4) (f+5) (g+6) (h+7)
+
+let rec tailcall16 a b c d e f g h i j k l m n o p =
+ if a < 0
+ then b
+ else tailcall16 (a-1) (b+1) (c+2) (d+3) (e+4) (f+5) (g+6) (h+7)
+ (i+8) (j+9) (k+10) (l+11) (m+12) (n+13) (o+14) (p+15)
+
+let indtailcall8 fn a b c d e f g h =
+ fn a b c d e f g h
+
+let indtailcall16 fn a b c d e f g h i j k l m n o p =
+ fn a b c d e f g h i j k l m n o p
+
+let _ =
+ print_int (tailcall4 10000000 0 0 0); print_newline();
+ print_int (tailcall8 10000000 0 0 0 0 0 0 0); print_newline();
+ print_int (tailcall16 10000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0); print_newline();
+ print_int (indtailcall8 tailcall8 10 0 0 0 0 0 0 0); print_newline();
+ print_int (indtailcall16 tailcall16 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0); print_newline()