use of org.eclipse.core.internal.expressions.WithExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpressionWithNull.
/**
* Bug 484325
*/
public void testAdaptExpressionWithNull() throws Exception {
// it's surprisingly difficult to craft an EvaluationContext that
// provides
// a defaultVariable == null
IEvaluationContext testContext = new EvaluationContext(null, new Adaptee());
testContext.addVariable("nullCarrier", Arrays.asList((Object) null, (Object) null, (Object) null));
WithExpression withExpression = new WithExpression("nullCarrier");
IterateExpression iterateExpression = new IterateExpression("and");
iterateExpression.add(new AdaptExpression("org.eclipse.core.internal.expressions.tests.NotExisting"));
withExpression.add(iterateExpression);
EvaluationResult result = withExpression.evaluate(testContext);
assertTrue(result == EvaluationResult.FALSE);
}
use of org.eclipse.core.internal.expressions.WithExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testWithExpressionHashCode.
public void testWithExpressionHashCode() throws Exception {
WithExpression expression1 = new WithExpression("variable");
expression1.add(new InstanceofExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter"));
WithExpression expression2 = new WithExpression("variable");
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.WithExpression 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.internal.expressions.WithExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testWithExpressionNotEqual.
public void testWithExpressionNotEqual() throws Exception {
WithExpression expression1 = new WithExpression("variable1");
expression1.add(new InstanceofExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter1"));
WithExpression expression2 = new WithExpression("variable2");
expression2.add(new InstanceofExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter2"));
assertTrue("These with expressions should not be equal", !expression1.equals(expression2));
}
use of org.eclipse.core.internal.expressions.WithExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testWithExpressionUndefinedVariable.
public void testWithExpressionUndefinedVariable() throws Exception {
WithExpression expr = new WithExpression("variable");
expr.add(new EqualsExpression(new Object()));
EvaluationContext context = new EvaluationContext(null, new Object());
context.addVariable("variable", IEvaluationContext.UNDEFINED_VARIABLE);
assertEquals(EvaluationResult.FALSE, expr.evaluate(context));
}
Aggregations