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.
Simplify testing for locations in error messages. Currently we write
but we should instead write something like
The new
withErrorAt
method scans the source string for$
, removes the$
, and sets the error location to where it was (line 1, column 13). TheassertParseThrowsParseException
method now accepts aFunction<String, Matcher<String>>
, and the first argument is the error location.