Unit Compiler Testing

What is considered the best unit test approach for a complex module like a compiler?

I have written several compilers and interpreters over the years, and I really find this code quite difficult to test in a good way.

If we take something like generating an abstract syntax tree. how would you test this with TDD?

Small designs can be easily tested. for example something like:

string code = @"public class Foo {}";
AST ast = compiler.Parse(code);

Since it will not generate many ast nodes.

But if I really want to verify that the compiler can create an AST for something like a method:

[TestMethod]
public void Can_parse_integer_instance_method_in_class ()
{
   string code = @"public class Foo {  public int method(){ return 0;}}";
   AST ast = compiler.Parse(code);

? AST, , , AST , .

, TDD, ?

+5
2

, . 10% ( ++, , ), .

, TDD (, ) , , , , , . , grepping ( ? , ..). Grepping , (S-exprs XML), . , , .

+1

-, , ! , , , . , , , !

-, , . , , . , .

, , ; , . , !

, , :

  • -: , . , ; , , .
  • : , , , .. . . .
  • : , ( ), , , , . , - . . , . , .. , , , .

! , : (C-) , . :

+4

All Articles