My previous post did not receive any replies so I thought I might try
generalizing the problem a bit...
Suppose I'm parsing a language into a syntax tree and then
transforming that tree into another AST representing a core
language. The core language is a more general AST that should help
Without looking into your language and transformation in more detail
it's hard to come up with concrete suggestions. But here are some
anyway:
Write an interpreter for each of your languages (original AST,
transformed AST) etc, and then use a quickcheck property stating that
well formed
Additionally, as a safety net, you might want to type-check the code
that's being produced by your Arbitrary instances and state some
invariants on your code. Also, you'll likely want to limit your
number of evaluation steps if your language allows non-terminating
programs.
In any case,
Hi
My experience is that generating correct AST's is hard to get right.
I've found regression testing to be more useful when doing program
transformation.
I would follow Lennarts solution of writing a function that
semantically evaluates each expression. I would then add a bit into
your program