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

Consider dedicated syntax for unit tests #12

Open
kgutwin opened this issue Feb 17, 2022 · 1 comment
Open

Consider dedicated syntax for unit tests #12

kgutwin opened this issue Feb 17, 2022 · 1 comment
Labels
enhancement New feature or request syntax Concerning the Melody language syntax

Comments

@kgutwin
Copy link

kgutwin commented Feb 17, 2022

Imagine something like this:

some of <word>;
<space>;
capture {
  1 to 9;
  2 of <digit>;
}

should match "Econ 101" capturing "101";
should not match "305";
should not match "Physics 022"

If you have the ability to embed tiny unit tests in your regex declaration, then this could substantially help both to catch regressions and to document the intent behind the regex. The unit tests would be run at compile time, raising something akin to a syntax error if they fail (with clear output as to why they failed, to make it easier to fix).

@yoav-lavi
Copy link
Owner

yoav-lavi commented Feb 18, 2022

Thank you for the suggestion!

Will consider adding this, seems like it could be useful but it introduces regex execution during compilation so I'll need to think how it'll fit. Possibly a flag that would run these rather than output a regex + ignoring them on normal compilation.

Leaving open for now

@yoav-lavi yoav-lavi added syntax Concerning the Melody language syntax enhancement New feature or request labels Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request syntax Concerning the Melody language syntax
Projects
None yet
Development

No branches or pull requests

3 participants
@kgutwin @yoav-lavi and others