use of org.eclipse.core.internal.expressions.InstanceofExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testSubType.
public void testSubType() throws Exception {
EvaluationContext context = new EvaluationContext(null, IEvaluationContext.UNDEFINED_VARIABLE);
ArrayList<AbstractCollection<?>> list = new ArrayList<>();
HashSet<?> o1 = new HashSet<>();
EvaluationContext c1 = new EvaluationContext(null, o1);
list.add(o1);
ArrayList<?> o2 = new ArrayList<>();
EvaluationContext c2 = new EvaluationContext(null, o2);
list.add(o2);
LinkedList<?> o3 = new LinkedList<>();
EvaluationContext c3 = new EvaluationContext(null, o3);
list.add(o3);
context.addVariable("selection", list);
WithExpression with = new WithExpression("selection");
IterateExpression iterate = new IterateExpression("and", "false");
with.add(iterate);
InstanceofExpression iCollection = new InstanceofExpression("java.util.Collection");
iterate.add(iCollection);
InstanceofExpression iSet = new InstanceofExpression("java.util.Set");
InstanceofExpression iList = new InstanceofExpression("java.util.List");
assertEquals(EvaluationResult.TRUE, iSet.evaluate(c1));
assertEquals(EvaluationResult.FALSE, iList.evaluate(c1));
assertEquals(EvaluationResult.FALSE, iSet.evaluate(c2));
assertEquals(EvaluationResult.TRUE, iList.evaluate(c2));
assertEquals(EvaluationResult.FALSE, iSet.evaluate(c3));
assertEquals(EvaluationResult.TRUE, iList.evaluate(c3));
assertEquals(EvaluationResult.TRUE, with.evaluate(context));
}
use of org.eclipse.core.internal.expressions.InstanceofExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testInstanceofTrue.
public void testInstanceofTrue() throws Exception {
B b = new B();
EvaluationContext context = new EvaluationContext(null, b);
// $NON-NLS-1$
InstanceofExpression exp = new InstanceofExpression("org.eclipse.core.internal.expressions.tests.B");
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
// $NON-NLS-1$
exp = new InstanceofExpression("org.eclipse.core.internal.expressions.tests.A");
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
// $NON-NLS-1$
exp = new InstanceofExpression("org.eclipse.core.internal.expressions.tests.I");
assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
}
use of org.eclipse.core.internal.expressions.InstanceofExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testAdaptExpressionNotEqual.
public void testAdaptExpressionNotEqual() 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.Adapter1"));
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.Adapter2"));
assertTrue("These adapt expressions should not be equal", !expression1.equals(expression2));
}
use of org.eclipse.core.internal.expressions.InstanceofExpression in project eclipse.platform.runtime by eclipse.
the class ExpressionTests method testInstanceOfExpressionNotEqual.
public void testInstanceOfExpressionNotEqual() throws Exception {
InstanceofExpression expression1 = new InstanceofExpression("+");
InstanceofExpression expression2 = new InstanceofExpression("!");
assertTrue("These instance of expressions should not be equal", !expression1.equals(expression2));
}
Aggregations