bugfix; more tests

This commit is contained in:
Simon Cruanes 2014-06-28 04:01:18 +02:00
parent 735a11e5ec
commit d36e8dd38e
2 changed files with 7 additions and 6 deletions

View file

@ -92,7 +92,7 @@ module Split = struct
and _split_search ~by s prev i =
if i >= String.length s
then Some (SplitStop, prev, String.length s - prev)
else if _is_prefix ~by s i 0 && i>prev
else if _is_prefix ~by s i 0
then Some (SplitAt (i+String.length by), prev, i-prev)
else _split_search ~by s prev (i+1)
@ -142,11 +142,6 @@ module Split = struct
let seq ~by s = _mkseq ~by s _tuple3
let seq_cpy ~by s = _mkseq ~by s String.sub
(*$T
Split.list_cpy ~by:"," "aa,bb,cc" = ["aa"; "bb"; "cc"]
Split.list_cpy ~by:"--" "a--b----c--" = ["a"; "b"; ""; "c"; ""]
*)
end
(* note: inefficient *)

View file

@ -111,6 +111,12 @@ module Split : sig
val list_cpy : by:t -> t -> t list
(*$T
Split.list_cpy ~by:"," "aa,bb,cc" = ["aa"; "bb"; "cc"]
Split.list_cpy ~by:"--" "a--b----c--" = ["a"; "b"; ""; "c"; ""]
Split.list_cpy ~by:" " "hello world aie" = ["hello"; ""; "world"; "aie"]
*)
val gen_cpy : by:t -> t -> t gen
val seq_cpy : by:t -> t -> t sequence