File: test_output.ml

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 (24 lines) | stat: -rw-r--r-- 736 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
let%expect_test "expect.output" =
  Printf.printf "hello\n";
  let output = [%expect.output] in
  Printf.printf "'%s'\n" (String.uppercase_ascii output);
  [%expect {|
    'HELLO
    '
    |}];
  Printf.printf "string without line break";
  let output = [%expect.output] in
  Printf.printf "%s\n" (String.uppercase_ascii output);
  [%expect {| STRING WITHOUT LINE BREAK |}]
;;

let%expect_test "Ensure repeated expect.outputs clean up in-betweeen" =
  Printf.printf "first";
  let output1 = [%expect.output] in
  Printf.printf "second";
  let output2 = [%expect.output] in
  Printf.printf "%s" (String.uppercase_ascii output2);
  [%expect {| SECOND |}];
  Printf.printf "%s" (String.uppercase_ascii output1);
  [%expect {| FIRST |}]
;;