use of org.eclipse.core.internal.expressions.AdaptExpression 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.AdaptExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpressionAdaptable.
public void testAdaptExpressionAdaptable() throws Exception {
// $NON-NLS-1$
AdaptExpression expression = new AdaptExpression("org.eclipse.core.internal.expressions.tests.Adapter");
// $NON-NLS-1$
expression.add(new InstanceofExpression("org.eclipse.core.internal.expressions.tests.Adapter"));
EvaluationResult result = expression.evaluate(new EvaluationContext(null, new AdaptableAdaptee()));
assertTrue(result == EvaluationResult.TRUE);
}
use of org.eclipse.core.internal.expressions.AdaptExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpressionHashCode.
public void testAdaptExpressionHashCode() throws Exception {
AdaptExpression expression1 = new AdaptExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter");
expression1.add(new InstanceofExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter"));
AdaptExpression expression2 = new AdaptExpression(// $NON-NLS-1$
"org.eclipse.core.internal.expressions.tests.Adapter");
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.AdaptExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpressionFail2.
public void testAdaptExpressionFail2() throws Exception {
// $NON-NLS-1$
AdaptExpression expression = new AdaptExpression("org.eclipse.core.internal.expressions.tests.Adapter");
// $NON-NLS-1$
expression.add(new InstanceofExpression("org.eclipse.core.internal.expressions.tests.NotExisting"));
EvaluationResult result = expression.evaluate(new EvaluationContext(null, new Adaptee()));
assertTrue(result == EvaluationResult.FALSE);
}
use of org.eclipse.core.internal.expressions.AdaptExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpression.
public void testAdaptExpression() throws Exception {
// $NON-NLS-1$
AdaptExpression expression = new AdaptExpression("org.eclipse.core.internal.expressions.tests.Adapter");
// $NON-NLS-1$
expression.add(new InstanceofExpression("org.eclipse.core.internal.expressions.tests.Adapter"));
EvaluationResult result = expression.evaluate(new EvaluationContext(null, new Adaptee()));
assertTrue(result == EvaluationResult.TRUE);
}
Aggregations