I'm writing a language parser here: https://github.com/davesque/rust-vyper/blob/master/parser/src/parsers.rs
Here's an example of some complex expected results which are defined with large struct literals: https://github.com/davesque/rust-vyper/blob/master/parser/tests/test_parsers.rs#L270-L302
My question is, how can I avoid typing out large struct literals in tests for functionality of the sort found in these parsers?
I had the idea of deriving serialization behavior using
serde_json for the relevant structs and then testing against an expected serialization. That way, I thought the representation of the desired output might be easier to visually parse in certain cases and it would be easier to figure out why tests are breaking if I did a line diff of conflicting serializations. But this approach feels kinda hacky and it seems to assume that serialzation will always happen in a consistent way which may not be the case.
Anyone have any other ideas?