File: space_nine.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 (43 lines) | stat: -rw-r--r-- 1,358 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
37
38
39
40
41
42
43
(*
   Demonstate use of [%expect]
   to match a single line of text with 0|1|2 leading & trailing NLs.
   The text begins with a single space.

   Starting with..

   {[
     let%expect_test _ =
       print_string " hello";          [%expect{||}];
       print_string " hello\n";        [%expect{||}];
       print_string " hello\n\n";      [%expect{||}];
       print_string "\n hello";        [%expect{||}];
       print_string "\n hello\n";      [%expect{||}];
       print_string "\n hello\n\n";    [%expect{||}];
       print_string "\n\n hello";      [%expect{||}];
       print_string "\n\n hello\n";    [%expect{||}];
       print_string "\n\n hello\n\n";  [%expect{||}];
     ;;
   ]}

   Generate with [cp space_nine.ml.corrected space_nine.ml] the following [%expect]... *)

let%expect_test _ =
  print_string " hello";
  [%expect_exact " hello"];
  print_string " hello\n";
  [%expect_exact " hello\n"];
  print_string " hello\n\n";
  [%expect_exact " hello\n\n"];
  print_string "\n hello";
  [%expect_exact "\n hello"];
  print_string "\n hello\n";
  [%expect_exact "\n hello\n"];
  print_string "\n hello\n\n";
  [%expect_exact "\n hello\n\n"];
  print_string "\n\n hello";
  [%expect_exact "\n\n hello"];
  print_string "\n\n hello\n";
  [%expect_exact "\n\n hello\n"];
  print_string "\n\n hello\n\n";
  [%expect_exact "\n\n hello\n\n"]
;;