diff options
Diffstat (limited to 'javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java6ValidatorTest.java')
-rw-r--r-- | javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java6ValidatorTest.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java6ValidatorTest.java b/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java6ValidatorTest.java new file mode 100644 index 000000000..d066abe07 --- /dev/null +++ b/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java6ValidatorTest.java @@ -0,0 +1,42 @@ +package com.github.javaparser.ast.validator; + +import com.github.javaparser.JavaParser; +import com.github.javaparser.ParseResult; +import com.github.javaparser.ParserConfiguration; +import com.github.javaparser.ast.expr.Expression; +import com.github.javaparser.ast.stmt.Statement; +import org.junit.Test; + +import static com.github.javaparser.ParseStart.EXPRESSION; +import static com.github.javaparser.ParseStart.STATEMENT; +import static com.github.javaparser.ParserConfiguration.LanguageLevel.*; +import static com.github.javaparser.Providers.provider; +import static com.github.javaparser.utils.TestUtils.assertProblems; + +public class Java6ValidatorTest { + public static final JavaParser javaParser = new JavaParser(new ParserConfiguration().setLanguageLevel(JAVA_6)); + + @Test + public void noStringsInSwitch() { + ParseResult<Statement> result = javaParser.parse(STATEMENT, provider("switch(x){case \"abc\": ;}")); + assertProblems(result, "(line 1,col 16) Strings in switch statements are not supported."); + } + + @Test + public void nobinaryIntegerLiterals() { + ParseResult<Expression> result = javaParser.parse(EXPRESSION, provider("0b01")); + assertProblems(result, "(line 1,col 1) Binary literal values are not supported."); + } + + @Test + public void noUnderscoresInIntegerLiterals() { + ParseResult<Expression> result = javaParser.parse(EXPRESSION, provider("1_000_000")); + assertProblems(result, "(line 1,col 1) Underscores in literal values are not supported."); + } + + @Test + public void noMultiCatch() { + ParseResult<Statement> result = javaParser.parse(STATEMENT, provider("try{}catch(Abc|Def e){}")); + assertProblems(result, "(line 1,col 12) Multi-catch is not supported."); + } +} |