Search in sources :

Example 6 with Variable

use of org.apache.ratis.examples.arithmetic.expression.Variable in project incubator-ratis by apache.

the class TestAssignCli method createExpression.

@Test
public void createExpression() throws Exception {
    Assert.assertEquals(new DoubleValue(2.0), new Assign().createExpression("2.0"));
    Assert.assertEquals(MULT.apply(2.0, new Variable("a")), new Assign().createExpression("2*a"));
    Assert.assertEquals(ADD.apply(2.0, 1.0), new Assign().createExpression("2+1"));
    Assert.assertEquals(ADD.apply(new Variable("a"), new Variable("b")), new Assign().createExpression("a+b"));
    Assert.assertEquals(SQRT.apply(new Variable("a")), new Assign().createExpression("√a"));
    Assert.assertEquals(SQRT.apply(2.0), new Assign().createExpression("√2"));
}
Also used : Variable(org.apache.ratis.examples.arithmetic.expression.Variable) DoubleValue(org.apache.ratis.examples.arithmetic.expression.DoubleValue) Test(org.junit.Test)

Aggregations

Variable (org.apache.ratis.examples.arithmetic.expression.Variable)6 Expression (org.apache.ratis.examples.arithmetic.expression.Expression)3 DoubleValue (org.apache.ratis.examples.arithmetic.expression.DoubleValue)1 RaftClientReply (org.apache.ratis.protocol.RaftClientReply)1 Test (org.junit.Test)1