rescript-core icon indicating copy to clipboard operation
rescript-core copied to clipboard

Runtime tests using examples from docstrings

Open aspeddro opened this issue 1 year ago • 3 comments

This PR is a proposal to add unit tests using docstrings. Currently the examples from docstrings have tests for compilation only.

  • bsc emits the Js and passes the code to node using the --eval|-e argument.

image

TODO:

  • [x] Fix examples
  • [x] Remove examples with infinite loop, setIntervalFloat
  • [x] Update CHANGELOG

Changes

  • Added assert_eq function
  • Runtime errors captured
  • Removed some examples with infinite loop at src/Core__Global.resi
  • Removed Array from the test suite and moved it to docstrings.

DocTest script

  • Added argument --ignore-runtime-tests
    • --ignore-runtime-tests 'RescriptCore.Array.toReversed,RescriptCore.Promise.withResolvers'. Array.toReversed and Promise.withResolvers are not supported by Node

aspeddro avatar Apr 07 '24 22:04 aspeddro

Ready for review

aspeddro avatar Apr 24 '24 02:04 aspeddro

I made a small improvement in two examples in the Null and Nullable module

aspeddro avatar Jun 04 '24 21:06 aspeddro

@zth what do you think?

fhammerschmidt avatar Jun 08 '24 06:06 fhammerschmidt