Description
Try to generate tests for the following class, set timeout at least to 60s.
importorg.antlr.runtime.tree.TreeVisitor;
importorg.antlr.runtime.tree.TreeVisitorAction;
importorg.antlr.v4.parse.GrammarASTAdaptor;
importorg.antlr.v4.tool.ast.GrammarAST;
publicclassGrammarin {
publicvoidsetGrammarPtr(finalorg.antlr.v4.tool.Grammarg, GrammarASTtree) {
if (tree != null) {
TreeVisitorv = newTreeVisitor(newGrammarASTAdaptor());
v.visit(tree, newTreeVisitorAction() {
publicObjectpre(Objectt) {
((GrammarAST) t).g = g;
returnt;
}
publicObjectpost(Objectt) {
returnt;
}
});
}
}
}The following code i generated:
@Test@DisplayName("setGrammarPtr: -> tree != null : True")
publicvoidtestSetGrammarPtr_TreeNotEqualsNull_2() throwsClassNotFoundException, NoSuchFieldException, IllegalAccessException {
Grammaringrammarin = newGrammarin();
GrammarRootASTtree = newGrammarRootAST(null);
tree.token = null;
ClassbaseTreeClazz = Class.forName("org.antlr.runtime.tree.BaseTree");
FieldchildrenField = baseTreeClazz.getDeclaredField("children");
childrenField.setAccessible(true);
childrenField.get(tree) = newArrayList();
grammarin.setGrammarPtr(null, tree);
}Line with getter leads to the compilation error
childrenField.get(tree) = new ArrayList(); - variable expected
Description
Try to generate tests for the following class, set timeout at least to 60s.
The following code i generated:
Line with getter leads to the compilation error