summaryrefslogtreecommitdiff
path: root/testsuite/tests/match-exception/tail_calls.ml
blob: ae72fc9317775227f073b1347e2b80ac2a1886d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(* TEST
*)

(**
    The success continuation expression is in tail position.
*)

let count_to_tr_match n =
  let rec loop i =
    match
      i < n
    with exception Not_found -> ()
    | false -> ()
    | true -> loop (i + 1)
  in loop 0
;;

let test_tail_recursion =
  try
    count_to_tr_match 10000000;
    print_endline "handler-case (match) is tail recursive"
  with _ ->
    assert false
;;