assert-tokenstreams-eq
A utility for comparing token streams in tests. It applies rustfmt to the
token streams to ensure consistent formatting and leverages pretty_assertions
to clearly visualize differences when the assertion fails.
Usage
Add this to your Cargo.toml:
[]
= "0.1"
= "1.0"
Then use the macro in your tests:
use assert_tokenstreams_eq;
use quote;
How It Works
- Both token streams are formatted using
rustfmt. This handles differences in whitespace, indentation, and equivalent syntax. - The formatted strings are compared.
- If they differ,
pretty_assertionsprints a colorful diff showing exactly where the mismatch occurred.
Prerequisites
This crate relies on rustfmt being installed and available in your path.