use of org.eclipse.core.internal.expressions.IterateExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionHashCode.
public void testIterateExpressionHashCode() throws Exception {
IterateExpression expression1 = new IterateExpression("and");
expression1.add(new InstanceofExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter"));
IterateExpression expression2 = new IterateExpression("and");
expression2.add(new InstanceofExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter"));
assertEquals("Equal expressions should have the same hash code", expression1.hashCode(), expression2.hashCode());
}
use of org.eclipse.core.internal.expressions.IterateExpression 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.internal.expressions.IterateExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionWithAdapterManager.
public void testIterateExpressionWithAdapterManager() throws Exception {
final List<Object> result = new ArrayList<>();
Expression myExpression = new Expression() {
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
result.add(context.getDefaultVariable());
return EvaluationResult.FALSE;
}
};
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("or");
exp.add(myExpression);
final List<String> input = new ArrayList<>();
// $NON-NLS-1$
input.add("one");
// $NON-NLS-1$
input.add("two");
CollectionWrapper wrapper = new CollectionWrapper();
wrapper.collection = input;
EvaluationContext context = new EvaluationContext(null, wrapper);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
assertTrue(result.equals(input));
}
use of org.eclipse.core.internal.expressions.IterateExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionAndFalse.
public void testIterateExpressionAndFalse() throws Exception {
final List<Object> result = new ArrayList<>();
Expression myExpression = new Expression() {
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
result.add(context.getDefaultVariable());
return EvaluationResult.FALSE;
}
};
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("and");
exp.add(myExpression);
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));
// $NON-NLS-1$
assertTrue(result.size() == 1 && result.get(0).equals("one"));
}
use of org.eclipse.core.internal.expressions.IterateExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionAndTrue.
public void testIterateExpressionAndTrue() throws Exception {
final List<Object> result = new ArrayList<>();
Expression myExpression = new Expression() {
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
result.add(context.getDefaultVariable());
return EvaluationResult.TRUE;
}
};
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("and");
exp.add(myExpression);
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.TRUE == exp.evaluate(context));
assertTrue(result.equals(input));
}
Aggregations