Search in sources :

Example 1 with AdaptExpression

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);
}
Also used : IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) IterateExpression(org.eclipse.core.internal.expressions.IterateExpression) WithExpression(org.eclipse.core.internal.expressions.WithExpression) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 2 with AdaptExpression

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);
}
Also used : InstanceofExpression(org.eclipse.core.internal.expressions.InstanceofExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 3 with AdaptExpression

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());
}
Also used : InstanceofExpression(org.eclipse.core.internal.expressions.InstanceofExpression) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression)

Example 4 with AdaptExpression

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);
}
Also used : InstanceofExpression(org.eclipse.core.internal.expressions.InstanceofExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Example 5 with AdaptExpression

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);
}
Also used : InstanceofExpression(org.eclipse.core.internal.expressions.InstanceofExpression) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) AdaptExpression(org.eclipse.core.internal.expressions.AdaptExpression) EvaluationResult(org.eclipse.core.expressions.EvaluationResult)

Aggregations

AdaptExpression (org.eclipse.core.internal.expressions.AdaptExpression)7 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)5 EvaluationResult (org.eclipse.core.expressions.EvaluationResult)5 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)5 InstanceofExpression (org.eclipse.core.internal.expressions.InstanceofExpression)5 IterateExpression (org.eclipse.core.internal.expressions.IterateExpression)1 WithExpression (org.eclipse.core.internal.expressions.WithExpression)1