bloodyowl / rescript-test

A lightweight test framework for ReScript
https://bloodyowl.github.io/rescript-test/
MIT License
78 stars 9 forks source link

feature: Add assertionWithLazyOperator #18

Open hamza0867 opened 5 months ago

hamza0867 commented 5 months ago

Closes #17

bloodyowl commented 5 months ago

the operator parameter is just the string description of the the operator, in what case is it heavy to compute?

hamza0867 commented 5 months ago

the operator parameter is just the string description of the the operator, in what case is it heavy to compute?

The thing is, the operator is shown in case of error, which can be used to display custom error messages, those error messages can be heavy to compute. For example when we want to display some formatted message that is generated by going through some deep tree and collecting data from the tree.

TheSpyder commented 5 months ago

For context, we're replacing some ounit2 code, there the assertion can include both a string message and a printer function. https://dsheets.github.io/codoc/ounit.2.0.0/_build/src/oUnit2/index.html#/val:assert_equal

We use the printer function because we are working with a document model; the simple object diff doesn't provide enough context for changes deep in the tree. In the absence of a printer function, we have to render those details into the string description which can be expensive.

Would you rather we add an assertion with a printer function?