Add tests for status quo for SpEL compiler

This commit is contained in:
Sam Brannen
2024-03-09 13:46:39 +01:00
parent fad544e077
commit 107f47cfcf

View File

@@ -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();