Skip to content
New issue

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

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

Already on GitHub? # to your account

Integration testing by implementing a toy language #141

Open
6 tasks
MalteJanz opened this issue Sep 16, 2022 · 3 comments
Open
6 tasks

Integration testing by implementing a toy language #141

MalteJanz opened this issue Sep 16, 2022 · 3 comments

Comments

@MalteJanz
Copy link
Contributor

MalteJanz commented Sep 16, 2022

There should be a simple toy language and toy syntax tree to test all / most of the tree api methods (traversal and accessing specific nodes / tokens).

This issue tries to improve the testing situation in rowan, so things like #139 (off-by-one-error) can be caught at an early stage and projects depending on this library don't have to find these bugs the hard way. This should also allow for easier refactoring / internal changes with the confidence, that the public api still works as expected. Also future PRs which provide bug fixes for the public API can also provide a test for it to help increase the coverage.

steps to do this (out of my head / only a suggestion for the implementation):

  • Add a test directory for the integration tests
  • Write a module toy_language inside the test directory
    • Implement all the necessary things for rowan (see examples and Make A Language Blog )
    • Instead of writing a complete lexer / parser, simply write a method build_toy_tree which uses the GreenNodeBuilder and constructs a meaningful tree by hand (which provides enough depth / siblings / ... to use for testing)
  • Confirm the toy_language tree and underlaying source string looks like expected by writing two tests for this
  • Start implementing tests for the tree traversal / accessing tree nodes API
@MalteJanz MalteJanz changed the title Integration testing by implement a toy language Integration testing by implementing a toy language Sep 16, 2022
@MalteJanz
Copy link
Contributor Author

@matklad what do you think about this?

I may want to tackle this issue in the future, especially because I rely on the tree API and would like the confidence that it works as expected (and give back a bit to this awesome crate). But first I need to make some further progress on my bachelor project, so I will ping here if I start working on it ( if anybody else want's to tackle this before me, feel free) 🙂.

I guess it would be a great benefit to have some more tests for a crate which has over 1.2 million downloads and is used in more than 2200 GitHub repos (I guess that number is maybe a bit misleading now, that rust-analyzer is inside the rust-lang repo 😅 ).

@lnicola
Copy link
Member

lnicola commented Sep 16, 2022

CC https://arzg.github.io/lang/, maybe we could lift that off as an example :-).

@MalteJanz
Copy link
Contributor Author

@lnicola That's also a nice blog / resource which also helped me a ton with my implementation / usage of rowan 👍. Maybe it can also be added to the readme of rowan as a great learning resource? 🤔

I guess an implementation like that could also be used as a "toy language" but that is maybe already too big to only test some of the tree methods 🤷‍♂️

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

No branches or pull requests

2 participants