mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-05 19:00:31 -05:00
a test to ensure chars1_if p = take1_if p >|= Slice.to_string
This commit is contained in:
parent
e06cd516f0
commit
b8fa400465
2 changed files with 14 additions and 0 deletions
|
|
@ -512,6 +512,19 @@ let chars1_if ?descr p = {
|
|||
~err
|
||||
}
|
||||
|
||||
(*$QR
|
||||
Q.(printable_string) (fun s ->
|
||||
let pred = (function 'a'..'z' | 'A' .. 'Z' | '{' | '}' -> true | _ -> false) in
|
||||
let p1 = chars1_if pred in
|
||||
let p2 = take1_if pred >|= Slice.to_string in
|
||||
parse_string p1 s = parse_string p2 s)
|
||||
*)
|
||||
|
||||
(*$T
|
||||
let pred = (function 'a'..'z' | 'A' .. 'Z' | '{' | '}' -> true | _ -> false) in \
|
||||
parse_string (chars_if pred) "coucou{lol} 123" = Ok "coucou{lol}"
|
||||
*)
|
||||
|
||||
exception Fold_fail of state * string
|
||||
|
||||
let chars_fold ~f acc0 = {
|
||||
|
|
|
|||
|
|
@ -318,6 +318,7 @@ val chars_if : (char -> bool) -> string t
|
|||
val chars1_if : ?descr:string -> (char -> bool) -> string t
|
||||
(** Like {!chars_if}, but accepts only non-empty strings.
|
||||
[chars1_if p] fails if the string accepted by [chars_if p] is empty.
|
||||
[chars1_if p] is equivalent to [take1_if p >|= Slice.to_string].
|
||||
@param descr describes what kind of character was expected, in case of error *)
|
||||
|
||||
val endline : char t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue