use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionOrMultiChildren.
public void testIterateExpressionOrMultiChildren() throws Exception {
// Test for Bug 260522: <iterate> iterates over collection elements,
// thereby *and*-ing all evaluated child expressions
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("or");
exp.add(Expression.FALSE);
exp.add(Expression.TRUE);
List<String> input = new ArrayList<>();
// $NON-NLS-1$
input.add("one");
EvaluationContext context = new EvaluationContext(null, input);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionAndMultiChildren.
public void testIterateExpressionAndMultiChildren() throws Exception {
// Test for Bug 260522: <iterate> iterates over collection elements,
// thereby *and*-ing all evaluated child expressions
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("and");
exp.add(Expression.FALSE);
exp.add(Expression.TRUE);
List<String> input = new ArrayList<>();
// $NON-NLS-1$
input.add("one");
// $NON-NLS-1$
input.add("two");
EvaluationContext context = new EvaluationContext(null, input);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionExact.
public void testCountExpressionExact() throws Exception {
// $NON-NLS-1$
CountExpression exp = new CountExpression("2");
List<String> list = new ArrayList<>();
// $NON-NLS-1$
list.add("one");
EvaluationContext context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
list.clear();
// $NON-NLS-1$
list.add("one");
// $NON-NLS-1$
list.add("two");
context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
list.clear();
// $NON-NLS-1$
list.add("one");
// $NON-NLS-1$
list.add("two");
// $NON-NLS-1$
list.add("three");
context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testWithExpressionNoVariable.
public void testWithExpressionNoVariable() throws Exception {
WithExpression expr = new WithExpression("variable");
expr.add(new EqualsExpression(new Object()));
EvaluationContext context = new EvaluationContext(null, new Object());
try {
expr.evaluate(context);
fail("Should throw exceptoin");
} catch (CoreException e) {
// this is success
}
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionNoneOrOne.
public void testCountExpressionNoneOrOne() throws Exception {
// $NON-NLS-1$
CountExpression exp = new CountExpression("?");
List<String> list = new ArrayList<>();
EvaluationContext context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
list.clear();
// $NON-NLS-1$
list.add("one");
context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
list.clear();
// $NON-NLS-1$
list.add("one");
// $NON-NLS-1$
list.add("two");
context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
Aggregations