SPR-7100: '_' supported as first char of identifier

This commit is contained in:
Andy Clement
2010-04-16 21:10:23 +00:00
parent f6b56a591c
commit bf1a95c771
3 changed files with 14 additions and 0 deletions

View File

@@ -57,6 +57,9 @@ class Tokenizer {
case '+':
pushCharToken(TokenKind.PLUS);
break;
case '_': // the other way to start an identifier
lexIdentifier();
break;
case '-':
pushCharToken(TokenKind.MINUS);
break;

View File

@@ -222,6 +222,12 @@ public class EvaluationTests extends ExpressionTestCase {
evaluateAndCheckError("madeup", SpelMessage.PROPERTY_OR_FIELD_NOT_READABLE, 0, "madeup",
"org.springframework.expression.spel.testresources.Inventor");
}
@Test
public void testPropertyField02_SPR7100() {
evaluate("_name", "Nikola Tesla", String.class);
evaluate("_name_", "Nikola Tesla", String.class);
}
@Test
public void testRogueTrailingDotCausesNPE_SPR6866() {
@@ -408,6 +414,7 @@ public class EvaluationTests extends ExpressionTestCase {
evaluate("'christian'[8]", "n", String.class);
}
@Test
public void testIndexerError() {
evaluateAndCheckError("new org.springframework.expression.spel.testresources.Inventor().inventions[1]",SpelMessage.CANNOT_INDEX_INTO_NULL_VALUE);

View File

@@ -10,6 +10,8 @@ import java.util.Map;
@SuppressWarnings("unused")
public class Inventor {
private String name;
public String _name;
public String _name_;
public String publicName;
private PlaceOfBirth placeOfBirth;
private Date birthdate;
@@ -36,6 +38,8 @@ public class Inventor {
public Inventor(String name, Date birthdate, String nationality) {
this.name = name;
this._name = name;
this._name_ = name;
this.birthdate = birthdate;
this.nationality = nationality;
this.arrayContainer = new ArrayContainer();