Search in sources :

Example 6 with DRLParser

use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.

the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_END6.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END6() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( property > 0 && < 10 ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 7 with DRLParser

use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.

the class DRLContextTest method testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3.

@Test(timeout = 10 * 1000)
public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3() {
    String input = "rule MyRule \n" + "	when \n" + "		Class ( name : property <= ";
    DRLParser parser = getParser(input);
    parser.enableEditorInterface();
    try {
        parser.compilationUnit();
    } catch (Exception ex) {
    }
    assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, getLastIntegerValue(parser.getEditorInterface().get(0).getContent()));
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) DroolsParserException(org.drools.drl.parser.DroolsParserException) RecognitionException(org.antlr.runtime.RecognitionException) Test(org.junit.Test)

Example 8 with DRLParser

use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.

the class ErrorsParserTest method testPackageGarbage.

@Test
public void testPackageGarbage() throws Exception {
    DRLParser parser = parseResource("package_garbage.drl");
    parser.compilationUnit();
    assertTrue(parser.hasErrors());
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) Test(org.junit.Test)

Example 9 with DRLParser

use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.

the class ErrorsParserTest method testLexicalError.

@Test
public void testLexicalError() throws Exception {
    DRLParser parser = parseResource("lex_error.drl");
    parser.compilationUnit();
    assertTrue(parser.hasErrors());
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) Test(org.junit.Test)

Example 10 with DRLParser

use of org.drools.drl.parser.lang.DRLParser in project drools by kiegroup.

the class ErrorsParserTest method testEvalWithSemicolon.

@Test
public void testEvalWithSemicolon() throws Exception {
    DRLParser parser = parseResource("eval_with_semicolon.drl");
    parser.compilationUnit();
    assertTrue(parser.hasErrors());
    assertEquals(1, parser.getErrorMessages().size());
    assertEquals("ERR 102", parser.getErrors().get(0).getErrorCode());
}
Also used : DRLParser(org.drools.drl.parser.lang.DRLParser) Test(org.junit.Test)

Aggregations

DRLParser (org.drools.drl.parser.lang.DRLParser)200 Test (org.junit.Test)197 DroolsParserException (org.drools.drl.parser.DroolsParserException)187 RecognitionException (org.antlr.runtime.RecognitionException)186 DroolsToken (org.drools.drl.parser.lang.DroolsToken)6 Ignore (org.junit.Ignore)2 LinkedList (java.util.LinkedList)1 Token (org.antlr.runtime.Token)1 InternalResource (org.drools.core.io.internal.InternalResource)1 Expander (org.drools.drl.parser.lang.Expander)1 DefaultExpander (org.drools.drl.parser.lang.dsl.DefaultExpander)1