[jboss-svn-commits] JBL Code SVN: r19746 - 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
Mon Apr 28 13:06:14 EDT 2008
Author: porcelli
Date: 2008-04-28 13:06:14 -0400 (Mon, 28 Apr 2008)
New Revision: 19746
Added:
labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/TestNewDRL.java
labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/gUnitTest.testsuite
Log:
Tests for the new DRL parser.
Added: labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/TestNewDRL.java
===================================================================
--- labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/TestNewDRL.java (rev 0)
+++ labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/TestNewDRL.java 2008-04-28 17:06:14 UTC (rev 19746)
@@ -0,0 +1,784 @@
+package org.drools.lang;
+
+import junit.framework.TestCase;
+import java.io.*;
+import java.lang.reflect.*;
+import org.antlr.runtime.*;
+import org.antlr.runtime.tree.*;
+
+public class TestNewDRL extends TestCase {
+ String stdout;
+ String stderr;
+
+ public void testNormal_lhs_block1() throws Exception {
+ // test input: ""
+ Object retval = execParser("normal_lhs_block", "", false);
+ Object actual = examineParserExecResult(8, retval);
+ Object expecting = "VT_AND_IMPLICIT";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block2() throws Exception {
+ // test input: " $id : Something( duration == \"foo\") "
+ Object retval = execParser("normal_lhs_block", " $id : Something( duration == \"foo\") ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING $id (VT_FACT (VT_QUALIFIED_ID Something) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT duration)) (== \"foo\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block3() throws Exception {
+ // test input: "foo3 : Bar("
+ Object retval = execParser("normal_lhs_block", "foo3 : Bar(", false);
+ Object actual = examineParserExecResult(28, retval);
+ Object expecting = "FAIL";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block4() throws Exception {
+ // test input: "\n\tCheese(name == \"Stilton\", age==2001)\n\tWine(name == \"Grange\", age == \"1978\", accolades contains \"world champion\")\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCheese(name == \"Stilton\", age==2001)\n\tWine(name == \"Grange\", age == \"1978\", accolades contains \"world champion\")\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"Stilton\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 2001)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Wine) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"Grange\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== \"1978\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT accolades)) (contains \"world champion\")))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block5() throws Exception {
+ // test input: "Foo()"
+ Object retval = execParser("normal_lhs_block", "Foo()", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block6() throws Exception {
+ // test input: "not Cheese(type == \"stilton\")"
+ Object retval = execParser("normal_lhs_block", "not Cheese(type == \"stilton\")", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block7() throws Exception {
+ // test input: "\n\tPerson(age < 42, location==\"atlanta\") \n\tor\n\tPerson(name==\"bob\")\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tPerson(age < 42, location==\"atlanta\") \n\tor\n\tPerson(name==\"bob\")\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"atlanta\")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"bob\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block8() throws Exception {
+ // test input: "\n\tFoo(bar == false)\n\tFoo(boo > -42)\n\tFoo(boo > -42.42)\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tFoo(bar == false)\n\tFoo(boo > -42)\n\tFoo(boo > -42.42)\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (== false)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT boo)) (> -42)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT boo)) (> -42.42)))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block9() throws Exception {
+ // test input: "Cheese( )"
+ Object retval = execParser("normal_lhs_block", "Cheese( )", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block10() throws Exception {
+ // test input: "\n\tCol1() from something.doIt( foo,bar,42,\"hello\",{ a => \"b\", \"something\" => 42, \"a\" => foo, x => {x=>y}},\"end\", [a, \"b\", 42] )\n\tCol2()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCol1() from something.doIt( foo,bar,42,\"hello\",{ a => \"b\", \"something\" => 42, \"a\" => foo, x => {x=>y}},\"end\", [a, \"b\", 42] )\n\tCol2()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE something (. doIt ( foo,bar,42,\"hello\",{ a => \"b\", \"something\" => 42, \"a\" => foo, x => {x=>y}},\"end\", [a, \"b\", 42] )))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block11() throws Exception {
+ // test input: "\n\tCol1() from doIt( foo,bar,42,\"hello\",{ a => \"b\", \"something\" => 42, \"a\" => foo, x => {x=>y}},\"end\", [a, \"b\", 42] )\n\tCol2()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCol1() from doIt( foo,bar,42,\"hello\",{ a => \"b\", \"something\" => 42, \"a\" => foo, x => {x=>y}},\"end\", [a, \"b\", 42] )\n\tCol2()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE doIt ( foo,bar,42,\"hello\",{ a => \"b\", \"something\" => 42, \"a\" => foo, x => {x=>y}},\"end\", [a, \"b\", 42] ))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block12() throws Exception {
+ // test input: "\n\tCol1() from something.doIt\n\tCol2()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCol1() from something.doIt\n\tCol2()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE something (. doIt))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block13() throws Exception {
+ // test input: "\n\tCol1() from something.doIt[\"key\"]\n\tCol2()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCol1() from something.doIt[\"key\"]\n\tCol2()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE something (. doIt [\"key\"]))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block14() throws Exception {
+ // test input: "\n\tCol1() from doIt1( foo,bar,42,\"hello\",{ a => \"b\"}, [a, \"b\", 42] )\n\t .doIt2(bar, [a, \"b\", 42]).field[\"key\"]\n\tCol2()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCol1() from doIt1( foo,bar,42,\"hello\",{ a => \"b\"}, [a, \"b\", 42] )\n\t .doIt2(bar, [a, \"b\", 42]).field[\"key\"]\n\tCol2()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE doIt1 ( foo,bar,42,\"hello\",{ a => \"b\"}, [a, \"b\", 42] ) (. doIt2 (bar, [a, \"b\", 42]) (. field [\"key\"])))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block15() throws Exception {
+ // test input: "\n\tfoo3 : Bar(a==3)\n foo4 : Bar(a4:a==4)\n Baz()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tfoo3 : Bar(a==3)\n foo4 : Bar(a4:a==4)\n Baz()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo3 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 3))))) (VT_PATTERN (VT_FACT_BINDING foo4 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_BIND_FIELD a4 (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 4)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Baz))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block16() throws Exception {
+ // test input: "\n\tPerson(age > 30 && < 40)\n \tVehicle(type == \"sedan\" || == \"wagon\", age < 3)\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tPerson(age > 30 && < 40)\n \tVehicle(type == \"sedan\" || == \"wagon\", age < 3)\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (&& (> 30) (< 40))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Vehicle) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (|| (== \"sedan\") (== \"wagon\"))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 3)))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block17() throws Exception {
+ // test input: " foo3 : Bar(a==3) ; foo4 : Bar(a4:a==4) ; Baz()"
+ Object retval = execParser("normal_lhs_block", " foo3 : Bar(a==3) ; foo4 : Bar(a4:a==4) ; Baz()", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo3 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 3))))) (VT_PATTERN (VT_FACT_BINDING foo4 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_BIND_FIELD a4 (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 4)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Baz))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block18() throws Exception {
+ // test input: "\n \tnot ( Cheese(type == \"stilton\") )\n \texists ( Foo() )\n \t"
+ Object retval = execParser("normal_lhs_block", "\n \tnot ( Cheese(type == \"stilton\") )\n \texists ( Foo() )\n \t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))) (exists (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo)))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block19() throws Exception {
+ // test input: "\n \tnot ( Cheese(type == \"stilton\") )\n \texists ( Foo() )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n \tnot ( Cheese(type == \"stilton\") )\n \texists ( Foo() )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))) (exists (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo)))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block20() throws Exception {
+ // test input: "\n \ta : (not ( Cheese(type == \"stilton\") ))\n \texists ( Foo() )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n \ta : (not ( Cheese(type == \"stilton\") ))\n \texists ( Foo() )\n\t", false);
+ Object actual = examineParserExecResult(28, retval);
+ Object expecting = "FAIL";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block21() throws Exception {
+ // test input: " Cheese( t:type == \"cheddar\" ) "
+ Object retval = execParser("normal_lhs_block", " Cheese( t:type == \"cheddar\" ) ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_BIND_FIELD t (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"cheddar\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block22() throws Exception {
+ // test input: "Cheese( $type:type )"
+ Object retval = execParser("normal_lhs_block", "Cheese( $type:type )", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_BIND_FIELD $type (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block23() throws Exception {
+ // test input: "\n Cheese($type : type == \"stilton\")\n $person : Person($name : name == \"bob\", likes == $type) \n\t"
+ Object retval = execParser("normal_lhs_block", "\n Cheese($type : type == \"stilton\")\n $person : Person($name : name == \"bob\", likes == $type) \n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_BIND_FIELD $type (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))) (VT_PATTERN (VT_FACT_BINDING $person (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $name (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"bob\"))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT likes)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $type))))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block24() throws Exception {
+ // test input: "\n\tPerson(name == \"mark\") or \n\t( Person(type == \"fan\") and Cheese(type == \"green\") )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tPerson(name == \"mark\") or \n\t( Person(type == \"fan\") and Cheese(type == \"green\") )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"mark\")))) (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"fan\")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"green\")))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block25() throws Exception {
+ // test input: "\n\tPerson(name == \"mark\") && Cheese(type == \"stilton\")\n Person(name == \"mark\") || Cheese(type == \"stilton\")\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tPerson(name == \"mark\") && Cheese(type == \"stilton\")\n Person(name == \"mark\") || Cheese(type == \"stilton\")\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (&& (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"mark\")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))) (|| (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"mark\")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block26() throws Exception {
+ // test input: "\n\tfoo : ( Person(name == \"mark\") or Person(type == \"fan\") ) \n\tCheese(type == \"green\")\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tfoo : ( Person(name == \"mark\") or Person(type == \"fan\") ) \n\tCheese(type == \"green\")\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo (or (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"mark\"))) (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"fan\")))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"green\")))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block27() throws Exception {
+ // test input: "\n\tfoo : ( Person(name == \"mark\") \n\t\tor \n\t\tPerson(type == \"fan\") )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tfoo : ( Person(name == \"mark\") \n\t\tor \n\t\tPerson(type == \"fan\") )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo (or (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"mark\"))) (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"fan\")))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block28() throws Exception {
+ // test input: "\n\tfoo : ( \n\t\tPerson(name == \"mark\") or Person(type == \"fan\") \n\t\t)\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tfoo : ( \n\t\tPerson(name == \"mark\") or Person(type == \"fan\") \n\t\t)\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo (or (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"mark\"))) (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"fan\")))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block29() throws Exception {
+ // test input: "\n\t ( (not Foo(x==\"a\") or Foo(x==\"y\") ) and ( Shoes() or Butt() ) )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\t ( (not Foo(x==\"a\") or Foo(x==\"y\") ) and ( Shoes() or Butt() ) )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (and (or (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT x)) (== \"a\"))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT x)) (== \"y\"))))) (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Shoes))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Butt))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block30() throws Exception {
+ // test input: "\n\teval(abc(\"foo\") + 5)\n\tFoo()\n\teval(qed())\n\tBar()\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\teval(abc(\"foo\") + 5)\n\tFoo()\n\teval(qed())\n\tBar()\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (eval (abc(\"foo\") + 5)) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))) (eval (qed())) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Bar))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block31() throws Exception {
+ // test input: "\n\tFoo()\n\tBar()\n\teval(abc(\"foo\"))\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tFoo()\n\tBar()\n\teval(abc(\"foo\"))\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Bar))) (eval (abc(\"foo\"))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block32() throws Exception {
+ // test input: "Foo(name== (a + b))"
+ Object retval = execParser("normal_lhs_block", "Foo(name== (a + b))", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== (a + b))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block33() throws Exception {
+ // test input: "Person( $age2:age -> ($age2 == $age1+2 ) )"
+ Object retval = execParser("normal_lhs_block", "Person( $age2:age -> ($age2 == $age1+2 ) )", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $age2 (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (-> ($age2 == $age1+2 )))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block34() throws Exception {
+ // test input: "Foo(bar == Foo.BAR)"
+ Object retval = execParser("normal_lhs_block", "Foo(bar == Foo.BAR)", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT Foo) (VT_ACCESSOR_ELEMENT BAR)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block35() throws Exception {
+ // test input: "\n\tp: Person( name soundslike \"Michael\" )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tp: Person( name soundslike \"Michael\" )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING p (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (soundslike \"Michael\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block36() throws Exception {
+ // test input: "\n\tFoo()\n\tBar()\n\teval(\n\t\n\t\n\t\n\t abc(\n\t \n\t \"foo\") + \n\t 5\n\t \n\t \n\t \n\t \n\t )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tFoo()\n\tBar()\n\teval(\n\t\n\t\n\t\n\t abc(\n\t \n\t \"foo\") + \n\t 5\n\t \n\t \n\t \n\t \n\t )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Bar))) (eval (\n\t\n\t\n\t\n\t abc(\n\t \n\t \"foo\") + \n\t 5\n\t \n\t \n\t \n\t \n\t )))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block37() throws Exception {
+ // test input: "eval(abc();)"
+ Object retval = execParser("normal_lhs_block", "eval(abc();)", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (eval (abc();)))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block38() throws Exception {
+ // test input: "\n\tFoo(\n\t bar == baz, la==laz\n\t )\n\t "
+ Object retval = execParser("normal_lhs_block", "\n\tFoo(\n\t bar == baz, la==laz\n\t )\n\t ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT baz)))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT la)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT laz)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block39() throws Exception {
+ // test input: "com.cheeseco.Cheese($type : type == \"stilton\")"
+ Object retval = execParser("normal_lhs_block", "com.cheeseco.Cheese($type : type == \"stilton\")", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID com cheeseco Cheese) (VT_BIND_FIELD $type (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"stilton\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block40() throws Exception {
+ // test input: "\n\t Integer() from accumulate( Person( age > 21 ),\n init( int x = 0; ),\n action( x++; ),\n result( new Integer(x) ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\t Integer() from accumulate( Person( age > 21 ),\n init( int x = 0; ),\n action( x++; ),\n result( new Integer(x) ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Integer))) (accumulate (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (result ( new Integer(x) ))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block41() throws Exception {
+ // test input: "\n $counter:Integer() from accumulate( $person : Person( age > 21 ),\n init( int x = 0; ),\n action( x++; ),\n result( new Integer(x) ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n $counter:Integer() from accumulate( $person : Person( age > 21 ),\n init( int x = 0; ),\n action( x++; ),\n result( new Integer(x) ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $counter (VT_FACT (VT_QUALIFIED_ID Integer)))) (accumulate (VT_PATTERN (VT_FACT_BINDING $person (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21))))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (result ( new Integer(x) ))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block42() throws Exception {
+ // test input: "$personList : ArrayList() from collect( Person( age > 21 ) );"
+ Object retval = execParser("normal_lhs_block", "$personList : ArrayList() from collect( Person( age > 21 ) );", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $personList (VT_FACT (VT_QUALIFIED_ID ArrayList)))) (collect (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block43() throws Exception {
+ // test input: "\n\t\tnot ( State( $state : state ) and\n\t not( Person( status == $state, $likes : likes ) and\n\t Cheese( type == $likes ) ) )\n\t Person( name == \"Bob\" )\n\t ( Cheese( price == 10 ) or Cheese( type == \"brie\" ) )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\t\tnot ( State( $state : state ) and\n\t not( Person( status == $state, $likes : likes ) and\n\t Cheese( type == $likes ) ) )\n\t Person( name == \"Bob\" )\n\t ( Cheese( price == 10 ) or Cheese( type == \"brie\" ) )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (not (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID State) (VT_BIND_FIELD $state (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT state)))))) (not (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT status)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $state)))) (VT_BIND_FIELD $likes (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT likes)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $likes)))))))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"Bob\")))) (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT price)) (== 10)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== \"brie\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block44() throws Exception {
+ // test input: "\n forall( Person( age > 21, $likes : likes )\n Cheese( type == $likes ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n forall( Person( age > 21, $likes : likes )\n Cheese( type == $likes ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (forall (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)) (VT_BIND_FIELD $likes (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT likes)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $likes))))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block45() throws Exception {
+ // test input: "\n Country( $cities : city )\n Person( city memberOf $cities )\n "
+ Object retval = execParser("normal_lhs_block", "\n Country( $cities : city )\n Person( city memberOf $cities )\n ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Country) (VT_BIND_FIELD $cities (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)) (memberOf (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $cities)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block46() throws Exception {
+ // test input: "\n Country( $cities : city )\n Person( city not memberOf $cities )\n "
+ Object retval = execParser("normal_lhs_block", "\n Country( $cities : city )\n Person( city not memberOf $cities )\n ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Country) (VT_BIND_FIELD $cities (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)) (memberOf not (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $cities)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block47() throws Exception {
+ // test input: "\n \tPerson(age > 30 && < 40)\n \tVehicle(type in ( \"sedan\", \"wagon\" ), age < 3)\n\t"
+ Object retval = execParser("normal_lhs_block", "\n \tPerson(age > 30 && < 40)\n \tVehicle(type in ( \"sedan\", \"wagon\" ), age < 3)\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (&& (> 30) (< 40))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Vehicle) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (in \"sedan\" \"wagon\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 3)))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block48() throws Exception {
+ // test input: "\n \tPerson(age > 30 && < 40)\n \tVehicle(type not in ( \"sedan\", \"wagon\" ), age < 3)\n\t"
+ Object retval = execParser("normal_lhs_block", "\n \tPerson(age > 30 && < 40)\n \tVehicle(type not in ( \"sedan\", \"wagon\" ), age < 3)\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (&& (> 30) (< 40))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Vehicle) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (in not \"sedan\" \"wagon\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 3)))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block49() throws Exception {
+ // test input: " Person( age < 42 && location==\"atlanta\") "
+ Object retval = execParser("normal_lhs_block", " Person( age < 42 && location==\"atlanta\") ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"atlanta\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block50() throws Exception {
+ // test input: " Person( age < 42 || location==\"atlanta\") "
+ Object retval = execParser("normal_lhs_block", " Person( age < 42 || location==\"atlanta\") ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"atlanta\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block51() throws Exception {
+ // test input: "Person( age < 42 && location==\"atlanta\" || age > 20 && location==\"Seatle\" || location == \"Chicago\")"
+ Object retval = execParser("normal_lhs_block", "Person( age < 42 && location==\"atlanta\" || age > 20 && location==\"Seatle\" || location == \"Chicago\")", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"atlanta\"))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 20)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"Seatle\")))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"Chicago\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block52() throws Exception {
+ // test input: "Person( age < 42 && ( location==\"atlanta\" || age > 20 && location==\"Seatle\") || location == \"Chicago\")"
+ Object retval = execParser("normal_lhs_block", "Person( age < 42 && ( location==\"atlanta\" || age > 20 && location==\"Seatle\") || location == \"Chicago\")", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"atlanta\")) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 20)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"Seatle\"))))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== \"Chicago\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block53() throws Exception {
+ // test input: " Person( ( age == 70 && hair == \"black\" ) || ( age == 40 && hair == \"pink\" ) || ( age == 12 && ( hair == \"yellow\" || hair == \"blue\" ) ) ) "
+ Object retval = execParser("normal_lhs_block", " Person( ( age == 70 && hair == \"black\" ) || ( age == 40 && hair == \"pink\" ) || ( age == 12 && ( hair == \"yellow\" || hair == \"blue\" ) ) ) ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 70)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"black\"))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 40)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"pink\")))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 12)) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"yellow\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"blue\"))))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block54() throws Exception {
+ // test input: " Person( name matches \"mark\" || matches \"bob\" ) "
+ Object retval = execParser("normal_lhs_block", " Person( name matches \"mark\" || matches \"bob\" ) ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (|| (matches \"mark\") (matches \"bob\"))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block55() throws Exception {
+ // test input: "\n\tCity( $city : city )\n\tCountry( cities not contains $city )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tCity( $city : city )\n\tCountry( cities not contains $city )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID City) (VT_BIND_FIELD $city (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Country) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT cities)) (contains not (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $city)))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block56() throws Exception {
+ // test input: " Message( text not matches '[abc]*' ) "
+ Object retval = execParser("normal_lhs_block", " Message( text not matches '[abc]*' ) ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Message) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT text)) (matches not '[abc]*')))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block57() throws Exception {
+ // test input: "Foo( bar > 1 || == 1 )"
+ Object retval = execParser("normal_lhs_block", "Foo( bar > 1 || == 1 )", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (|| (> 1) (== 1))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block58() throws Exception {
+ // test input: "\n\tPattern1();\n\tPattern2() from x.y.z;\n\tPattern5();\n\tPattern6();\n\tPattern7();\n\tPattern3();\n\tPattern4() from collect( Pattern5() );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tPattern1();\n\tPattern2() from x.y.z;\n\tPattern5();\n\tPattern6();\n\tPattern7();\n\tPattern3();\n\tPattern4() from collect( Pattern5() );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern1))) (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern2))) (VT_FROM_SOURCE x (. y (. z)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern5))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern6))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern7))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern3))) (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern4))) (collect (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern5))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block59() throws Exception {
+ // test input: " eval( 3==3 ) "
+ Object retval = execParser("normal_lhs_block", " eval( 3==3 ) ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (eval ( 3==3 )))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block60() throws Exception {
+ // test input: "\n\tInteger() from accumulate( Person( age > 21 ),\n\t init( int x = 0; ),\n\t action( x++; ),\n\t reverse( x--; ),\n\t result( new Integer(x) ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\tInteger() from accumulate( Person( age > 21 ),\n\t init( int x = 0; ),\n\t action( x++; ),\n\t reverse( x--; ),\n\t result( new Integer(x) ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Integer))) (accumulate (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (reverse ( x--; )) (result ( new Integer(x) ))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block61() throws Exception {
+ // test input: "\n Number() from accumulate( Person( $age : age > 21 ),\n average( $age ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n Number() from accumulate( Person( $age : age > 21 ),\n average( $age ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Number))) (accumulate (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $age (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21))))) (VT_ACCUMULATE_ID_CLAUSE average ( $age )))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block62() throws Exception {
+ // test input: "\n #bellow statement makes no sense, but is useful to test parsing recursiveness\n $personList : ArrayList() from collect( $p : Person( age > 21 || age < 10 ) from collect( People() from $town.getPeople() ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n #bellow statement makes no sense, but is useful to test parsing recursiveness\n $personList : ArrayList() from collect( $p : Person( age > 21 || age < 10 ) from collect( People() from $town.getPeople() ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $personList (VT_FACT (VT_QUALIFIED_ID ArrayList)))) (collect (from (VT_PATTERN (VT_FACT_BINDING $p (VT_FACT (VT_QUALIFIED_ID Person) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 10)))))) (collect (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID People))) (VT_FROM_SOURCE $town (. getPeople ()))))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block63() throws Exception {
+ // test input: "\n $personList : ArrayList() from accumulate( Person( $age : age > 21 || < 10 ) from collect( People() from $town.getPeople() ),\n max( $age ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n $personList : ArrayList() from accumulate( Person( $age : age > 21 || < 10 ) from collect( People() from $town.getPeople() ),\n max( $age ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $personList (VT_FACT (VT_QUALIFIED_ID ArrayList)))) (accumulate (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $age (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (|| (> 21) (< 10)))))) (collect (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID People))) (VT_FROM_SOURCE $town (. getPeople ()))))) (VT_ACCUMULATE_ID_CLAUSE max ( $age )))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block64() throws Exception {
+ // test input: "\n $p : Person( name == \"bob\" )\n $c : Cheese( type == $p.likes ) || Cheese( price == 10 )\n "
+ Object retval = execParser("normal_lhs_block", "\n $p : Person( name == \"bob\" )\n $c : Cheese( type == $p.likes ) || Cheese( price == 10 )\n ", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING $p (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== \"bob\"))))) (|| (VT_PATTERN (VT_FACT_BINDING $c (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $p) (VT_ACCESSOR_ELEMENT likes))))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT price)) (== 10))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block65() throws Exception {
+ // test input: "\n\t(or\n\tnot Person()\n\t\t(and Cheese()\n\t\t\tMeat()\n\t\t\tWine()))\n\t"
+ Object retval = execParser("normal_lhs_block", "\n\t(or\n\tnot Person()\n\t\t(and Cheese()\n\t\t\tMeat()\n\t\t\tWine()))\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (or (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person)))) (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Meat))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Wine))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block66() throws Exception {
+ // test input: "\n $counter:Integer() from accumulate( $person : Person( age > 21 ) and Cheese( type == $person.likes ),\n init( int x = 0; ),\n action( x++; ),\n result( new Integer(x) ) );\n\t"
+ Object retval = execParser("normal_lhs_block", "\n $counter:Integer() from accumulate( $person : Person( age > 21 ) and Cheese( type == $person.likes ),\n init( int x = 0; ),\n action( x++; ),\n result( new Integer(x) ) );\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $counter (VT_FACT (VT_QUALIFIED_ID Integer)))) (accumulate (and (VT_PATTERN (VT_FACT_BINDING $person (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $person) (VT_ACCESSOR_ELEMENT likes))))))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (result ( new Integer(x) ))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block67() throws Exception {
+ // test input: "\n $a : EventA()\n $b : EventB( this after[1,10] $a )\n $c : EventC( this finishes $b )\n $d : EventD( this not starts $a )\n $e : EventE( this not before [1, 10] $b )\n\t"
+ Object retval = execParser("normal_lhs_block", "\n $a : EventA()\n $b : EventB( this after[1,10] $a )\n $c : EventC( this finishes $b )\n $d : EventD( this not starts $a )\n $e : EventE( this not before [1, 10] $b )\n\t", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING $a (VT_FACT (VT_QUALIFIED_ID EventA)))) (VT_PATTERN (VT_FACT_BINDING $b (VT_FACT (VT_QUALIFIED_ID EventB) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (after [1,10] (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $a))))))) (VT_PATTERN (VT_FACT_BINDING $c (VT_FACT (VT_QUALIFIED_ID EventC) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (finishes (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $b))))))) (VT_PATTERN (VT_FACT_BINDING $d (VT_FACT (VT_QUALIFIED_ID EventD) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (starts not (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $a))))))) (VT_PATTERN (VT_FACT_BINDING $e (VT_FACT (VT_QUALIFIED_ID EventE) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (before not [1, 10] (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $b))))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block68() throws Exception {
+ // test input: "StockTick( symbol==\"ACME\") from entry-point StreamA"
+ Object retval = execParser("normal_lhs_block", "StockTick( symbol==\"ACME\") from entry-point StreamA", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID StockTick) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT symbol)) (== \"ACME\")))) (entry-point StreamA)))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testNormal_lhs_block69() throws Exception {
+ // test input: "Person( ( age ( > 60 && < 70 ) || ( > 50 && < 55 ) && hair == \"black\" ) || ( age == 40 && hair == \"pink\" ) || ( age == 12 && ( hair == \"yellow\" || hair == \"blue\" ) ))"
+ Object retval = execParser("normal_lhs_block", "Person( ( age ( > 60 && < 70 ) || ( > 50 && < 55 ) && hair == \"black\" ) || ( age == 40 && hair == \"pink\" ) || ( age == 12 && ( hair == \"yellow\" || hair == \"blue\" ) ))", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (|| (&& (> 60) (< 70)) (&& (> 50) (< 55)))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"black\"))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 40)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"pink\")))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 12)) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"yellow\")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== \"blue\"))))))))";
+
+ assertEquals("testing rule "+"normal_lhs_block", expecting, actual);
+ }
+
+ public void testConstraints70() throws Exception {
+ // test input: "$var : attr -> ( $var.equals(\"xyz\") )"
+ Object retval = execParser("constraints", "$var : attr -> ( $var.equals(\"xyz\") )", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(VT_BIND_FIELD $var (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT attr)) (-> ( $var.equals(\"xyz\") ))))";
+
+ assertEquals("testing rule "+"constraints", expecting, actual);
+ }
+
+ public void testConstraints71() throws Exception {
+ // test input: "eval( $var.equals(\"xyz\") )"
+ Object retval = execParser("constraints", "eval( $var.equals(\"xyz\") )", false);
+ Object actual = examineParserExecResult(10, retval);
+ Object expecting = "(eval ( $var.equals(\"xyz\") ))";
+
+ assertEquals("testing rule "+"constraints", expecting, actual);
+ }
+
+ // Invoke target parser.rule
+ public Object execParser(String testRuleName, String testInput, boolean isFile) throws Exception {
+ CharStream input;
+ /** Set up ANTLR input stream based on input source, file or String */
+ if ( isFile==true ) {
+ input = new ANTLRFileStream(testInput);
+ }
+ else {
+ input = new ANTLRStringStream(testInput);
+ }
+ try {
+ NewDRLLexer lexer = new NewDRLLexer(input);
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ NewDRLParser parser = new NewDRLParser(tokens);
+ /** Use Reflection to get rule method from parser */
+ Method ruleName = Class.forName("org.drools.lang.NewDRLParser").getMethod(testRuleName);
+
+ /** Start of I/O Redirecting */
+ PipedInputStream pipedIn = new PipedInputStream();
+ PipedOutputStream pipedOut = new PipedOutputStream();
+ PipedInputStream pipedErrIn = new PipedInputStream();
+ PipedOutputStream pipedErrOut = new PipedOutputStream();
+ try {
+ pipedOut.connect(pipedIn);
+ pipedErrOut.connect(pipedErrIn);
+ }
+ catch(IOException e) {
+ System.err.println("connection failed...");
+ System.exit(1);
+ }
+ PrintStream console = System.out;
+ PrintStream consoleErr = System.err;
+ PrintStream ps = new PrintStream(pipedOut);
+ PrintStream ps2 = new PrintStream(pipedErrOut);
+ System.setOut(ps);
+ System.setErr(ps2);
+ /** End of redirecting */
+
+ /** Invoke grammar rule, and store if there is a return value */
+ Object ruleReturn = ruleName.invoke(parser);
+ String astString = null;
+ /** If rule has return value, determine if it's an AST */
+ if ( ruleReturn!=null ) {
+ /** If return object is instanceof AST, get the toStringTree */
+ if ( ruleReturn.toString().indexOf(testRuleName+"_return")>0 ) {
+ try { // NullPointerException may happen here...
+ Class _return = Class.forName("org.drools.lang.NewDRLParser"+"$"+testRuleName+"_return");
+ Method[] methods = _return.getDeclaredMethods();
+ for(Method method : methods) {
+ if ( method.getName().equals("getTree") ) {
+ Method returnName = _return.getMethod("getTree");
+ CommonTree tree = (CommonTree) returnName.invoke(ruleReturn);
+ astString = tree.toStringTree();
+ }
+ }
+ }
+ catch(Exception e) {
+ System.err.println(e);
+ }
+ }
+ }
+
+ org.antlr.gunit.gUnitExecuter.StreamVacuum stdoutVacuum = new org.antlr.gunit.gUnitExecuter.StreamVacuum(pipedIn);
+ org.antlr.gunit.gUnitExecuter.StreamVacuum stderrVacuum = new org.antlr.gunit.gUnitExecuter.StreamVacuum(pipedErrIn);
+ ps.close();
+ ps2.close();
+ System.setOut(console); // Reset standard output
+ System.setErr(consoleErr); // Reset standard err out
+ this.stdout = null;
+ this.stderr = null;
+ stdoutVacuum.start();
+ stderrVacuum.start();
+ stdoutVacuum.join();
+ stderrVacuum.join();
+ // retVal could be actual return object from rule, stderr or stdout
+ if ( stderrVacuum.toString().length()>0 ) {
+ this.stderr = stderrVacuum.toString();
+ return this.stderr;
+ }
+ if ( stdoutVacuum.toString().length()>0 ) {
+ this.stdout = stdoutVacuum.toString();
+ }
+ if ( astString!=null ) { // Return toStringTree of AST
+ return astString;
+ }
+ if ( ruleReturn!=null ) {
+ return ruleReturn;
+ }
+ if ( stderrVacuum.toString().length()==0 && stdoutVacuum.toString().length()==0 ) {
+ return null;
+ }
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace(); System.exit(1);
+ } catch (SecurityException e) {
+ e.printStackTrace(); System.exit(1);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace(); System.exit(1);
+ } catch (IllegalAccessException e) {
+ e.printStackTrace(); System.exit(1);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace(); System.exit(1);
+ } catch (InterruptedException e) {
+ e.printStackTrace(); System.exit(1);
+ } catch (Exception e) {
+ e.printStackTrace(); System.exit(1);
+ }
+ return stdout;
+ }
+
+ // Modify the return value if the expected token type is OK or FAIL
+ public Object examineParserExecResult(int tokenType, Object retVal) {
+ if ( tokenType==27 ) { // expected Token: OK
+ if ( this.stderr==null ) {
+ return "OK";
+ }
+ else {
+ return "FAIL";
+ }
+ }
+ else if ( tokenType==28 ) { // expected Token: FAIL
+ if ( this.stderr!=null ) {
+ return "FAIL";
+ }
+ else {
+ return "OK";
+ }
+ }
+ else { // return the same object for the other token types
+ return retVal;
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/TestNewDRL.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/gUnitTest.testsuite
===================================================================
--- labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/gUnitTest.testsuite (rev 0)
+++ labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/gUnitTest.testsuite 2008-04-28 17:06:14 UTC (rev 19746)
@@ -0,0 +1,374 @@
+gunit NewDRL;
+
+ at header{
+package org.drools.lang;
+}
+
+normal_lhs_block:
+ "" -> "VT_AND_IMPLICIT"
+ << $id : Something( duration == "foo") >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING $id (VT_FACT (VT_QUALIFIED_ID Something) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT duration)) (== "foo"))))))
+ "foo3 : Bar(" FAIL
+ <<
+ Cheese(name == "Stilton", age==2001)
+ Wine(name == "Grange", age == "1978", accolades contains "world champion")
+ >> -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "Stilton")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 2001)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Wine) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "Grange")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== "1978")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT accolades)) (contains "world champion")))))
+ "Foo()"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))))
+ <<not Cheese(type == "stilton")>>
+ -> (VT_AND_IMPLICIT (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))))
+ <<
+ Person(age < 42, location=="atlanta")
+ or
+ Person(name=="bob")
+ >>
+ -> (VT_AND_IMPLICIT (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "atlanta")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "bob"))))))
+ <<
+ Foo(bar == false)
+ Foo(boo > -42)
+ Foo(boo > -42.42)
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (== false)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT boo)) (> -42)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT boo)) (> -42.42)))))
+ "Cheese( )"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese))))
+
+ <<
+ Col1() from something.doIt( foo,bar,42,"hello",{ a => "b", "something" => 42, "a" => foo, x => {x=>y}},"end", [a, "b", 42] )
+ Col2()
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE something (. doIt ( foo,bar,42,"hello",{ a => "b", "something" => 42, "a" => foo, x => {x=>y}},"end", [a, "b", 42] )))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))
+ <<
+ Col1() from doIt( foo,bar,42,"hello",{ a => "b", "something" => 42, "a" => foo, x => {x=>y}},"end", [a, "b", 42] )
+ Col2()
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE doIt ( foo,bar,42,"hello",{ a => "b", "something" => 42, "a" => foo, x => {x=>y}},"end", [a, "b", 42] ))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))
+ <<
+ Col1() from something.doIt
+ Col2()
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE something (. doIt))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))
+ <<
+ Col1() from something.doIt["key"]
+ Col2()
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE something (. doIt ["key"]))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))
+ <<
+ Col1() from doIt1( foo,bar,42,"hello",{ a => "b"}, [a, "b", 42] )
+ .doIt2(bar, [a, "b", 42]).field["key"]
+ Col2()
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col1))) (VT_FROM_SOURCE doIt1 ( foo,bar,42,"hello",{ a => "b"}, [a, "b", 42] ) (. doIt2 (bar, [a, "b", 42]) (. field ["key"])))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Col2))))
+ <<
+ foo3 : Bar(a==3)
+ foo4 : Bar(a4:a==4)
+ Baz()
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo3 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 3))))) (VT_PATTERN (VT_FACT_BINDING foo4 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_BIND_FIELD a4 (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 4)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Baz))))
+ <<
+ Person(age > 30 && < 40)
+ Vehicle(type == "sedan" || == "wagon", age < 3)
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (&& (> 30) (< 40))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Vehicle) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (|| (== "sedan") (== "wagon"))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 3)))))
+ " foo3 : Bar(a==3) ; foo4 : Bar(a4:a==4) ; Baz()"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo3 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 3))))) (VT_PATTERN (VT_FACT_BINDING foo4 (VT_FACT (VT_QUALIFIED_ID Bar) (VT_BIND_FIELD a4 (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT a)) (== 4)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Baz))))
+ <<
+ not ( Cheese(type == "stilton") )
+ exists ( Foo() )
+ >>
+ -> (VT_AND_IMPLICIT (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))) (exists (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo)))))
+ <<
+ not ( Cheese(type == "stilton") )
+ exists ( Foo() )
+ >>
+ -> (VT_AND_IMPLICIT (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))) (exists (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo)))))
+ <<
+ a : (not ( Cheese(type == "stilton") ))
+ exists ( Foo() )
+ >>
+ FAIL
+ << Cheese( t:type == "cheddar" ) >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_BIND_FIELD t (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "cheddar"))))))
+
+ "Cheese( $type:type )"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_BIND_FIELD $type (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)))))))
+ <<
+ Cheese($type : type == "stilton")
+ $person : Person($name : name == "bob", likes == $type)
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_BIND_FIELD $type (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))) (VT_PATTERN (VT_FACT_BINDING $person (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $name (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "bob"))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT likes)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $type))))))))
+ <<
+ Person(name == "mark") or
+ ( Person(type == "fan") and Cheese(type == "green") )
+ >>
+ -> (VT_AND_IMPLICIT (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "mark")))) (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "fan")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "green")))))))
+ <<
+ Person(name == "mark") && Cheese(type == "stilton")
+ Person(name == "mark") || Cheese(type == "stilton")
+ >>
+ -> (VT_AND_IMPLICIT (&& (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "mark")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))) (|| (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "mark")))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))))
+ <<
+ foo : ( Person(name == "mark") or Person(type == "fan") )
+ Cheese(type == "green")
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo (or (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "mark"))) (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "fan")))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "green")))))
+ <<
+ foo : ( Person(name == "mark")
+ or
+ Person(type == "fan") )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo (or (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "mark"))) (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "fan")))))))
+ <<
+ foo : (
+ Person(name == "mark") or Person(type == "fan")
+ )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING foo (or (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "mark"))) (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "fan")))))))
+ <<
+ ( (not Foo(x=="a") or Foo(x=="y") ) and ( Shoes() or Butt() ) )
+ >>
+ -> (VT_AND_IMPLICIT (and (or (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT x)) (== "a"))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT x)) (== "y"))))) (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Shoes))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Butt))))))
+ <<
+ eval(abc("foo") + 5)
+ Foo()
+ eval(qed())
+ Bar()
+ >>
+ -> (VT_AND_IMPLICIT (eval (abc("foo") + 5)) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))) (eval (qed())) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Bar))))
+ <<
+ Foo()
+ Bar()
+ eval(abc("foo"))
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Bar))) (eval (abc("foo"))))
+ "Foo(name== (a + b))"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== (a + b))))))
+
+ "Person( $age2:age -> ($age2 == $age1+2 ) )"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $age2 (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (-> ($age2 == $age1+2 )))))))
+
+ "Foo(bar == Foo.BAR)"
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT Foo) (VT_ACCESSOR_ELEMENT BAR)))))))
+ <<
+ p: Person( name soundslike "Michael" )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING p (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (soundslike "Michael"))))))
+
+ <<
+ Foo()
+ Bar()
+ eval(
+
+
+
+ abc(
+
+ "foo") +
+ 5
+
+
+
+
+ )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Bar))) (eval (
+
+
+
+ abc(
+
+ "foo") +
+ 5
+
+
+
+
+ )))
+
+ "eval(abc();)"
+ -> (VT_AND_IMPLICIT (eval (abc();)))
+
+ <<
+ Foo(
+ bar == baz, la==laz
+ )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT baz)))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT la)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT laz)))))))
+
+ <<com.cheeseco.Cheese($type : type == "stilton")>>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID com cheeseco Cheese) (VT_BIND_FIELD $type (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "stilton"))))))
+
+ <<
+ Integer() from accumulate( Person( age > 21 ),
+ init( int x = 0; ),
+ action( x++; ),
+ result( new Integer(x) ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Integer))) (accumulate (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (result ( new Integer(x) ))))))
+
+ <<
+ $counter:Integer() from accumulate( $person : Person( age > 21 ),
+ init( int x = 0; ),
+ action( x++; ),
+ result( new Integer(x) ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $counter (VT_FACT (VT_QUALIFIED_ID Integer)))) (accumulate (VT_PATTERN (VT_FACT_BINDING $person (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21))))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (result ( new Integer(x) ))))))
+
+ "$personList : ArrayList() from collect( Person( age > 21 ) );"
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $personList (VT_FACT (VT_QUALIFIED_ID ArrayList)))) (collect (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)))))))
+
+
+ <<
+ not ( State( $state : state ) and
+ not( Person( status == $state, $likes : likes ) and
+ Cheese( type == $likes ) ) )
+ Person( name == "Bob" )
+ ( Cheese( price == 10 ) or Cheese( type == "brie" ) )
+ >>
+ -> (VT_AND_IMPLICIT (not (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID State) (VT_BIND_FIELD $state (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT state)))))) (not (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT status)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $state)))) (VT_BIND_FIELD $likes (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT likes)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $likes)))))))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "Bob")))) (or (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT price)) (== 10)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== "brie"))))))
+
+ <<
+ forall( Person( age > 21, $likes : likes )
+ Cheese( type == $likes ) );
+ >>
+ -> (VT_AND_IMPLICIT (forall (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)) (VT_BIND_FIELD $likes (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT likes)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $likes))))))))
+
+ <<
+ Country( $cities : city )
+ Person( city memberOf $cities )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Country) (VT_BIND_FIELD $cities (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)) (memberOf (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $cities)))))))
+
+ <<
+ Country( $cities : city )
+ Person( city not memberOf $cities )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Country) (VT_BIND_FIELD $cities (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)) (memberOf not (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $cities)))))))
+
+ <<
+ Person(age > 30 && < 40)
+ Vehicle(type in ( "sedan", "wagon" ), age < 3)
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (&& (> 30) (< 40))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Vehicle) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (in "sedan" "wagon")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 3)))))
+
+ <<
+ Person(age > 30 && < 40)
+ Vehicle(type not in ( "sedan", "wagon" ), age < 3)
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (&& (> 30) (< 40))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Vehicle) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (in not "sedan" "wagon")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 3)))))
+
+ << Person( age < 42 && location=="atlanta") >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "atlanta"))))))
+
+ << Person( age < 42 || location=="atlanta") >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "atlanta"))))))
+
+ <<Person( age < 42 && location=="atlanta" || age > 20 && location=="Seatle" || location == "Chicago")>>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "atlanta"))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 20)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "Seatle")))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "Chicago"))))))
+
+ <<Person( age < 42 && ( location=="atlanta" || age > 20 && location=="Seatle") || location == "Chicago")>>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 42)) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "atlanta")) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 20)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "Seatle"))))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT location)) (== "Chicago"))))))
+
+ << Person( ( age == 70 && hair == "black" ) || ( age == 40 && hair == "pink" ) || ( age == 12 && ( hair == "yellow" || hair == "blue" ) ) ) >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 70)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "black"))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 40)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "pink")))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 12)) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "yellow")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "blue"))))))))
+
+ << Person( name matches "mark" || matches "bob" ) >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (|| (matches "mark") (matches "bob"))))))
+
+ <<
+ City( $city : city )
+ Country( cities not contains $city )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID City) (VT_BIND_FIELD $city (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT city)))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Country) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT cities)) (contains not (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $city)))))))
+
+ << Message( text not matches '[abc]*' ) >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Message) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT text)) (matches not '[abc]*')))))
+
+ <<Foo( bar > 1 || == 1 )>>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Foo) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT bar)) (|| (> 1) (== 1))))))
+
+ <<
+ Pattern1();
+ Pattern2() from x.y.z;
+ Pattern5();
+ Pattern6();
+ Pattern7();
+ Pattern3();
+ Pattern4() from collect( Pattern5() );
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern1))) (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern2))) (VT_FROM_SOURCE x (. y (. z)))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern5))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern6))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern7))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern3))) (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern4))) (collect (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Pattern5))))))
+
+ << eval( 3==3 ) >>
+ -> (VT_AND_IMPLICIT (eval ( 3==3 )))
+
+ <<
+ Integer() from accumulate( Person( age > 21 ),
+ init( int x = 0; ),
+ action( x++; ),
+ reverse( x--; ),
+ result( new Integer(x) ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Integer))) (accumulate (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (reverse ( x--; )) (result ( new Integer(x) ))))))
+
+ <<
+ Number() from accumulate( Person( $age : age > 21 ),
+ average( $age ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Number))) (accumulate (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $age (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21))))) (VT_ACCUMULATE_ID_CLAUSE average ( $age )))))
+
+ <<
+ #bellow statement makes no sense, but is useful to test parsing recursiveness
+ $personList : ArrayList() from collect( $p : Person( age > 21 || age < 10 ) from collect( People() from $town.getPeople() ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $personList (VT_FACT (VT_QUALIFIED_ID ArrayList)))) (collect (from (VT_PATTERN (VT_FACT_BINDING $p (VT_FACT (VT_QUALIFIED_ID Person) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (< 10)))))) (collect (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID People))) (VT_FROM_SOURCE $town (. getPeople ()))))))))
+
+ <<
+ $personList : ArrayList() from accumulate( Person( $age : age > 21 || < 10 ) from collect( People() from $town.getPeople() ),
+ max( $age ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $personList (VT_FACT (VT_QUALIFIED_ID ArrayList)))) (accumulate (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (VT_BIND_FIELD $age (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (|| (> 21) (< 10)))))) (collect (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID People))) (VT_FROM_SOURCE $town (. getPeople ()))))) (VT_ACCUMULATE_ID_CLAUSE max ( $age )))))
+
+ <<
+ $p : Person( name == "bob" )
+ $c : Cheese( type == $p.likes ) || Cheese( price == 10 )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING $p (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT name)) (== "bob"))))) (|| (VT_PATTERN (VT_FACT_BINDING $c (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $p) (VT_ACCESSOR_ELEMENT likes))))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT price)) (== 10))))))
+
+ <<
+ (or
+ not Person()
+ (and Cheese()
+ Meat()
+ Wine()))
+ >>
+ -> (VT_AND_IMPLICIT (or (not (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person)))) (and (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Meat))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Wine))))))
+
+ <<
+ $counter:Integer() from accumulate( $person : Person( age > 21 ) and Cheese( type == $person.likes ),
+ init( int x = 0; ),
+ action( x++; ),
+ result( new Integer(x) ) );
+ >>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT_BINDING $counter (VT_FACT (VT_QUALIFIED_ID Integer)))) (accumulate (and (VT_PATTERN (VT_FACT_BINDING $person (VT_FACT (VT_QUALIFIED_ID Person) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (> 21))))) (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Cheese) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT type)) (== (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $person) (VT_ACCESSOR_ELEMENT likes))))))) (VT_ACCUMULATE_INIT_CLAUSE (init ( int x = 0; )) (action ( x++; )) (result ( new Integer(x) ))))))
+
+ <<
+ $a : EventA()
+ $b : EventB( this after[1,10] $a )
+ $c : EventC( this finishes $b )
+ $d : EventD( this not starts $a )
+ $e : EventE( this not before [1, 10] $b )
+ >>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT_BINDING $a (VT_FACT (VT_QUALIFIED_ID EventA)))) (VT_PATTERN (VT_FACT_BINDING $b (VT_FACT (VT_QUALIFIED_ID EventB) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (after [1,10] (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $a))))))) (VT_PATTERN (VT_FACT_BINDING $c (VT_FACT (VT_QUALIFIED_ID EventC) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (finishes (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $b))))))) (VT_PATTERN (VT_FACT_BINDING $d (VT_FACT (VT_QUALIFIED_ID EventD) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (starts not (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $a))))))) (VT_PATTERN (VT_FACT_BINDING $e (VT_FACT (VT_QUALIFIED_ID EventE) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT this)) (before not [1, 10] (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT $b))))))))
+
+ <<StockTick( symbol=="ACME") from entry-point StreamA>>
+ -> (VT_AND_IMPLICIT (from (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID StockTick) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT symbol)) (== "ACME")))) (entry-point StreamA)))
+
+ <<Person( ( age ( > 60 && < 70 ) || ( > 50 && < 55 ) && hair == "black" ) || ( age == 40 && hair == "pink" ) || ( age == 12 && ( hair == "yellow" || hair == "blue" ) ))>>
+ -> (VT_AND_IMPLICIT (VT_PATTERN (VT_FACT (VT_QUALIFIED_ID Person) (|| (|| (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (|| (&& (> 60) (< 70)) (&& (> 50) (< 55)))) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "black"))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 40)) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "pink")))) (&& (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT age)) (== 12)) (|| (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "yellow")) (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT hair)) (== "blue"))))))))
+
+
+constraints:
+ <<$var : attr -> ( $var.equals("xyz") )>>
+ -> (VT_BIND_FIELD $var (VT_FIELD (VT_ACCESSOR_PATH (VT_ACCESSOR_ELEMENT attr)) (-> ( $var.equals("xyz") ))))
+
+ <<eval( $var.equals("xyz") )>>
+ -> (eval ( $var.equals("xyz") ))
\ No newline at end of file
Property changes on: labs/jbossrules/branches/parser-rewrite/drools-compiler/src/test/java/org/drools/lang/gUnitTest.testsuite
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list