package tezt
Install
Dune Dependency
Authors
Maintainers
Sources
md5=643f48378265ae18b7aab4675a1e836e
sha512=f399d4d8b935fc3dcb4354596c2b7fa26a019f99c83cb4c1d48b0e26c5bc6da13b2cad9792dd50420a88b777d3b8a1d67c7ddd0457322e65d311b859be03879f
doc/tezt.core/Tezt_core/Base/index.html
Module Tezt_core.Base
Source
Base functions.
Strings
Same as Filename.concat
.
Concurrency Monad
Same as Lwt.both
, but immediately propagate exceptions.
More precisely, if one of the two promises is rejected or canceled, cancel the other promise and reject the resulting promise immediately with the original exception.
Get the value of an option that must not be None
.
Usage: mandatory name option
name
is used in the error message if option
is None
.
Lists
Make a list of all integers between two integers.
If the first argument a
is greater than the second argument b
, return the empty list. Otherwise, returns the list a; ...; b
.
Backport of List.find_map
from OCaml 4.10.
take n l
returns the first n
elements of l
if longer than n
, else l
itself.
drop n l
removes the first n
elements of l
if longer than n
, else the empty list. Raise invalid_arg
if n
is negative.
Split a list based on a predicate.
span f l
returns a pair of lists (l1, l2)
, where l1
is the longest prefix of l
that satisfies the predicate f
, and l2
is the rest of the list. The order of the elements in the input list is preserved such that l = l1 @ l2
.
Regular Expressions
Compiled regular expressions.
Compile a regular expression using Perl syntax.
Same as rex @@ sf ...
.
Test whether a string matches a regular expression.
Example: "number 1234 matches" =~ rex "\\d+"
Match a regular expression with two capture groups.
Match a regular expression with three capture groups.
Match a regular expression with four capture groups.
Match a regular expression with one capture group and return all results.
val replace_string :
?pos:int ->
?len:int ->
?all:bool ->
rex ->
by:string ->
string ->
string
replace_string ~all rex ~by s
iterates on s
, and replaces every occurrence of rex
with by
. If all = false
, then only the first occurrence of rex
is replaced.
Promises
Repeat something a given amount of times.
Input/Output
Open file, use function to write output then close the output. In case of error while writing, the channel is closed before raising the exception
Open file, use function to read input then close the input. In case of error while reading, the channel is closed before raising the exception *
Write a string into a file, overwriting the file if it already exists.
Usage: write_file filename ~contents
Read the whole contents of a file.
Common structures
Environment
Path to the root of the project.
This is DUNE_SOURCEROOT
is defined, PWD
otherwise.