Skip to content

Commit 232ef72

Browse files
committed
Create LongOperationTest.java
1 parent dbdf3a7 commit 232ef72

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.github.kayjamlang.tests.expressions.operation;
2+
3+
import com.github.kayjamlang.core.expressions.Expression;
4+
import com.github.kayjamlang.core.expressions.OperationExpression;
5+
import com.github.kayjamlang.core.expressions.ValueExpression;
6+
import com.github.kayjamlang.core.expressions.data.Operation;
7+
import com.github.kayjamlang.tests.TestsUtils;
8+
import org.junit.Test;
9+
10+
import static org.junit.Assert.*;
11+
import static org.junit.Assert.assertSame;
12+
13+
public class LongOperationTest {
14+
15+
@Test
16+
public void test() throws Exception {
17+
Expression expression = TestsUtils.parse("2 + 4 * 8");
18+
19+
assertNotNull(expression);
20+
assertSame(OperationExpression.class, expression.getClass());
21+
22+
OperationExpression operationExpression = (OperationExpression) expression;
23+
assertEquals(Operation.PLUS, operationExpression.operation);
24+
assertSame(ValueExpression.class, operationExpression.left.getClass());
25+
assertSame(OperationExpression.class, operationExpression.right.getClass());
26+
27+
OperationExpression rightOperationExpression = (OperationExpression) operationExpression.right;
28+
assertEquals(Operation.MULTIPLY, rightOperationExpression.operation);
29+
assertSame(ValueExpression.class, rightOperationExpression.right.getClass());
30+
}
31+
}

0 commit comments

Comments
 (0)