use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionFailure.
public void testIterateExpressionFailure() throws Exception {
IterateExpression exp = new IterateExpression((String) null);
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.expressions.EvaluationResult 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.expressions.EvaluationResult 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.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.
the class EnablementExpression method evaluate.
@Override
public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
long start = 0;
if (Expressions.TRACING)
start = System.currentTimeMillis();
EvaluationResult result = evaluateAnd(context);
if (Expressions.TRACING) {
System.out.println(// $NON-NLS-1$
"[Enablement Expression] - evaluation time: " + (System.currentTimeMillis() - start) + // $NON-NLS-1$
" ms.");
}
return result;
}
use of org.eclipse.core.expressions.EvaluationResult in project eclipse.platform.runtime by eclipse.
the class PropertyTesterTests method testPlatformTester.
public void testPlatformTester() throws Exception {
TestExpression exp = new TestExpression("org.eclipse.core.runtime", "bundleState", new Object[] { "org.eclipse.core.expressions" }, "ACTIVE", false);
EvaluationContext context = new EvaluationContext(null, Platform.class);
EvaluationResult result = exp.evaluate(context);
assertEquals(EvaluationResult.TRUE, result);
}
Aggregations