@@ -1128,6 +1128,10 @@ public void testMinusSignHandling() throws Exception {
11281128 this .verifyExecute ("msg(5- 2)" , "3" );
11291129 this .verifyExecute ("msg(5 -2)" , "3" );
11301130 this .verifyExecute ("msg(5-2)" , "3" );
1131+ this .verifyExecute ("msg(0x05 - 2)" , "3" );
1132+ this .verifyExecute ("msg(0x05- 2)" , "3" );
1133+ this .verifyExecute ("msg(0x05 -2)" , "3" );
1134+ this .verifyExecute ("msg(0x05-2)" , "3" );
11311135 this .verifyExecute ("@arr = array(5); msg(@arr[0] - 2)" , "3" );
11321136 this .verifyExecute ("@arr = array(5); msg(@arr[0]- 2)" , "3" );
11331137 this .verifyExecute ("@arr = array(5); msg(@arr[0] -2)" , "3" );
@@ -1142,6 +1146,10 @@ public void testMinusSignHandling() throws Exception {
11421146 this .verifyExecute ("msg(abs(5)-2)" , "3" );
11431147
11441148 // "2 - ...".
1149+ this .verifyExecute ("msg(2 - 0x05)" , "-3" );
1150+ this .verifyExecute ("msg(2- 0x05)" , "-3" );
1151+ this .verifyExecute ("msg(2 -0x05)" , "-3" );
1152+ this .verifyExecute ("msg(2-0x05)" , "-3" );
11451153 this .verifyExecute ("@arr = array(5); msg(2 - @arr[0])" , "-3" );
11461154 this .verifyExecute ("@arr = array(5); msg(2- @arr[0])" , "-3" );
11471155 this .verifyExecute ("@arr = array(5); msg(2 -@arr[0])" , "-3" );
@@ -1154,7 +1162,7 @@ public void testMinusSignHandling() throws Exception {
11541162 this .verifyExecute ("msg(2- abs(5))" , "-3" );
11551163 this .verifyExecute ("msg(2 -abs(5))" , "-3" );
11561164 this .verifyExecute ("msg(2-abs(5))" , "-3" );
1157-
1165+
11581166 // "- something".
11591167 this .verifyExecute ("msg(-5)" , "-5" );
11601168 this .verifyExecute ("msg(typeof(-5))" , "int" );
@@ -1165,6 +1173,62 @@ public void testMinusSignHandling() throws Exception {
11651173 this .verifyExecute ("@a = 5; msg(- @a)" , "-5" );
11661174 this .verifyExecute ("@a = 5; msg(typeof(- @a))" , "int" );
11671175 }
1176+
1177+ @ Test
1178+ public void testPlusSignHandling () throws Exception {
1179+ // This tests a specific lexer part where token TType.PLUS ('+' sign) is merged with the next token
1180+ // based on whether the PLUS is used as a positive sign or a mathematical operator.
1181+
1182+ // "... + 2".
1183+ this .verifyExecute ("msg(5 + 2)" , "7" );
1184+ this .verifyExecute ("msg(5+ 2)" , "7" );
1185+ this .verifyExecute ("msg(5 +2)" , "7" );
1186+ this .verifyExecute ("msg(5+2)" , "7" );
1187+ this .verifyExecute ("msg(0x05 + 2)" , "7" );
1188+ this .verifyExecute ("msg(0x05+ 2)" , "7" );
1189+ this .verifyExecute ("msg(0x05 +2)" , "7" );
1190+ this .verifyExecute ("msg(0x05+2)" , "7" );
1191+ this .verifyExecute ("@arr = array(5); msg(@arr[0] + 2)" , "7" );
1192+ this .verifyExecute ("@arr = array(5); msg(@arr[0]+ 2)" , "7" );
1193+ this .verifyExecute ("@arr = array(5); msg(@arr[0] +2)" , "7" );
1194+ this .verifyExecute ("@arr = array(5); msg(@arr[0]+2)" , "7" );
1195+ this .verifyExecute ("@a = 5; msg(@a + 2)" , "7" );
1196+ this .verifyExecute ("@a = 5; msg(@a+ 2)" , "7" );
1197+ this .verifyExecute ("@a = 5; msg(@a +2)" , "7" );
1198+ this .verifyExecute ("@a = 5; msg(@a+2)" , "7" );
1199+ this .verifyExecute ("msg(abs(5) + 2)" , "7" );
1200+ this .verifyExecute ("msg(abs(5)+ 2)" , "7" );
1201+ this .verifyExecute ("msg(abs(5) +2)" , "7" );
1202+ this .verifyExecute ("msg(abs(5)+2)" , "7" );
1203+
1204+ // "2 + ...".
1205+ this .verifyExecute ("msg(2 + 0x05)" , "7" );
1206+ this .verifyExecute ("msg(2+ 0x05)" , "7" );
1207+ this .verifyExecute ("msg(2 +0x05)" , "7" );
1208+ this .verifyExecute ("msg(2+0x05)" , "7" );
1209+ this .verifyExecute ("@arr = array(5); msg(2 + @arr[0])" , "7" );
1210+ this .verifyExecute ("@arr = array(5); msg(2+ @arr[0])" , "7" );
1211+ this .verifyExecute ("@arr = array(5); msg(2 +@arr[0])" , "7" );
1212+ this .verifyExecute ("@arr = array(5); msg(2+@arr[0])" , "7" );
1213+ this .verifyExecute ("@a = 5; msg(2 + @a)" , "7" );
1214+ this .verifyExecute ("@a = 5; msg(2+ @a)" , "7" );
1215+ this .verifyExecute ("@a = 5; msg(2 +@a)" , "7" );
1216+ this .verifyExecute ("@a = 5; msg(2+@a)" , "7" );
1217+ this .verifyExecute ("msg(2 + abs(5))" , "7" );
1218+ this .verifyExecute ("msg(2+ abs(5))" , "7" );
1219+ this .verifyExecute ("msg(2 +abs(5))" , "7" );
1220+ this .verifyExecute ("msg(2+abs(5))" , "7" );
1221+
1222+ // "+ something".
1223+ this .verifyExecute ("msg(+5)" , "5" );
1224+ this .verifyExecute ("msg(typeof(+5))" , "int" );
1225+ this .verifyExecute ("msg(+ 5)" , "5" );
1226+ this .verifyExecute ("msg(typeof(+ 5))" , "int" );
1227+ this .verifyExecute ("@a = 5; msg(+@a)" , "5" );
1228+ this .verifyExecute ("@a = 5; msg(typeof(+@a))" , "int" );
1229+ this .verifyExecute ("@a = 5; msg(+ @a)" , "5" );
1230+ this .verifyExecute ("@a = 5; msg(typeof(+ @a))" , "int" );
1231+ }
11681232
11691233 private void verifyExecute (String script , String expectedResponse ) throws ConfigCompileException , ConfigCompileGroupException {
11701234 MCPlayer temp = this .env .getEnv (CommandHelperEnvironment .class ).GetPlayer ();
0 commit comments