@@ -574,21 +574,26 @@ void strings() {
574574
575575 @ Test
576576 void stringRepeat () {
577- evaluate ("'abc' * 0" , "" , String .class );
578- evaluate ("'abc' * 1" , "abc" , String .class );
579- evaluate ("'abc' * 2" , "abcabc" , String .class );
577+ String EMPTY = "" ;
578+ evaluate ("'' * 0" , EMPTY , String .class );
579+ evaluate ("'' * 2" , EMPTY , String .class );
580+ evaluate ("'abc' * 0" , EMPTY , String .class );
581+
582+ evaluate ("'Abc' * 1" , "Abc" , String .class );
583+ evaluate ("'Abc' * 2" , "AbcAbc" , String .class );
584+ evaluate ("'Abc' * 3" , "AbcAbcAbc" , String .class );
580585
581586 Expression expr = parser .parseExpression ("'a' * 256" );
582587 assertThat (expr .getValue (context , String .class )).hasSize (256 );
583588
584- // 4 is the position of the '*' (repeat operator)
585- evaluateAndCheckError ("'a' * 257" , String .class , MAX_REPEATED_TEXT_SIZE_EXCEEDED , 4 );
589+ // 6 is the position of the repeatCount
590+ evaluateAndCheckError ("'a' * 257" , String .class , MAX_REPEATED_TEXT_SIZE_EXCEEDED , 6 );
586591
587592 // Integer overflow: 2 * ((Integer.MAX_VALUE / 2) + 1) --> integer overflow
588593 int repeatCount = (Integer .MAX_VALUE / 2 ) + 1 ;
589594 assertThat (2 * repeatCount ).isNegative ();
590- // 5 is the position of the '*' (repeat operator)
591- evaluateAndCheckError ("'ab' * " + repeatCount , String .class , MAX_REPEATED_TEXT_SIZE_EXCEEDED , 5 );
595+ // 7 is the position of the repeatCount
596+ evaluateAndCheckError ("'ab' * " + repeatCount , String .class , MAX_REPEATED_TEXT_SIZE_EXCEEDED , 7 );
592597 }
593598
594599 @ Test
@@ -623,12 +628,19 @@ void stringConcatenation() {
623628 assertThat (expr .getValue (context , String .class )).hasSize (maxSize );
624629
625630 // Text is too big
631+ context .setVariable ("text1" , createString (maxSize ));
632+ context .setVariable ("text2" , createString (maxSize ));
633+ evaluateAndCheckError ("#text1 + #text2" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 7 );
634+
626635 context .setVariable ("text1" , createString (maxSize + 1 ));
627636 evaluateAndCheckError ("#text1 + ''" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 7 );
628637 evaluateAndCheckError ("#text1 + true" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 7 );
629638 evaluateAndCheckError ("'' + #text1" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 3 );
630639 evaluateAndCheckError ("true + #text1" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 5 );
631640
641+ context .setVariable ("text1" , createString (maxSize - 1 ));
642+ evaluateAndCheckError ("#text1 + 'YZ'" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 7 );
643+
632644 context .setVariable ("text1" , createString (maxSize / 2 ));
633645 context .setVariable ("text2" , createString ((maxSize / 2 ) + 1 ));
634646 evaluateAndCheckError ("#text1 + #text2" , String .class , MAX_CONCATENATED_STRING_LENGTH_EXCEEDED , 7 );
0 commit comments