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

Simplify testing for locations in error messages #214

Open
julianhyde opened this issue Jan 15, 2024 · 0 comments
Open

Simplify testing for locations in error messages #214

julianhyde opened this issue Jan 15, 2024 · 0 comments

Comments

@julianhyde
Copy link
Collaborator

Simplify testing for locations in error messages. Currently we write

ml("from {x, y} group")
    .assertParseThrowsParseException(
        startsWith("Encountered \" \"group\" \"group \"\" at line 1, column 13."));

but we should instead write something like

ml("from {x, y} $group")
    .withErrorAt('$')
    .assertParseThrowsParseException(loc ->
        startsWith("Encountered \" \"group\" \"group \"\" at " + loc + "."));

The new withErrorAt method scans the source string for $, removes the $, and sets the error location to where it was (line 1, column 13). The assertParseThrowsParseException method now accepts a Function<String, Matcher<String>>, and the first argument is the error location.

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

No branches or pull requests

1 participant