mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-21 13:31:46 +00:00
Introduce missing tests for immediate SpEL compilation for Elvis operator
This commit is contained in:
+17
@@ -1470,6 +1470,23 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/String");
|
||||
}
|
||||
|
||||
@Test
|
||||
void elvisWithImmediateCompilation() {
|
||||
expression = parser.parseExpression("'a' ?: 'b'");
|
||||
// Both literals, so we can compile immediately without having previously
|
||||
// evaluated the expression.
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(String.class)).isEqualTo("a");
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/String");
|
||||
|
||||
expression = parser.parseExpression("null ?: 'a'");
|
||||
// Both literals, so we can compile immediately without having previously
|
||||
// evaluated the expression.
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(String.class)).isEqualTo("a");
|
||||
assertThat(getAst().getExitDescriptor()).isEqualTo("Ljava/lang/Object");
|
||||
}
|
||||
|
||||
@Test // gh-19758
|
||||
void elvisMiscellaneous() {
|
||||
SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null);
|
||||
|
||||
Reference in New Issue
Block a user