Add support of relative line numbers to `//MATCH`
Is your feature request related to a problem? Please describe.
When writing test-cases where with more than one // MATCH per line, developer need to use absolute line numbers like this: // MATCH:30, // MATCH:31.
This makes test code harder to modify and support because every change to code above MATCH: needs recalculation of absolute line-numbers.
Describe the solution you'd like
Add support of new MATCH syntax with relative line numbers: MATCH:[-1], MATCH:[+1]. With this syntax, test will look for a message on the previous or the following line of "match" message. More verbose alternative could be MATCH:[@LINE - 1], MATCH:[@LINE + 1].
Additional context
Other test-framework for linters use it, e.g like this.
It's great, because I had the exact same idea when I saw your PR.
I'm unsure about the format, but I'm convinced about the feature
I'm unsure about the format, but I'm convinced about the feature
I lean towards verbose format.
Little formal description of how I see parsing:
When we have [] after MATCH: it means "evaluation" context inside []. In "evaluation" @line or @LINE will be current line of the MATCH (possible more macros with @ in the future). Inside [] we can add (+) or subtract (-) a number of lines (possible more operations in the future).
For records, I worked on the file that handles the test suites you want to improve
It's for something different, but you could be interested.
- #1431