File: trailing_in_module.ml.corrected.expected

package info (click to toggle)
ppx-expect 0.17.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 948 kB
  • sloc: ml: 3,399; ansic: 104; javascript: 19; makefile: 15; sh: 2
file content (36 lines) | stat: -rw-r--r-- 763 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
open! Core

module M (X : Sexpable) = struct
  module N (Y : sig
      val x : X.t
    end) =
  struct
    let%expect_test "trailing output" =
      let sexp = X.sexp_of_t Y.x in
      print_s sexp;
      [%expect
        {|
         "a\
        \nb\
        \nc"
        |}]
    ;;

    let%expect_test "error" =
      if String.length (string_of_sexp (X.sexp_of_t Y.x)) > 1
      then raise_s (Base.Sexp.message "sexp is too long" [ "input: ", X.sexp_of_t Y.x ])
    [@@expect.uncaught_exn
      {|
      ("sexp is too long" ("input: "  "a\
                                     \nb\
                                     \nc"))
      |}]
    ;;
  end
end

module String_tests = M (String)

module Run_on_abc = String_tests.N (struct
    let x = "a\nb\nc"
  end)