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

Syntactic tests #19

Open
justinmchase opened this issue Nov 12, 2022 · 0 comments
Open

Syntactic tests #19

justinmchase opened this issue Nov 12, 2022 · 0 comments
Milestone

Comments

@justinmchase
Copy link
Owner

justinmchase commented Nov 12, 2022

The language should support a syntactic method for writing tests in the same file as the patterns. I'm not totally sure how this should be, will require some research.

Initial thoughts:

  • use --- to separate code from tests, multiple --- indicates multiple tests
  • test blocks are just object property declarations, where the properties are the shape of a test object
  • or maybe its just yaml?
  • The test just runs the pattern with the given input, deep equals it to the expected output
  • The test object may have some other fields to describe expectations like:
    • throws?: boolean | Pattern
    • matched?: boolean
    • done?: boolean
    • errors?: MachError[]
Letter = "a"-"z"
Main = Letter+
---
input: abc
expected: abc
---
input: abc1
expected: abc
matched: true
done: false
@justinmchase justinmchase added this to the MVP milestone Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant