use of org.eclipse.core.internal.expressions.CountExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionNone.
public void testCountExpressionNone() 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.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.FALSE == exp.evaluate(context));
}
use of org.eclipse.core.internal.expressions.CountExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionFailure.
public void testCountExpressionFailure() throws Exception {
// $NON-NLS-1$
CountExpression exp = new CountExpression("!");
EvaluationContext context = new EvaluationContext(null, new Object());
try {
EvaluationResult result = exp.evaluate(context);
fail("Count should've failed for non-Collection variable. Result = " + result.toString());
} catch (CoreException e) {
assertEquals(ExpressionStatus.VARIABLE_IS_NOT_A_COLLECTION, e.getStatus().getCode());
}
}
use of org.eclipse.core.internal.expressions.CountExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionHashCode.
public void testCountExpressionHashCode() throws Exception {
CountExpression expression1 = new CountExpression("*");
CountExpression expression2 = new CountExpression("*");
assertEquals("Equal expressions should have the same hash code", expression1.hashCode(), expression2.hashCode());
}
use of org.eclipse.core.internal.expressions.CountExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionNotEqual.
public void testCountExpressionNotEqual() throws Exception {
CountExpression expression1 = new CountExpression("+");
CountExpression expression2 = new CountExpression("!");
assertTrue("These count expressions should not be equal", !expression1.equals(expression2));
}
use of org.eclipse.core.internal.expressions.CountExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionOneOrMore.
public void testCountExpressionOneOrMore() throws Exception {
// $NON-NLS-1$
CountExpression exp = new CountExpression("+");
List<String> list = new ArrayList<>();
EvaluationContext context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.FALSE == 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.TRUE == exp.evaluate(context));
}
Aggregations