[jboss-svn-commits] JBL Code SVN: r20289 - labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jun 4 07:33:14 EDT 2008


Author: porcelli
Date: 2008-06-04 07:33:14 -0400 (Wed, 04 Jun 2008)
New Revision: 20289

Modified:
   labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java
Log:
New tests to prevent bugs... The new tests checks for dialect statement and the eval sentence inside a OrDescr.

Modified: labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java
===================================================================
--- labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java	2008-06-04 10:17:35 UTC (rev 20288)
+++ labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java	2008-06-04 11:33:14 UTC (rev 20289)
@@ -122,7 +122,23 @@
         assertEquals( source.indexOf( "import " + impdescr.getTarget() ) + ("import " + impdescr.getTarget()).length() - 1,
                       impdescr.getEndCharacter() );
     }
+    
+    public void testDialect() throws Exception {
+        final String source = "dialect 'mvel'";
+        parse("compilation_unit","compilation_unit", source );
+        AttributeDescr attr = (AttributeDescr) this.walker.getPackageDescr().getAttributes().get(0);
+        assertEquals( "dialect", attr.getName() );
+        assertEquals( "mvel", attr.getValue() );
+    }
 
+    public void testDialect2() throws Exception {
+        final String source = "dialect \"mvel\"";
+        parse("compilation_unit","compilation_unit", source );
+        AttributeDescr attr = (AttributeDescr) this.walker.getPackageDescr().getAttributes().get(0);
+        assertEquals( "dialect", attr.getName() );
+        assertEquals( "mvel", attr.getValue() );
+    }
+
     public void testEmptyRule() throws Exception {
         final RuleDescr rule = (RuleDescr) parseResource("rule", "rule", "empty_rule.drl" );
 
@@ -134,16 +150,16 @@
         assertNotNull( rule.getConsequence() );
     }
 
-//    //FIXME Keywords END and THEN should not be used as identifiers: try to enable it
-//    public void testKeywordCollisions() throws Exception {
-//        parseResource("compilation_unit","compilation_unit", "eol_funny_business.drl" );
-//
-//        final PackageDescr pkg = walker.getPackageDescr();
-//
-//        assertEquals( 1,
-//                      pkg.getRules().size() );
-//    }
+    //FIXME Keywords END and THEN should not be used as identifiers: try to enable it
+    public void FIXME_testKeywordCollisions() throws Exception {
+        parseResource("compilation_unit","compilation_unit", "eol_funny_business.drl" );
 
+        final PackageDescr pkg = walker.getPackageDescr();
+
+        assertEquals( 1,
+                      pkg.getRules().size() );
+    }
+
     
     public void testTemplates() throws Exception {
 
@@ -2454,6 +2470,20 @@
 
     }
 
+    public void testCheckOrDescr() throws Exception {
+        final String text = "Person( eval( age == 25 ) || ( eval( name.equals( \"bob\" ) ) && eval( age == 30 ) ) )";
+        PatternDescr pattern = (PatternDescr) parse("lhs_pattern", "lhs_pattern", text);
+
+        assertEquals( 1,
+                      pattern.getDescrs().size() );
+        assertEquals(pattern.getConstraint().getClass(), org.drools.lang.descr.AndDescr.class);
+
+        assertEquals(pattern.getConstraint().getDescrs().get(0).getClass(), org.drools.lang.descr.OrDescr.class);
+
+        OrDescr orDescr = (OrDescr) pattern.getConstraint().getDescrs().get(0);
+        assertEquals(orDescr.getDescrs().get(0).getClass(), org.drools.lang.descr.PredicateDescr.class);
+    }
+
     public void testConstraintAndConnective() throws Exception {
         final String text = "Person( age < 42 && location==\"atlanta\")";
         PatternDescr pattern = (PatternDescr) parse("lhs_pattern", "lhs_pattern", text);




More information about the jboss-svn-commits mailing list