Reputation: 725
I have a javacc file which I'm trying to write unit tests for. Is it more effective to make unit tests for the .jj file or for the java files the jj file produces when it is compiled. I know this was asked here, but a lot of the links on the answer are dead. Any help, tips are appreciated!
Upvotes: 1
Views: 182
Reputation: 16241
I've developed a framework for testing compilers that might be of use. Each test is a file to be parsed which contains (as comments) the expected result. See http://www.engr.mun.ca/~theo/Publications/compiler-testing.pdf for details. I can send you the code for the testing framework, if you'd like.
To your specific question, I'm not sure how you could go about testing the .jj file directly. The only option I see is to test the generated lexer and parser to see if they behave as desired. Of course that assumes that someone has regenerated the .java files since the last change to the .jj file.
Upvotes: 1