mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 19:25:28 -05:00
fix(pp): slicing needs attention
This commit is contained in:
parent
94640e9efe
commit
679534597d
2 changed files with 9 additions and 4 deletions
|
|
@ -89,10 +89,10 @@ let split_text_ (str : string) : t =
|
||||||
match String.index_from str !i '\n' with
|
match String.index_from str !i '\n' with
|
||||||
| exception Not_found ->
|
| exception Not_found ->
|
||||||
(* last chunk *)
|
(* last chunk *)
|
||||||
if !i + 1 < len then cur := !cur ^ text_sub_ str !i (len - 1 - !i);
|
if !i + 1 < len then cur := !cur ^ text_sub_ str !i (len - !i);
|
||||||
i := len
|
i := len
|
||||||
| j ->
|
| j ->
|
||||||
cur := !cur ^ text_sub_ str !i (j - 1 - !i) ^ nl;
|
cur := !cur ^ text_sub_ str !i (j - !i) ^ nl;
|
||||||
i := j + 1
|
i := j + 1
|
||||||
done;
|
done;
|
||||||
group !cur
|
group !cur
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,11 @@ let spf = Printf.sprintf
|
||||||
let () =
|
let () =
|
||||||
eq "hello world" (Flatten.to_string @@ text "hello" ^ newline ^ text "world")
|
eq "hello world" (Flatten.to_string @@ text "hello" ^ newline ^ text "world")
|
||||||
|
|
||||||
|
let () =
|
||||||
|
eq ~name:"split text" ~printer:(spf "%S") "let rec f x =\n x+2\n"
|
||||||
|
(let d = text "let rec f x =\n x+2\n" in
|
||||||
|
Pretty.to_string ~width:15 d)
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
eq ~name:"l1" ~printer:(spf "%S") "[0; 1; 2; 3;\n 4; 5; 6; 7;\n 8; 9]"
|
eq ~name:"l1" ~printer:(spf "%S") "[0; 1; 2; 3;\n 4; 5; 6; 7;\n 8; 9]"
|
||||||
(let d = Dump.list (List.init 10 int) in
|
(let d = Dump.list (List.init 10 int) in
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue