use of org.eclipse.core.expressions.EvaluationContext 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.EvaluationContext 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.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testPlatformPropertyTester.
public void testPlatformPropertyTester() throws Exception {
IExtensionRegistry registry = Platform.getExtensionRegistry();
// $NON-NLS-1$ //$NON-NLS-2$
IConfigurationElement[] ces = registry.getConfigurationElementsFor("org.eclipse.core.expressions.tests", "testParticipants");
// $NON-NLS-1$ //$NON-NLS-2$
IConfigurationElement enable = findExtension(ces, "test3").getChildren("enablement")[0];
Expression exp = ExpressionConverter.getDefault().perform(enable);
EvaluationContext context = new EvaluationContext(null, Platform.class);
assertEquals(EvaluationResult.TRUE, exp.evaluate(context));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testCountExpressionAnyNumber.
public void testCountExpressionAnyNumber() 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.TRUE == exp.evaluate(context));
list.clear();
// $NON-NLS-1$
list.add("one");
// $NON-NLS-1$
list.add("two");
// $NON-NLS-1$
list.add("three");
context = new EvaluationContext(null, list);
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
}
use of org.eclipse.core.expressions.EvaluationContext in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testIterateExpressionWithAdapterManagerIfEmptyFalse.
public void testIterateExpressionWithAdapterManagerIfEmptyFalse() throws Exception {
// $NON-NLS-1$
IterateExpression exp = new IterateExpression("or", "false");
final List<String> input = new ArrayList<>();
CollectionWrapper wrapper = new CollectionWrapper();
wrapper.collection = input;
EvaluationContext context = new EvaluationContext(null, wrapper);
assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
Aggregations