[jboss-svn-commits] JBL Code SVN: r20116 - labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 22 19:13:41 EDT 2008


Author: mattgeis
Date: 2008-05-22 19:13:41 -0400 (Thu, 22 May 2008)
New Revision: 20116

Modified:
   labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java
   labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java
Log:
updates to test for new DSL ANTLR parsing

Modified: labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java
===================================================================
--- labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java	2008-05-22 23:06:09 UTC (rev 20115)
+++ labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DSLTokenizedMappingFileTest.java	2008-05-22 23:13:41 UTC (rev 20116)
@@ -41,7 +41,7 @@
     }
 
     public void testParseFileWithBrackets() {
-        String file = "[when][]ATTRIBUTE \"{attr}\" IS IN [{list}]=Attribute( {attr} in ({list}) )";
+        String file = "[when]ATTRIBUTE \"{attr}\" IS IN [{list}]=Attribute( {attr} in ({list}) )";
         try {
             final Reader reader = new StringReader( file );
             this.file = new DSLTokenizedMappingFile();
@@ -65,7 +65,7 @@
             assertEquals( "(\\W|^)ATTRIBUTE \"(.*?)\" IS IN [(.*?)](\\W|$)",
                           entry.getKeyPattern().toString() );
             //Attribute( {attr} in ({list}) )
-            assertEquals( "Attribute(\\s+\\$1\\s+in (\\$2) )",
+            assertEquals( "Attribute( $2 in ($3) )",
                           entry.getValuePattern() );
 
         } catch ( final IOException e ) {
@@ -75,7 +75,7 @@
     }
 
     public void testParseFileWithEscaptedBrackets() {
-        String file = "[when][]ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]=Attribute( {attr} in ({list}) )";
+        String file = "[when]ATTRIBUTE \"{attr}\" IS IN \\[{list}\\]=Attribute( {attr} in ({list}) )";
         try {
             final Reader reader = new StringReader( file );
             this.file = new DSLTokenizedMappingFile();
@@ -100,7 +100,7 @@
             assertEquals( "(\\W|^)ATTRIBUTE \"(.*?)\" IS IN \\[(.*?)\\](\\W|$)",
                           entry.getKeyPattern().toString() );
             //Attribute( {attr} in ({list}) )
-            assertEquals( "Attribute(\\s+\\$1\\s+in (\\$2) )",
+            assertEquals( "Attribute( $2 in ($3) )",
                           entry.getValuePattern() );
 
         } catch ( final IOException e ) {
@@ -111,9 +111,9 @@
     }
 
     public void testParseFileWithEscapes() {
-        String file = "[then][]TEST=System.out.println(\"DO_SOMETHING\");\n" + 
-                      "[when][]code {code1} occurs and sum of all digit not equal \\( {code2} \\+ {code3} \\)=AAAA( cd1 == {code1}, cd2 != ( {code2} + {code3} ))\n" + 
-                      "[when][]code {code1} occurs=BBBB\n";
+        String file = "[then]TEST=System.out.println(\"DO_SOMETHING\");\n" + 
+                      "[when]code {code1} occurs and sum of all digit not equal \\( {code2} \\+ {code3} \\)=AAAA( cd1 == {code1}, cd2 != ( {code2} + {code3} ))\n" + 
+                      "[when]code {code1} occurs=BBBB\n";
         try {
             final Reader reader = new StringReader( file );
             this.file = new DSLTokenizedMappingFile();
@@ -145,7 +145,7 @@
     }
 
     public void testParseFileWithEscaptedEquals() {
-        String file = "[when][]something:\\={value}=Attribute( something == \"{value}\" )";
+        String file = "[when]something:\\={value}=Attribute( something == \"{value}\" )";
         try {
             final Reader reader = new StringReader( file );
             this.file = new DSLTokenizedMappingFile();
@@ -166,9 +166,9 @@
                           entry.getSection() );
             assertEquals( DSLMappingEntry.EMPTY_METADATA,
                           entry.getMetaData() );
-            assertEquals( "something:={value}",
-                          entry.getMappingKey() );
-            assertEquals( "Attribute( something == \"{value}\" )",
+            assertEquals( "(\\W|^)something:\\=(.*?)$",
+                          entry.getKeyPattern().toString() );
+            assertEquals( "Attribute( something == \"$2\" )",
                           entry.getMappingValue() );
 
         } catch ( final IOException e ) {

Modified: labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java
===================================================================
--- labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java	2008-05-22 23:06:09 UTC (rev 20115)
+++ labs/jbossrules/branches/mattgeis/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java	2008-05-22 23:13:41 UTC (rev 20116)
@@ -17,7 +17,7 @@
     protected void setUp() throws Exception {
         final String filename = "test_metainfo.dsl";
         final Reader reader = new InputStreamReader( this.getClass().getResourceAsStream( filename ) );
-        this.file = new DSLTokenizedMappingFile();
+        this.file = new DSLMappingFile();
         this.file.parseAndLoad( reader );
         reader.close();
 
@@ -43,7 +43,7 @@
 
     
     public void testExpandParts() throws Exception {
-        DSLMappingFile file = new DSLTokenizedMappingFile();
+        DSLMappingFile file = new DSLMappingFile();
         String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
         file.parseAndLoad( new StringReader( dsl ) );
         assertEquals( 0,
@@ -56,7 +56,7 @@
     
     public void testExpandFailure() throws Exception {
 
-        DSLMappingFile file = new DSLTokenizedMappingFile();
+        DSLMappingFile file = new DSLMappingFile();
         String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
         file.parseAndLoad( new StringReader( dsl ) );
         assertEquals( 0,
@@ -82,7 +82,7 @@
 
     public void testExpandWithKeywordClashes() throws Exception {
 
-        DSLMappingFile file = new DSLTokenizedMappingFile();
+        DSLMappingFile file = new DSLMappingFile();
         String dsl = "[when]Invoke rule executor=ruleExec: RuleExecutor()\n" + "[then]Execute rule \"{id}\"=ruleExec.ExecuteSubRule( new Long({id}));";
         file.parseAndLoad( new StringReader( dsl ) );
         assertEquals( 0,
@@ -102,7 +102,7 @@
 
 
     public void testLineNumberError() throws Exception {
-        DSLMappingFile file = new DSLTokenizedMappingFile();
+        DSLMappingFile file = new DSLMappingFile();
         String dsl = "[when]foo=Foo()\n[then]bar {num}=baz({num});";
         file.parseAndLoad( new StringReader( dsl ) );
 




More information about the jboss-svn-commits mailing list