Parsing fails when assert is used as an identifier when in JDK 1.4 mode

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2257 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2003-09-12 15:57:25 +00:00
parent e07888b94b
commit 95f70b0653
3 changed files with 193 additions and 188 deletions

View File

@ -532,6 +532,9 @@ void VariableDeclaratorId() :
}
( "[" "]" )*
{
if (!usingAssertAsIdentifier && s.equals("assert")) {
throw new ParseException("Can't use 'assert' as an identifier when running in JDK 1.4 mode!");
}
jjtThis.setImage( s );
}
}

View File

@ -16,8 +16,6 @@ public class AssertTest extends TestCase {
new JavaParser(new StringReader(TEST4)).CompilationUnit();
}
/*
TODO
public void testAssertAsIdentifierFailsWith1_4() {
try {
new JavaParser(new StringReader(TEST5)).CompilationUnit();
@ -26,10 +24,11 @@ TODO
// cool
}
}
*/
public void testAssertAsIdentifierSucceedsWith1_3() {
new JavaParser(new StringReader(TEST6)).CompilationUnit();
JavaParser jp = new JavaParser(new StringReader(TEST6));
jp.setAssertAsIdentifier();
jp.CompilationUnit();
}
public void testAssertAsKeywordFailsWith1_3() {

File diff suppressed because it is too large Load Diff