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"]
;;
|