softdevteam / grmtools

Rust grammar tool libraries and binaries
Other
494 stars 32 forks source link

Cleanup test helpers #432

Closed ratmice closed 6 months ago

ratmice commented 6 months ago

This is a cleanup for the ErrorsHelper test functions, it is primarily intended to improve the output. I.e. it should now print both the error, and the expected, when they don't match now. Previously this was difficult to do because the expected value was used in the if guard of an Err(e) if ... it could no longer be used in plain old the Err(e) branch of the match. As such, I just reorganized the implementation to make that branch unneeded.

Doing the same thing in lrlex required we add a Debug derive for LrNonStreamingLexerDef.

ratmice commented 6 months ago

It occurred to me that it would be good to add #[track_caller] to these helper functions, so that panics in the helper refer to the location in the test where the helper is called, rather than some line within the helper itself. Pretty sure that is everything for this series.

ltratt commented 6 months ago

It occurred to me that it would be good to add #[track_caller] to these helper functions

I did not know about #[track_caller]! Good idea.