Search in sources :

Example 1 with EqualsExpression

use of org.eclipse.core.internal.expressions.EqualsExpression in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testEqualsExpressionNotEqual.

public void testEqualsExpressionNotEqual() throws Exception {
    EqualsExpression expression1 = new EqualsExpression("+");
    EqualsExpression expression2 = new EqualsExpression("!");
    assertTrue("These equals expressions should not be equal", !expression1.equals(expression2));
}
Also used : EqualsExpression(org.eclipse.core.internal.expressions.EqualsExpression)

Example 2 with EqualsExpression

use of org.eclipse.core.internal.expressions.EqualsExpression in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testEqualsExpressionHashCode.

public void testEqualsExpressionHashCode() throws Exception {
    EqualsExpression expression1 = new EqualsExpression("*");
    EqualsExpression expression2 = new EqualsExpression("*");
    assertEquals("Equal expressions should have the same hash code", expression1.hashCode(), expression2.hashCode());
}
Also used : EqualsExpression(org.eclipse.core.internal.expressions.EqualsExpression)

Example 3 with EqualsExpression

use of org.eclipse.core.internal.expressions.EqualsExpression in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testWithExpressionNoVariable.

public void testWithExpressionNoVariable() throws Exception {
    WithExpression expr = new WithExpression("variable");
    expr.add(new EqualsExpression(new Object()));
    EvaluationContext context = new EvaluationContext(null, new Object());
    try {
        expr.evaluate(context);
        fail("Should throw exceptoin");
    } catch (CoreException e) {
    // this is success
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) WithExpression(org.eclipse.core.internal.expressions.WithExpression) EqualsExpression(org.eclipse.core.internal.expressions.EqualsExpression)

Example 4 with EqualsExpression

use of org.eclipse.core.internal.expressions.EqualsExpression in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testEqualsExpression.

public void testEqualsExpression() throws Exception {
    // $NON-NLS-1$
    EqualsExpression exp = new EqualsExpression("name");
    // $NON-NLS-1$
    EvaluationContext context = new EvaluationContext(null, "name");
    assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
    exp = new EqualsExpression(Boolean.TRUE);
    context = new EvaluationContext(null, Boolean.TRUE);
    assertTrue(EvaluationResult.TRUE == exp.evaluate(context));
    // $NON-NLS-1$
    exp = new EqualsExpression("name");
    context = new EvaluationContext(null, Boolean.TRUE);
    assertTrue(EvaluationResult.FALSE == exp.evaluate(context));
}
Also used : IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) EqualsExpression(org.eclipse.core.internal.expressions.EqualsExpression)

Example 5 with EqualsExpression

use of org.eclipse.core.internal.expressions.EqualsExpression in project eclipse.platform.runtime by eclipse.

the class ExpressionTests method testWithExpressionUndefinedVariable.

public void testWithExpressionUndefinedVariable() throws Exception {
    WithExpression expr = new WithExpression("variable");
    expr.add(new EqualsExpression(new Object()));
    EvaluationContext context = new EvaluationContext(null, new Object());
    context.addVariable("variable", IEvaluationContext.UNDEFINED_VARIABLE);
    assertEquals(EvaluationResult.FALSE, expr.evaluate(context));
}
Also used : IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) EvaluationContext(org.eclipse.core.expressions.EvaluationContext) WithExpression(org.eclipse.core.internal.expressions.WithExpression) EqualsExpression(org.eclipse.core.internal.expressions.EqualsExpression)

Aggregations

EqualsExpression (org.eclipse.core.internal.expressions.EqualsExpression)5 EvaluationContext (org.eclipse.core.expressions.EvaluationContext)3 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)3 WithExpression (org.eclipse.core.internal.expressions.WithExpression)2 CoreException (org.eclipse.core.runtime.CoreException)1