Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime tests using examples from docstrings #210

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

aspeddro
Copy link
Contributor

@aspeddro aspeddro commented Apr 7, 2024

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:

  • Fix examples
  • Remove examples with infinite loop, setIntervalFloat
  • 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 aspeddro changed the title PoC: Runtime tests using examples from docstrings Runtime tests using examples from docstrings Apr 8, 2024
@aspeddro
Copy link
Contributor Author

Ready for review

Copy link
Member

@fhammerschmidt fhammerschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really nice work, some of the examples could be a bit more beginner-friendly but I know that is very hard to do without making them untestable.

@aspeddro aspeddro requested a review from fhammerschmidt June 4, 2024 21:29
@aspeddro
Copy link
Contributor Author

aspeddro commented Jun 4, 2024

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

@fhammerschmidt
Copy link
Member

@zth what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants