raven-compiler/src/test/java/org/raven/antlr/RuleTester.java
/**
     * Tests whether the output produced by the parser matches the expected ast node
     * @param v The visitor responsible for handling the parsing rule
     * @param txt The input text
     * @param expected The expected output
     */
Tests whether the output produced by the parser matches the expected ast node
@param v The visitor responsible for handling the parsing rule
@param txt The input text
@param expected The expected output
Tests whether the output produced by the parser matches the expected ast node @param v The visitor responsible for handling the parsing rule @param txt The input text @param expected The expected output
public static void testStatement(final RavenBaseVisitor v, final String txt, final Object expected) {
        RavenLexer lexer = new RavenLexer(CharStreams.fromString(txt));
        CommonTokenStream tokenStream = new CommonTokenStream(lexer);
        RavenParser parser = new RavenParser(tokenStream);
        parser.removeErrorListener(ConsoleErrorListener.INSTANCE);
        Object stmt;
        if (expected instanceof Range) {
            stmt = v.visit(parser.range());
        } else if (expected instanceof Import) {
            stmt = v.visit(parser.importStatement());
        } else if (expected instanceof Expression) {
            stmt = v.visit(parser.expression());
        } else if (v instanceof ParamDefVisitor) {
            stmt = v.visit(parser.paramDef());
        } else if (v instanceof InheritanceVisitor) {
            stmt = v.visitInheritance(parser.inheritance());
        } else {
            stmt = (Statement) v.visit(parser.statement());
        }
        assertEquals(expected, stmt);
    }
public static void testStatement ( final RavenBaseVisitor v , final String txt , final Object expected ) { RavenLexer lexer = new RavenLexer ( CharStreams . fromString ( txt ) ) ; CommonTokenStream tokenStream = new CommonTokenStream ( lexer ) ; RavenParser parser = new RavenParser ( tokenStream ) ; parser . removeErrorListener ( ConsoleErrorListener . INSTANCE ) ; Object stmt ; if ( expected instanceof Range ) { stmt = v . visit ( parser . range ( ) ) ; } else if ( expected instanceof Import ) { stmt = v . visit ( parser . importStatement ( ) ) ; } else if ( expected instanceof Expression ) { stmt = v . visit ( parser . expression ( ) ) ; } else if ( v instanceof ParamDefVisitor ) { stmt = v . visit ( parser . paramDef ( ) ) ; } else if ( v instanceof InheritanceVisitor ) { stmt = v . visitInheritance ( parser . inheritance ( ) ) ; } else { stmt = ( Statement ) v . visit ( parser . statement ( ) ) ; } assertEquals ( expected , stmt ) ; }
Tests whether the output produced by the parser matches the expected ast node
 @param v The visitor responsible for handling the parsing rule
 @param txt The input text
 @param expected The expected output
Tests whether the output produced by the parser matches the expected ast node @param v The visitor responsible for handling the parsing rule @param txt The input text @param expected The expected output