2 package jp.sourceforge.rpn_computer.test;
4 import jp.sourceforge.rpn_computer.ParseException;
5 import jp.sourceforge.rpn_computer.RpnNode;
6 import jp.sourceforge.rpn_computer.RpnParser;
7 import jp.sourceforge.rpn_computer.node.ExpressionStatementNode;
8 import jp.sourceforge.rpn_computer.node.FloatingPointLiteralNode;
9 import jp.sourceforge.rpn_computer.node.FunctionExpressionNode;
10 import jp.sourceforge.rpn_computer.node.IntegerLiteralNode;
11 import junit.framework.TestCase;
13 public class RpnParserTest extends TestCase {
15 public RpnParserTest(String name) {
19 public void testFail_null1() {
22 RpnParser parser = new RpnParser();
26 } catch (NullPointerException e) {
27 assertEquals("expressionがnullです。", e.getMessage());
31 public void testFail_EmptyStatement() {
34 RpnParser parser = new RpnParser();
38 } catch (ParseException e) {
42 public void testNormal_IntegerLiteral1() {
45 RpnParser parser = new RpnParser();
46 RpnNode expression = parser.parse(exp);
48 assertTrue(expression instanceof ExpressionStatementNode);
49 assertEquals(1, expression.getChildren().length);
51 RpnNode integerLiteral = expression.getChildren()[0];
52 assertTrue(integerLiteral instanceof IntegerLiteralNode);
53 assertEquals("1", ((IntegerLiteralNode) integerLiteral).getValue());
54 assertEquals(0, integerLiteral.getChildren().length);
57 public void testNormal_IntegerLiteral2() {
58 String exp = "123456789";
60 RpnParser parser = new RpnParser();
61 RpnNode expression = parser.parse(exp);
63 assertTrue(expression instanceof ExpressionStatementNode);
64 assertEquals(1, expression.getChildren().length);
66 RpnNode integerLiteral = expression.getChildren()[0];
67 assertTrue(integerLiteral instanceof IntegerLiteralNode);
68 assertEquals("123456789", ((IntegerLiteralNode) integerLiteral).getValue());
69 assertEquals(0, integerLiteral.getChildren().length);
72 public void testNormal_IntegerLiteral3() {
73 String exp = "0xfFff";
75 RpnParser parser = new RpnParser();
76 RpnNode expression = parser.parse(exp);
78 assertTrue(expression instanceof ExpressionStatementNode);
79 assertEquals(1, expression.getChildren().length);
81 RpnNode integerLiteral = expression.getChildren()[0];
82 assertTrue(integerLiteral instanceof IntegerLiteralNode);
83 assertEquals("0xfFff", ((IntegerLiteralNode) integerLiteral).getValue());
84 assertEquals(0, integerLiteral.getChildren().length);
87 public void testNormal_IntegerLiteral4() {
90 RpnParser parser = new RpnParser();
91 RpnNode expression = parser.parse(exp);
93 assertTrue(expression instanceof ExpressionStatementNode);
94 assertEquals(1, expression.getChildren().length);
96 RpnNode integerLiteral = expression.getChildren()[0];
97 assertTrue(integerLiteral instanceof IntegerLiteralNode);
98 assertEquals("07777", ((IntegerLiteralNode) integerLiteral).getValue());
99 assertEquals(0, integerLiteral.getChildren().length);
102 public void testNormal_IntegerLiteral5() {
105 RpnParser parser = new RpnParser();
106 RpnNode expression = parser.parse(exp);
108 assertTrue(expression instanceof ExpressionStatementNode);
109 assertEquals(1, expression.getChildren().length);
111 RpnNode integerLiteral = expression.getChildren()[0];
112 assertTrue(integerLiteral instanceof IntegerLiteralNode);
113 assertEquals("0", ((IntegerLiteralNode) integerLiteral).getValue());
114 assertEquals(0, integerLiteral.getChildren().length);
117 public void testFail_IntegerLiteral1() {
118 String exp = "123456789123456789123456789";
120 RpnParser parser = new RpnParser();
124 } catch (ParseException e) {
128 public void testFail_IntegerLiteral2() {
129 String exp = "123,456,789";
131 RpnParser parser = new RpnParser();
135 } catch (ParseException e) {
139 public void testNormal_FloatingPointLiteral1() {
140 String exp = "123.456";
142 RpnParser parser = new RpnParser();
143 RpnNode expression = parser.parse(exp);
145 assertTrue(expression instanceof ExpressionStatementNode);
146 assertEquals(1, expression.getChildren().length);
148 RpnNode floatingPointLiteral = expression.getChildren()[0];
149 assertTrue(floatingPointLiteral instanceof FloatingPointLiteralNode);
150 assertEquals("123.456", ((FloatingPointLiteralNode) floatingPointLiteral).getValue());
151 assertEquals(0, floatingPointLiteral.getChildren().length);
154 public void testNormal_FloatingPointLiteral2() {
155 String exp = "0.123456";
157 RpnParser parser = new RpnParser();
158 RpnNode expression = parser.parse(exp);
160 assertTrue(expression instanceof ExpressionStatementNode);
161 assertEquals(1, expression.getChildren().length);
163 RpnNode floatingPointLiteral = expression.getChildren()[0];
164 assertTrue(floatingPointLiteral instanceof FloatingPointLiteralNode);
165 assertEquals("0.123456", ((FloatingPointLiteralNode) floatingPointLiteral).getValue());
166 assertEquals(0, floatingPointLiteral.getChildren().length);
169 public void testNormal_FloatingPointLiteral3() {
170 String exp = ".123456";
172 RpnParser parser = new RpnParser();
173 RpnNode expression = parser.parse(exp);
175 assertTrue(expression instanceof ExpressionStatementNode);
176 assertEquals(1, expression.getChildren().length);
178 RpnNode floatingPointLiteral = expression.getChildren()[0];
179 assertTrue(floatingPointLiteral instanceof FloatingPointLiteralNode);
180 assertEquals(".123456", ((FloatingPointLiteralNode) floatingPointLiteral).getValue());
181 assertEquals(0, floatingPointLiteral.getChildren().length);
184 public void testNormal_FloatingPointLiteral4() {
187 RpnParser parser = new RpnParser();
188 RpnNode expression = parser.parse(exp);
190 assertTrue(expression instanceof ExpressionStatementNode);
191 assertEquals(1, expression.getChildren().length);
193 RpnNode floatingPointLiteral = expression.getChildren()[0];
194 assertTrue(floatingPointLiteral instanceof FloatingPointLiteralNode);
195 assertEquals("0.0", ((FloatingPointLiteralNode) floatingPointLiteral).getValue());
196 assertEquals(0, floatingPointLiteral.getChildren().length);
199 public void testNormal_FloatingPointLiteral5() {
202 RpnParser parser = new RpnParser();
203 RpnNode expression = parser.parse(exp);
205 assertTrue(expression instanceof ExpressionStatementNode);
206 assertEquals(1, expression.getChildren().length);
208 RpnNode floatingPointLiteral = expression.getChildren()[0];
209 assertTrue(floatingPointLiteral instanceof FloatingPointLiteralNode);
210 assertEquals(".0", ((FloatingPointLiteralNode) floatingPointLiteral).getValue());
211 assertEquals(0, floatingPointLiteral.getChildren().length);
214 public void testFail_FloatingPointLiteral1() {
215 String exp = "123.456.789";
217 RpnParser parser = new RpnParser();
221 } catch (ParseException e) {
225 public void testNormal_FunctionExpression1() {
226 String exp = "foo()";
228 RpnParser parser = new RpnParser();
229 RpnNode expression = parser.parse(exp);
231 assertTrue(expression instanceof ExpressionStatementNode);
232 assertEquals(1, expression.getChildren().length);
234 RpnNode function = expression.getChildren()[0];
235 assertTrue(function instanceof FunctionExpressionNode);
236 assertEquals(3, function.getChildren().length);
238 RpnNode functionName = function.getChildren()[0];
239 assertTrue(functionName instanceof FunctionExpressionNode.FunctionNameNode);
240 assertEquals("foo", ((FunctionExpressionNode.FunctionNameNode) functionName).getName());
241 assertEquals(0, functionName.getChildren().length);
243 RpnNode leftBracket = function.getChildren()[1];
244 assertTrue(leftBracket instanceof FunctionExpressionNode.LeftBracketNode);
245 assertEquals(0, leftBracket.getChildren().length);
247 RpnNode rightBracket = function.getChildren()[2];
248 assertTrue(rightBracket instanceof FunctionExpressionNode.RightBracketNode);
249 assertEquals(0, rightBracket.getChildren().length);
252 public void testNormal_FunctionExpression2() {
253 String exp = "foo(1, 2)";
255 RpnParser parser = new RpnParser();
256 RpnNode expression = parser.parse(exp);
258 assertTrue(expression instanceof ExpressionStatementNode);
259 assertEquals(1, expression.getChildren().length);
261 RpnNode function = expression.getChildren()[0];
262 assertTrue(function instanceof FunctionExpressionNode);
263 assertEquals(6, function.getChildren().length);
265 RpnNode functionName = function.getChildren()[0];
266 assertTrue(functionName instanceof FunctionExpressionNode.FunctionNameNode);
267 assertEquals("foo", ((FunctionExpressionNode.FunctionNameNode) functionName).getName());
268 assertEquals(0, functionName.getChildren().length);
270 RpnNode leftBracket = function.getChildren()[1];
271 assertTrue(leftBracket instanceof FunctionExpressionNode.LeftBracketNode);
272 assertEquals(0, leftBracket.getChildren().length);
274 RpnNode integerLiteral = function.getChildren()[2];
275 assertTrue(integerLiteral instanceof IntegerLiteralNode);
276 assertEquals("1", ((IntegerLiteralNode) integerLiteral).getValue());
277 assertEquals(0, integerLiteral.getChildren().length);
279 RpnNode comma = function.getChildren()[3];
280 assertTrue(comma instanceof FunctionExpressionNode.CommaNode);
281 assertEquals(0, comma.getChildren().length);
283 integerLiteral = function.getChildren()[4];
284 assertTrue(integerLiteral instanceof IntegerLiteralNode);
285 assertEquals("2", ((IntegerLiteralNode) integerLiteral).getValue());
286 assertEquals(0, integerLiteral.getChildren().length);
288 RpnNode rightBracket = function.getChildren()[5];
289 assertTrue(rightBracket instanceof FunctionExpressionNode.RightBracketNode);
290 assertEquals(0, rightBracket.getChildren().length);
293 public void testNormal_FunctionExpression3() {
294 String exp = "foo(1 + 2)";
296 RpnParser parser = new RpnParser();
297 RpnNode expression = parser.parse(exp);
299 assertTrue(expression instanceof ExpressionStatementNode);
300 assertEquals(1, expression.getChildren().length);
302 RpnNode function = expression.getChildren()[0];
303 assertTrue(function instanceof FunctionExpressionNode);
304 assertEquals(6, function.getChildren().length);
306 RpnNode functionName = function.getChildren()[0];
307 assertTrue(functionName instanceof FunctionExpressionNode.FunctionNameNode);
308 assertEquals("foo", ((FunctionExpressionNode.FunctionNameNode) functionName).getName());
309 assertEquals(0, functionName.getChildren().length);
311 RpnNode leftBracket = function.getChildren()[1];
312 assertTrue(leftBracket instanceof FunctionExpressionNode.LeftBracketNode);
313 assertEquals(0, leftBracket.getChildren().length);
315 RpnNode integerLiteral = function.getChildren()[2];
316 assertTrue(integerLiteral instanceof IntegerLiteralNode);
317 assertEquals("1", ((IntegerLiteralNode) integerLiteral).getValue());
318 assertEquals(0, integerLiteral.getChildren().length);
320 RpnNode comma = function.getChildren()[3];
321 assertTrue(comma instanceof FunctionExpressionNode.CommaNode);
322 assertEquals(0, comma.getChildren().length);
324 integerLiteral = function.getChildren()[4];
325 assertTrue(integerLiteral instanceof IntegerLiteralNode);
326 assertEquals("2", ((IntegerLiteralNode) integerLiteral).getValue());
327 assertEquals(0, integerLiteral.getChildren().length);
329 RpnNode rightBracket = function.getChildren()[5];
330 assertTrue(rightBracket instanceof FunctionExpressionNode.RightBracketNode);
331 assertEquals(0, rightBracket.getChildren().length);
334 public void testNormal_FunctionExpression4() {
335 String exp = "foo() + bar()";
340 public void testFail_FunctionExpression1() {
341 String exp = "foo()";
343 RpnParser parser = new RpnParser();
347 } catch (ParseException e) {
351 public void testFail_FunctionExpression3() {
352 String exp = "foo(10, )";
354 RpnParser parser = new RpnParser();
358 } catch (ParseException e) {
362 public void testFail_FunctionExpression4() {
365 RpnParser parser = new RpnParser();
369 } catch (ParseException e) {
373 public void testFail_FunctionExpression5() {
376 RpnParser parser = new RpnParser();
380 } catch (ParseException e) {
384 public void testFail_FunctionExpression6() {
385 String exp = "foo(10 10)";
387 RpnParser parser = new RpnParser();
391 } catch (ParseException e) {
395 public void testNormal_Variable1() {
401 public void testNormal_Variable2() {
402 String exp = "abc123_";
407 public void testNormal_Variable3() {
413 public void testNormal_Variable4() {
419 public void testFail_Variable1() {
420 String exp = "123abc";
422 RpnParser parser = new RpnParser();
426 } catch (ParseException e) {
430 public void testNormal_ParenthesesExpression1() {
431 String exp = "(1 + 2)";
436 public void testNormal_ParenthesesExpression2() {
437 String exp = "(1 + (2 - 3))";
442 public void testFail_ParenthesesExpression1() {
445 RpnParser parser = new RpnParser();
449 } catch (ParseException e) {
453 public void testFail_ParenthesesExpression2() {
454 String exp = "(1 + 2";
456 RpnParser parser = new RpnParser();
460 } catch (ParseException e) {
464 public void testFail_ParenthesesExpression3() {
465 String exp = "1 + 2)";
467 RpnParser parser = new RpnParser();
471 } catch (ParseException e) {
475 public void testNormal_PreIncrementExpression1() {
481 public void testFail_PreIncrementExpression1() {
484 RpnParser parser = new RpnParser();
488 } catch (ParseException e) {
492 public void testFail_PreIncrementExpression2() {
493 String exp = "++++x";
495 RpnParser parser = new RpnParser();
499 } catch (ParseException e) {
503 public void testFail_PreIncrementExpression3() {
504 String exp = "++(++x)";
506 RpnParser parser = new RpnParser();
510 } catch (ParseException e) {
514 public void testNormal_PostIncrementExpression1() {
520 public void testFail_PostIncrementExpression1() {
523 RpnParser parser = new RpnParser();
527 } catch (ParseException e) {
531 public void testFail_PostIncrementExpression2() {
532 String exp = "x++++";
534 RpnParser parser = new RpnParser();
538 } catch (ParseException e) {
542 public void testFail_PostIncrementExpression3() {
543 String exp = "(x++)++";
545 RpnParser parser = new RpnParser();
549 } catch (ParseException e) {
553 public void testNormal_PreDecrementExpression1() {
559 public void testFail_PreDecrementExpression1() {
562 RpnParser parser = new RpnParser();
566 } catch (ParseException e) {
570 public void testFail_PreDecrementExpression2() {
571 String exp = "----x";
573 RpnParser parser = new RpnParser();
577 } catch (ParseException e) {
581 public void testFail_PreDecrementExpression3() {
582 String exp = "--(--x)";
584 RpnParser parser = new RpnParser();
588 } catch (ParseException e) {
592 public void testNormal_PostDecrementExpression1() {
598 public void testFail_PostDecrementExpression1() {
601 RpnParser parser = new RpnParser();
605 } catch (ParseException e) {
609 public void testFail_PostDecrementExpression2() {
610 String exp = "x----";
612 RpnParser parser = new RpnParser();
616 } catch (ParseException e) {
620 public void testFail_PostDecrementExpression3() {
621 String exp = "(x--)--";
623 RpnParser parser = new RpnParser();
627 } catch (ParseException e) {
631 public void testNormal_UnaryExpressionNotPlusMinus1() {
637 public void testNormal_UnaryExpressionNotPlusMinus2() {
643 public void testNormal_UnaryExpressionNotPlusMinus3() {
644 String exp = "~(~1)";
649 public void testNormal_UnaryExpressionNotPlusMinus4() {
655 public void testNormal_UnaryExpressionNotPlusMinus5() {
661 public void testNormal_UnaryExpressionNotPlusMinus6() {
667 public void testNormal_UnaryExpressionNotPlusMinus7() {
668 String exp = "!(!9)";
673 public void testFail_UnaryExpressionNotPlusMinus1() {
676 RpnParser parser = new RpnParser();
680 } catch (ParseException e) {
684 public void testFail_UnaryExpressionNotPlusMinus2() {
687 RpnParser parser = new RpnParser();
691 } catch (ParseException e) {
695 public void testNormal_UnaryExpression1() {
701 public void testNormal_UnaryExpression2() {
707 public void testNormal_UnaryExpression3() {
708 String exp = "+(+999)";
713 public void testNormal_UnaryExpression4() {
714 String exp = "+(+x)";
719 public void testNormal_UnaryExpression5() {
725 public void testNormal_UnaryExpression6() {
731 public void testNormal_UnaryExpression7() {
732 String exp = "-(-999)";
737 public void testNormal_UnaryExpression8() {
738 String exp = "-(-x)";
743 public void testFail_UnaryExpression1() {
746 RpnParser parser = new RpnParser();
750 } catch (ParseException e) {
754 public void testFail_UnaryExpression2() {
757 RpnParser parser = new RpnParser();
761 } catch (ParseException e) {
765 public void testNormal_MultiplicativeExpression1() {
766 String exp = "2 * 3";
771 public void testNormal_MultiplicativeExpression2() {
772 String exp = "4 / 2";
777 public void testNormal_MultiplicativeExpression3() {
778 String exp = "10 % 3";
783 public void testNormal_MultiplicativeExpression4() {
784 String exp = "2 * 6 / 3 % 3";
789 public void testNormal_MultiplicativeExpression5() {
790 String exp = "1 / 0";
795 public void testNormal_MultiplicativeExpression6() {
796 String exp = "0 / 0";
801 public void testFail_MultiplicativeExpression1() {
802 String exp = "2 * * 3";
804 RpnParser parser = new RpnParser();
808 } catch (ParseException e) {
812 public void testFail_MultiplicativeExpression2() {
813 String exp = "2 / / 3";
815 RpnParser parser = new RpnParser();
819 } catch (ParseException e) {
823 public void testFail_MultiplicativeExpression3() {
824 String exp = "2 % % 3";
826 RpnParser parser = new RpnParser();
830 } catch (ParseException e) {
834 public void testFail_MultiplicativeExpression4() {
837 RpnParser parser = new RpnParser();
841 } catch (ParseException e) {
845 public void testNormal_AdditiveExpression1() {
846 String exp = "1 + 2";
851 public void testNormal_AdditiveExpression2() {
852 String exp = "1 - 2";
857 public void testNormal_AdditiveExpression3() {
858 String exp = "1 - 2 + 3";
863 public void testFail_AdditiveExpression1() {
864 String exp = "1 + + + 1";
866 RpnParser parser = new RpnParser();
870 } catch (ParseException e) {
874 public void testFail_AdditiveExpression2() {
875 String exp = "1 - - - 1";
877 RpnParser parser = new RpnParser();
881 } catch (ParseException e) {
885 public void testFail_AdditiveExpression3() {
888 RpnParser parser = new RpnParser();
892 } catch (ParseException e) {
896 public void testNormal_ShiftExpression1() {
897 String exp = "0 << 1";
902 public void testNormal_ShiftExpression2() {
903 String exp = "123 << 3";
908 public void testNormal_ShiftExpression3() {
909 String exp = "0 >> 1";
914 public void testNormal_ShiftExpression4() {
915 String exp = "123 >> 1";
920 public void testNormal_ShiftExpression5() {
921 String exp = "-123 >> 1";
926 public void testNormal_ShiftExpression6() {
927 String exp = "0 >>> 1";
932 public void testNormal_ShiftExpression7() {
933 String exp = "123 >>> 1";
938 public void testNormal_ShiftExpression8() {
939 String exp = "-123 >>> 1";
944 public void testNormal_ShiftExpression9() {
945 String exp = "123.456 << 3.456";
950 public void testNormal_ShiftExpression10() {
951 String exp = "1 << 2 << 3";
956 public void testFail_ShiftExpression1() {
957 String exp = "1 << << 1";
959 RpnParser parser = new RpnParser();
963 } catch (ParseException e) {
967 public void testFail_ShiftExpression2() {
968 String exp = "1 >> >> 1";
970 RpnParser parser = new RpnParser();
974 } catch (ParseException e) {
978 public void testFail_ShiftExpression3() {
979 String exp = "1 >>> >>> 1";
981 RpnParser parser = new RpnParser();
985 } catch (ParseException e) {
989 public void testFail_ShiftExpression4() {
990 String exp = "1 <<<< 1";
992 RpnParser parser = new RpnParser();
996 } catch (ParseException e) {
1000 public void testNormal_RelationalExpression1() {
1001 String exp = "123 > 122";
1006 public void testNormal_RelationalExpression2() {
1007 String exp = "123.1 > 123.2";
1012 public void testNormal_RelationalExpression3() {
1013 String exp = "123.1 > 123.1";
1018 public void testNormal_RelationalExpression4() {
1019 String exp = "122 < 123";
1024 public void testNormal_RelationalExpression5() {
1025 String exp = "123.2 < 123.1";
1030 public void testNormal_RelationalExpression6() {
1031 String exp = "123.2 < 123.2";
1036 public void testNormal_RelationalExpression7() {
1037 String exp = "123 >= 122";
1042 public void testNormal_RelationalExpression8() {
1043 String exp = "123.1 >= 123.2";
1048 public void testNormal_RelationalExpression9() {
1049 String exp = "123.1 >= 123.1";
1054 public void testNormal_RelationalExpression10() {
1055 String exp = "122 <= 123";
1060 public void testNormal_RelationalExpression11() {
1061 String exp = "123.2 <= 123.1";
1066 public void testNormal_RelationalExpression12() {
1067 String exp = "123.1 <= 123.1";
1072 public void testNormal_RelationalExpression13() {
1073 String exp = "0 > 0 > 0";
1078 public void testFail_RelationalExpression1() {
1079 String exp = "1 > > 2";
1081 RpnParser parser = new RpnParser();
1085 } catch (ParseException e) {
1089 public void testFail_RelationalExpression2() {
1090 String exp = "1 < < 2";
1092 RpnParser parser = new RpnParser();
1096 } catch (ParseException e) {
1100 public void testFail_RelationalExpression3() {
1101 String exp = "1 >= >= 2";
1103 RpnParser parser = new RpnParser();
1107 } catch (ParseException e) {
1111 public void testFail_RelationalExpression4() {
1112 String exp = "1 <= <= 2";
1114 RpnParser parser = new RpnParser();
1118 } catch (ParseException e) {
1122 public void testNormal_EqualityExpression1() {
1123 String exp = "123.456 == 123.456";
1128 public void testNormal_EqualityExpression2() {
1129 String exp = "123.456 == 123.4567";
1134 public void testNormal_EqualityExpression3() {
1135 String exp = "123.456 != 123.456";
1140 public void testNormal_EqualityExpression4() {
1141 String exp = "123.456 != 123.4567";
1146 public void testNormal_EqualityExpression5() {
1147 String exp = "NaN == NaN";
1152 public void testNormal_EqualityExpression6() {
1153 String exp = "NaN != NaN";
1158 public void testNormal_EqualityExpression7() {
1159 String exp = "0 == 0 == 0";
1164 public void testFail_EqualityExpression1() {
1165 String exp = "1 == == 2";
1167 RpnParser parser = new RpnParser();
1171 } catch (ParseException e) {
1175 public void testFail_EqualityExpression2() {
1176 String exp = "1 != != 2";
1178 RpnParser parser = new RpnParser();
1182 } catch (ParseException e) {
1186 public void testNormal_AndExpression1() {
1187 String exp = "123 & 456";
1192 public void testNormal_AndExpression2() {
1193 String exp = "123.456 & 456.789";
1198 public void testNormal_AndExpression3() {
1199 String exp = "123 & 456 & 789";
1204 public void testFail_AndExpression1() {
1205 String exp = "123 & & 456";
1207 RpnParser parser = new RpnParser();
1211 } catch (ParseException e) {
1216 public void testNormal_ExclusiveOrExpression1() {
1217 String exp = "123 ^ 456";
1222 public void testNormal_ExclusiveOrExpression2() {
1223 String exp = "123.456 ^ 456.789";
1228 public void testNormal_ExclusiveOrExpression3() {
1229 String exp = "123 ^ 456 ^ 789";
1234 public void testFail_ExclusiveOrExpression1() {
1235 String exp = "123 ^ ^ 456";
1237 RpnParser parser = new RpnParser();
1241 } catch (ParseException e) {
1245 public void testNormal_InclusiveOrExpression1() {
1246 String exp = "123 | 456";
1251 public void testNormal_InclusiveOrExpression2() {
1252 String exp = "123.456 | 456.789";
1257 public void testNormal_InclusiveOrExpression3() {
1258 String exp = "123 | 456 | 789";
1263 public void testFail_InclusiveOrExpression1() {
1264 String exp = "123 | | 456";
1266 RpnParser parser = new RpnParser();
1270 } catch (ParseException e) {
1274 public void testNormal_ConditionalAndExpression1() {
1275 String exp = "0 && 0";
1280 public void testNormal_ConditionalAndExpression2() {
1281 String exp = "0 && 1";
1286 public void testNormal_ConditionalAndExpression3() {
1287 String exp = "0 && 123.456";
1292 public void testNormal_ConditionalAndExpression4() {
1293 String exp = "1 && 0";
1298 public void testNormal_ConditionalAndExpression5() {
1299 String exp = "123.456 && 0";
1304 public void testNormal_ConditionalAndExpression6() {
1305 String exp = "1 && 1";
1310 public void testNormal_ConditionalAndExpression7() {
1311 String exp = "123.456 && 123.456";
1316 public void testFail_ConditionalAndExpression1() {
1317 String exp = "0 && && 0";
1319 RpnParser parser = new RpnParser();
1323 } catch (ParseException e) {
1327 public void testNormal_ConditionalOrExpression1() {
1328 String exp = "0 || 0";
1333 public void testNormal_ConditionalOrExpression2() {
1334 String exp = "0 || 1";
1339 public void testNormal_ConditionalOrExpression3() {
1340 String exp = "0 || 123.456";
1345 public void testNormal_ConditionalOrExpression4() {
1346 String exp = "1 || 0";
1351 public void testNormal_ConditionalOrExpression5() {
1352 String exp = "123.456 || 0";
1357 public void testNormal_ConditionalOrExpression6() {
1358 String exp = "1 || 1";
1363 public void testNormal_ConditionalOrExpression7() {
1364 String exp = "123.456 || 123.456";
1369 public void testFail_ConditionalOrExpression1() {
1370 String exp = "0 || || 0";
1372 RpnParser parser = new RpnParser();
1376 } catch (ParseException e) {
1380 public void testNormal_ConditionalExpression1() {
1381 String exp = "0 ? 123 : 456";
1386 public void testNormal_ConditionalExpression2() {
1387 String exp = "1 ? 123 : 456";
1392 public void testNormal_ConditionalExpression3() {
1393 String exp = "789 ? 123 : 456";
1398 public void testNormal_ConditionalExpression4() {
1399 String exp = "0 ? 1 : 2 ? 3 : 4";
1404 public void testFail_ConditionalExpression2() {
1405 String exp = "0 ? 1";
1407 RpnParser parser = new RpnParser();
1411 } catch (ParseException e) {
1415 public void testFail_ConditionalExpression3() {
1416 String exp = "1 : 2";
1418 RpnParser parser = new RpnParser();
1422 } catch (ParseException e) {
1426 public void testFail_ConditionalExpression4() {
1427 String exp = "0 ? 1 ? 2";
1429 RpnParser parser = new RpnParser();
1433 } catch (ParseException e) {
1437 public void testNormal_AssignmentExpression1() {
1438 String exp = "x = 123";
1443 public void testNormal_AssignmentExpression2() {
1444 String exp = "x += 1";
1449 public void testNormal_AssignmentExpression3() {
1450 String exp = "x -= 1";
1455 public void testNormal_AssignmentExpression4() {
1456 String exp = "x *= 2";
1461 public void testNormal_AssignmentExpression5() {
1462 String exp = "x /= 3";
1467 public void testNormal_AssignmentExpression6() {
1468 String exp = "x %= 4";
1473 public void testNormal_AssignmentExpression7() {
1474 String exp = "x &= 1";
1479 public void testNormal_AssignmentExpression8() {
1480 String exp = "x ^= 1";
1485 public void testNormal_AssignmentExpression9() {
1486 String exp = "x |= 1";
1491 public void testNormal_AssignmentExpression10() {
1492 String exp = "x <<= 1";
1497 public void testNormal_AssignmentExpression11() {
1498 String exp = "x >>= 1";
1503 public void testNormal_AssignmentExpression12() {
1504 String exp = "x >>>= 1";
1509 public void testNormal_AssignmentExpression13() {
1510 String exp = "x = y = 1";
1515 public void testFail_AssignmentExpression1() {
1516 String exp = "x = = 1";
1518 RpnParser parser = new RpnParser();
1522 } catch (ParseException e) {