I go straight to having examples/ with a ton of little test cases, and check the output stdout and stderr to see whether it went pear shaped.
It's an end to end test harness of sorts.
If you care about locking down your AST and IR output, I'd recommend having a printer of sort to stdout and check against that, like a sha-1 or expected output.txt to compare against, see example [1]
You can try creating an interpreter for the AST and other IR forms you use. This can also free you from testing for specific generated ASTs and IR, so long as they're equivalent (when executed will produce the same results). This will be more helpful once you start with things like adding in optimization passes.
Honestly, I think the biggest win is just having a solid test harness that can compare AST snapshots across versions. It’s not glamorous, but it catches regressions early and gives you confidence when you refactor the optimizer. Maybe throw in some fuzzing on the AST nodes and see what breaks – it’s surprisingly fun.
I go straight to having examples/ with a ton of little test cases, and check the output stdout and stderr to see whether it went pear shaped.
It's an end to end test harness of sorts.
If you care about locking down your AST and IR output, I'd recommend having a printer of sort to stdout and check against that, like a sha-1 or expected output.txt to compare against, see example [1]
[1] https://pastebin.com/ZA6CKwPZ
You can try creating an interpreter for the AST and other IR forms you use. This can also free you from testing for specific generated ASTs and IR, so long as they're equivalent (when executed will produce the same results). This will be more helpful once you start with things like adding in optimization passes.
Honestly, I think the biggest win is just having a solid test harness that can compare AST snapshots across versions. It’s not glamorous, but it catches regressions early and gives you confidence when you refactor the optimizer. Maybe throw in some fuzzing on the AST nodes and see what breaks – it’s surprisingly fun.