forked from apache/incubator-kie-drools
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DROOLS-7271] Fully port RuleParserTest as MiscDRLParserTest with @di…
- Loading branch information
1 parent
d637f88
commit 413d4cf
Showing
69 changed files
with
4,235 additions
and
13 deletions.
There are no files selected for viewing
2,490 changes: 2,477 additions & 13 deletions
2,490
drools-drl/drools-drl10-parser/src/test/java/org/drools/parser/MiscDRLParserTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/Rule_with_Extends.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.compiler | ||
|
||
rule test_rule extends rule1 | ||
when | ||
$foo : foo() | ||
then | ||
|
||
end |
25 changes: 25 additions & 0 deletions
25
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/Rule_with_Metadata.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
package org.drools.compiler | ||
|
||
rule test_rule | ||
@fooMeta1(barVal1) | ||
@fooMeta2(barVal2) | ||
when | ||
then | ||
System.out.println("Consequence"); | ||
end |
26 changes: 26 additions & 0 deletions
26
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/Rule_with_nested_LHS.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.compiler | ||
|
||
rule test | ||
when | ||
A() | ||
( B() and C() ) or | ||
( D() and E() ) or | ||
( F() and G() ) | ||
then | ||
|
||
end |
23 changes: 23 additions & 0 deletions
23
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/accumulate.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
rule "AccumulateParserTest" | ||
when | ||
Integer() from accumulate( Person( age > 21 ), | ||
init( int x = 0; ), | ||
action( x++; ), | ||
result( new Integer(x) ) ); | ||
then | ||
end |
21 changes: 21 additions & 0 deletions
21
...l/drools-drl10-parser/src/test/resources/org/drools/parser/accumulateExternalFunction.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
rule "AccumulateReverseParserTest" | ||
when | ||
Number() from accumulate( Person( $age : age > 21 ), | ||
average( $age ) ); | ||
then | ||
end |
28 changes: 28 additions & 0 deletions
28
.../drools-drl10-parser/src/test/resources/org/drools/parser/accumulateMultipleFunctions.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.compiler | ||
|
||
rule "Accumulate 1" | ||
when | ||
accumulate( Cheese( $price : price ), | ||
$a1 : average( $price ), | ||
$m1 : min( $price ), | ||
$M1 : max( $price ) // binds are optional, but it makes no sense to not have a binding in this case | ||
) | ||
then | ||
// do something | ||
end | ||
|
30 changes: 30 additions & 0 deletions
30
...l10-parser/src/test/resources/org/drools/parser/accumulateMultipleFunctionsConstraint.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.compiler | ||
|
||
rule "Accumulate 1" | ||
when | ||
accumulate( Cheese( $price : price ); | ||
$a1 : average( $price ), | ||
$m1 : min( $price ), | ||
$M1 : max( $price ); // binds are optional, but it makes no sense to not have a binding in this case | ||
$a1 > 10 && $M1 <= 100, | ||
$m1 == 5 // inline evals | ||
) | ||
then | ||
// do something | ||
end | ||
|
24 changes: 24 additions & 0 deletions
24
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/accumulateReverse.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
rule "AccumulateReverseParserTest" | ||
when | ||
Integer() from accumulate( Person( age > 21 ), | ||
init( int x = 0; ), | ||
action( x++; ), | ||
reverse( x--; ), | ||
result( new Integer(x) ) ); | ||
then | ||
end |
23 changes: 23 additions & 0 deletions
23
...drl/drools-drl10-parser/src/test/resources/org/drools/parser/accumulate_multi_pattern.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
rule "AccumulateMultiPatternParserTest" | ||
when | ||
$counter:Integer() from accumulate( $person : Person( age > 21 ) and Cheese( type == $person.likes ), | ||
init( int x = 0; ), | ||
action( x++; ), | ||
result( new Integer(x) ) ); | ||
then | ||
end |
23 changes: 23 additions & 0 deletions
23
...drl/drools-drl10-parser/src/test/resources/org/drools/parser/accumulate_with_bindings.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
rule "AccumulateParserTest" | ||
when | ||
$counter:Integer() from accumulate( $person : Person( age > 21 ), | ||
init( int x = 0; ), | ||
action( x++; ), | ||
result( new Integer(x) ) ); | ||
then | ||
end |
23 changes: 23 additions & 0 deletions
23
.../drools-drl10-parser/src/test/resources/org/drools/parser/accumulate_with_nested_from.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
rule "AccumulateParserTest" | ||
when | ||
// below statement makes no sense, but is useful to test parsing recursiveness | ||
$personList : ArrayList() from accumulate( Person( $age : age > 21 || < 10 ) from collect( People() from $town.getPeople() ), | ||
max( $age ) ); | ||
then | ||
end | ||
|
25 changes: 25 additions & 0 deletions
25
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/and_or_rule.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
import org.drools.compiler.Person | ||
|
||
rule simple_rule | ||
when | ||
Person(name == "mark") and Cheese(type == "stilton") | ||
Person(name == "mark") or Cheese(type == "stilton") | ||
then | ||
System.out.println( "Mark and Michael" ); | ||
end |
25 changes: 25 additions & 0 deletions
25
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/basic_binding.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.compiler.test; | ||
|
||
import org.drools.compiler.Cheese; | ||
|
||
rule "like cheddar" | ||
when | ||
Cheese( $type:type ) | ||
then | ||
System.out.println("I like " + $type); | ||
end |
27 changes: 27 additions & 0 deletions
27
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/bindings.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.drools.compiler.test; | ||
|
||
import org.drools.compiler.Cheese; | ||
import org.drools.compiler.Person; | ||
|
||
rule "Who likes Stilton" | ||
when | ||
Cheese($type : type == "stilton") | ||
$person : Person( $name : name == "bob", likes == $type) | ||
then | ||
System.out.println( $name + " likes " + $type); | ||
end |
21 changes: 21 additions & 0 deletions
21
drools-drl/drools-drl10-parser/src/test/resources/org/drools/parser/brackets_precedence.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
rule simple_rule | ||
when | ||
( (not Foo(x=="a") or Foo(x=="y") ) and ( Shoes() or Butt() ) ) | ||
then | ||
end |
Oops, something went wrong.