Merge branch '6.0.x'
This commit is contained in:
commit
cd610b3ed1
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -265,7 +265,9 @@ class Tokenizer {
|
||||||
raiseParseException(this.pos, SpelMessage.UNEXPECTED_ESCAPE_CHAR);
|
raiseParseException(this.pos, SpelMessage.UNEXPECTED_ESCAPE_CHAR);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Cannot handle (" + (int) ch + ") '" + ch + "'");
|
throw new IllegalStateException(
|
||||||
|
"Unsupported character '%s' (%d) encountered at position %d in expression."
|
||||||
|
.formatted(ch, (int) ch, (this.pos + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -24,6 +24,7 @@ import org.springframework.expression.spel.standard.SpelExpression;
|
||||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse some expressions and check we get the AST we expect.
|
* Parse some expressions and check we get the AST we expect.
|
||||||
|
|
@ -42,6 +43,58 @@ class ParsingTests {
|
||||||
@Nested
|
@Nested
|
||||||
class Miscellaneous {
|
class Miscellaneous {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void supportedCharactersInIdentifiers() {
|
||||||
|
parseCheck("#var='value'");
|
||||||
|
parseCheck("#Varz='value'");
|
||||||
|
parseCheck("#VarZ='value'");
|
||||||
|
parseCheck("#_var='value'");
|
||||||
|
parseCheck("#$var='value'");
|
||||||
|
parseCheck("#_$_='value'");
|
||||||
|
|
||||||
|
parseCheck("age");
|
||||||
|
parseCheck("getAge()");
|
||||||
|
parseCheck("get$age()");
|
||||||
|
parseCheck("age");
|
||||||
|
parseCheck("Age");
|
||||||
|
parseCheck("__age");
|
||||||
|
parseCheck("get__age()");
|
||||||
|
|
||||||
|
parseCheck("person.age");
|
||||||
|
parseCheck("person.getAge()");
|
||||||
|
parseCheck("person.get$age()");
|
||||||
|
parseCheck("person$1.age");
|
||||||
|
parseCheck("person_1.Age");
|
||||||
|
parseCheck("person_1.__age");
|
||||||
|
parseCheck("Person_1.get__age()");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void unsupportedCharactersInIdentifiers() {
|
||||||
|
// Invalid syntax
|
||||||
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> parser.parseRaw("apple~banana"))
|
||||||
|
.withMessage("Unsupported character '~' (126) encountered at position 6 in expression.");
|
||||||
|
|
||||||
|
// German characters
|
||||||
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> parser.parseRaw("begrüssung"))
|
||||||
|
.withMessage("Unsupported character 'ü' (252) encountered at position 5 in expression.");
|
||||||
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> parser.parseRaw("Spaß"))
|
||||||
|
.withMessage("Unsupported character 'ß' (223) encountered at position 4 in expression.");
|
||||||
|
|
||||||
|
// Spanish characters
|
||||||
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> parser.parseRaw("buenos_sueños"))
|
||||||
|
.withMessage("Unsupported character 'ñ' (241) encountered at position 11 in expression.");
|
||||||
|
|
||||||
|
// Chinese characters
|
||||||
|
assertThatIllegalStateException()
|
||||||
|
.isThrownBy(() -> parser.parseRaw("have乐趣()"))
|
||||||
|
.withMessage("Unsupported character '乐' (20048) encountered at position 5 in expression.");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void literalNull() {
|
void literalNull() {
|
||||||
parseCheck("null");
|
parseCheck("null");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue