Added a test case for filter cluses without atoms.
@@ -1694,6 +1694,7 @@ public class GroundRuleTest {
* Test a select caluse that has no atoms.
* Friends(A, +B) >= 1 {B: B == 'Alice'}
* Friends(A, +B) >= 1 {B: B != 'Alice'}
+ * Friends(A, +B) >= 1 {B: A == 'Alice'}
*/
@Test
public void testSelectWithoutAtoms() {
@@ -1768,5 +1769,34 @@ public class GroundRuleTest {
);
rule.groundAll(manager, store);
PSLTest.compareGroundRules(expected, rule, store);
+
+ // Now use another variable in the equality check.
+
+ coefficients = Arrays.asList(
+ (Coefficient)(new ConstantNumber(1.0f))
+ );
+
+ atoms = Arrays.asList(
+ (SummationAtomOrAtom)(new SummationAtom(
+ model.predicates.get("Friends"),
+ new SummationVariableOrTerm[]{new Variable("A"), new SummationVariable("B")}
+ ))
+ );
+
+ filters = new HashMap<SummationVariable, Formula>();
+ filters.put(new SummationVariable("B"), new QueryAtom(GroundingOnlyPredicate.Equal, new Variable("A"), new UniqueStringID("Alice")));
+
+ rule = new WeightedArithmeticRule(
+ new ArithmeticRuleExpression(coefficients, atoms, FunctionComparator.LargerThan, new ConstantNumber(1)),
+ filters,
+ 1.0,
+ true
+ );
+
+ expected = Arrays.asList(
+ "1.0: 1.0 * FRIENDS('Alice', 'Bob') + 1.0 * FRIENDS('Alice', 'Charlie') + 1.0 * FRIENDS('Alice', 'Derek') + 1.0 * FRIENDS('Alice', 'Eugene') >= 1.0 ^2"
+ );
+ rule.groundAll(manager, store);
+ PSLTest.compareGroundRules(expected, rule, store);
}
}
