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

Improve maintainability of parsing tests #50

Closed
jclark opened this issue Jun 14, 2021 · 2 comments
Closed

Improve maintainability of parsing tests #50

jclark opened this issue Jun 14, 2021 · 2 comments
Assignees
Projects
Milestone

Comments

@jclark
Copy link
Contributor

jclark commented Jun 14, 2021

The parsing tests should be designed in a way that when the AST data structure is changed, it is only a little work to get the tests working.

@jclark
Copy link
Contributor Author

jclark commented Jun 14, 2021

Some thoughts on how to do this:

  • expected output should be in .json files, so they can easily be edited
  • the AST should be transformed into a JSON format: the tests should work by comparing the expected and actual results in this format
  • the JSON format should not be the same as the AST format; the AST format has design decisions that may change; instead it should be a neutral tuple-based format e.g. an addition can be represented by ["+", L, R].
  • positions should not be in the JSON format: it is not practical to verify that they are correct by hand; alternative ways should be found to check position information
    • first of all check that the tokenizer is giving the right positions (since tokens are literal strings, this should be easy)
    • then check that the position of each node in the AST corresponds to a token of the right type (i.e. an addition should correspond to a "+" token)

@jclark
Copy link
Contributor Author

jclark commented Jun 14, 2021

Note that with this approach, parsing tests can be shared with jBallerina.

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

No branches or pull requests

3 participants