Address TODOs in SpEL's Indexer

This commit deletes outdated TODOs and addresses a remaining "current"
TODO in SpEL's Indexer.
This commit is contained in:
Sam Brannen
2024-02-10 15:37:25 +01:00
parent 888e50175d
commit dc73ec76fc
2 changed files with 21 additions and 11 deletions

View File

@@ -44,6 +44,25 @@ import static org.springframework.expression.spel.SpelMessage.UNABLE_TO_GROW_COL
@SuppressWarnings("rawtypes")
class IndexingTests {
@Test
@SuppressWarnings("unchecked")
void indexIntoArrays() {
SpelExpressionParser parser = new SpelExpressionParser();
// One-dimensional
this.property = new int[] {1, 2, 3, 4};
Expression expression = parser.parseExpression("property[2]");
assertThat(expression.getValue(this)).isEqualTo(3);
// Multi-dimensional
this.property = new int[][] {{1, 2}, {3, 4}};
expression = parser.parseExpression("property[0]");
assertThat(expression.getValue(this)).isEqualTo(new int[] {1, 2});
expression = parser.parseExpression("property[1][1]");
assertThat(expression.getValue(this)).isEqualTo(4);
}
@Test
@SuppressWarnings("unchecked")
void indexIntoGenericPropertyContainingMap() {