Skip to content

Testing framework: separate `Test.log` into printing and string conversion

E. Rivas requested to merge er433/test/print+to_string into dev

type:added

For LIGO developers

The primitive Test.log is used to print in the console from the testing framework. However, this function does more than one thing: it converts a value to a string and it also prints the obtained string.

This MR separates these two functionalities. It also adds a way of calling OCaml's Scanf.unescape (but it's not exposed to the user), which allows to get strings from a nat [0, 255].

Changelog details:

New functions: Test.print, Test.println, Test.eprint, Test.to_string, Test.nl and Test.chr

These new functions provide more fine-grained printing.

val Test.print : string -> unit : prints an string to stdout.

val Test.println : string -> unit : prints an string to stdout, adding a newline at the end.

val Test.eprint : string -> unit : prints an string to stderr.

val Test.to_string : 'a -> string : turns a value of a given type into a string (internally using the same conversion as Test.log)

val Test.nl : string : a string containing only a newline.

Test.chr : nat -> string option : turns a nat in the range [0, 255] to an string consisting of only the corresponding char.

Edited by E. Rivas

Merge request reports