Add tests for status quo for SpEL compiler
This commit is contained in:
@@ -536,6 +536,14 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(map)).isEqualTo(111);
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/Object");
|
||||
|
||||
// String key not enclosed in single quotes
|
||||
expression = parser.parseExpression("[aaa]");
|
||||
|
||||
assertThat(expression.getValue(map)).isEqualTo(111);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(map)).isEqualTo(111);
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/Object");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -644,6 +652,19 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("I");
|
||||
}
|
||||
|
||||
@Test
|
||||
void indexIntoStringCannotBeCompiled() {
|
||||
String text = "enigma";
|
||||
|
||||
// "g" is the 4th letter in "enigma" (index 3)
|
||||
expression = parser.parseExpression("[3]");
|
||||
|
||||
assertThat(expression.getValue(text)).isEqualTo("g");
|
||||
assertCannotCompile(expression);
|
||||
assertThat(expression.getValue(text)).isEqualTo("g");
|
||||
assertThat(getAst().getExitDescriptor()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void indexIntoObject() {
|
||||
TestClass6 tc = new TestClass6();
|
||||
|
||||
Reference in New Issue
Block a user