package vcaml

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file test_error_reporting.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(* The tests in this file demonstrate VCaml's own guarantees about how it behaves. *)
open Core
open Async
open Vcaml
open Vcaml_test_helpers

let%expect_test "Error in the middle of an atomic call is returned correctly" =
  Backtrace.elide := true;
  let%bind () =
    Expect_test_helpers_async.require_does_raise_async [%here] (fun () ->
      with_client (fun client ->
        let open Deferred.Or_error.Let_syntax in
        let get name = Nvim.get_var name ~type_:Boolean in
        let set name value = Nvim.set_var name ~type_:Boolean ~value in
        let%map foo, bar, baz =
          run_join
            [%here]
            client
            (let open Api_call.Or_error.Let_syntax in
             let%map () = set "foo" true
             and () = set "baz" true
             and foo = get "foo"
             and bar = get "bar"
             and baz = get "baz" in
             foo, bar, baz)
        in
        print_s [%message "" (foo : bool) (bar : bool) (baz : bool)]))
  in
  [%expect
    {|
    (("Called from" lib/vcaml/test/semantics/test_error_reporting.ml:LINE:COL)
     (("Vim returned error" "Key not found: bar" (error_type Validation))
      (index 3))) |}];
  Backtrace.elide := false;
  return ()
;;
OCaml

Innovation. Community. Security.