File: match_failure.ml

package info (click to toggle)
js-of-ocaml 6.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (21 lines) | stat: -rw-r--r-- 492 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(* TEST *)

(**
   Test that value match failure in a match block raises Match_failure.
*)
let return_some_3 () = Some (1 + 2)
;;

let test_match_partial_match =
  try
    let _ = (match return_some_3 () with
    | Some x when x < 3 -> "Some x"
    | exception Failure _ -> "failure"
    | exception Invalid_argument _ -> "invalid argument"
    | None -> "None"
    ) [@ocaml.warning "-8"] in
    assert false
  with
    Match_failure _ ->
      print_endline "match failure, as expected"
;;