diff options
author | Danny van Bruggen <hexagonaal@gmail.com> | 2018-02-03 23:20:04 +0100 |
---|---|---|
committer | Danny van Bruggen <hexagonaal@gmail.com> | 2018-02-03 23:20:04 +0100 |
commit | d7bb34fa5033f252060bcff360735967a4f3b02c (patch) | |
tree | 989b7fc563befcfa50c601dea2fd0c1efd78fc3c /javaparser-testing | |
parent | 6036e9961e7f8ea8f94c7d9b3ab9160b517d156b (diff) | |
download | platform_external_javaparser-d7bb34fa5033f252060bcff360735967a4f3b02c.tar.gz platform_external_javaparser-d7bb34fa5033f252060bcff360735967a4f3b02c.tar.bz2 platform_external_javaparser-d7bb34fa5033f252060bcff360735967a4f3b02c.zip |
Make a VarType and a Java 10 language level. Make a postprocessing framework so "var" can be turned into a VarType.
Diffstat (limited to 'javaparser-testing')
-rw-r--r-- | javaparser-testing/src/test/java/com/github/javaparser/version/Java10ProcessorTest.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/version/Java10ProcessorTest.java b/javaparser-testing/src/test/java/com/github/javaparser/version/Java10ProcessorTest.java new file mode 100644 index 000000000..6ebb89cfb --- /dev/null +++ b/javaparser-testing/src/test/java/com/github/javaparser/version/Java10ProcessorTest.java @@ -0,0 +1,85 @@ +package com.github.javaparser.version; + +import com.github.javaparser.JavaParser; +import com.github.javaparser.ParseResult; +import com.github.javaparser.ParserConfiguration; +import com.github.javaparser.ast.CompilationUnit; +import com.github.javaparser.ast.stmt.Statement; +import org.junit.Test; + +import static com.github.javaparser.ParseStart.COMPILATION_UNIT; +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.ast.validator.Java1_1ValidatorTest.allModifiers; +import static com.github.javaparser.utils.TestUtils.assertNoProblems; +import static com.github.javaparser.utils.TestUtils.assertProblems; + +public class Java10ProcessorTest { + public static final JavaParser javaParser = new JavaParser(new ParserConfiguration().setLanguageLevel(JAVA_10)); + + @Test + public void varIsAType() { + ParseResult<Statement> statement = javaParser.parse(STATEMENT, provider("var x=\"\";")); + + } + + @Test + public void underscoreIdentifiers() { + ParseResult<Statement> result = javaParser.parse(STATEMENT, provider("a.b._.c.d = act(_, _ -> _);")); + assertProblems(result, + "(line 1,col 5) '_' is a reserved keyword.", + "(line 1,col 17) '_' is a reserved keyword.", + "(line 1,col 20) '_' is a reserved keyword.", + "(line 1,col 25) '_' is a reserved keyword." + ); + } + + @Test + public void moduleRequires() { + ParseResult<CompilationUnit> result = javaParser.parse(COMPILATION_UNIT, provider("module x{requires " + allModifiers + " a;}")); + assertProblems(result, + "(line 1,col 10) Can have only one of 'public', 'protected', 'private'.", + "(line 1,col 10) Can have only one of 'final', 'abstract'.", + "(line 1,col 10) Can have only one of 'native', 'strictfp'.", + "(line 1,col 10) 'transient' is not allowed here.", + "(line 1,col 10) 'volatile' is not allowed here.", + "(line 1,col 10) 'final' is not allowed here.", + "(line 1,col 10) 'synchronized' is not allowed here.", + "(line 1,col 10) 'default' is not allowed here.", + "(line 1,col 10) 'native' is not allowed here.", + "(line 1,col 10) 'private' is not allowed here.", + "(line 1,col 10) 'protected' is not allowed here.", + "(line 1,col 10) 'strictfp' is not allowed here.", + "(line 1,col 10) 'abstract' is not allowed here.", + "(line 1,col 10) 'public' is not allowed here." + ); + } + + @Test + public void interfaceMethod() { + ParseResult<CompilationUnit> result = javaParser.parse(COMPILATION_UNIT, provider("interface X{" + allModifiers + "int x(){};}")); + assertProblems(result, + "(line 1,col 13) Can have only one of 'public', 'protected', 'private'.", + "(line 1,col 13) Can have only one of 'final', 'abstract'.", + "(line 1,col 13) Can have only one of 'native', 'strictfp'.", + "(line 1,col 13) Cannot be 'abstract' and also 'private', 'static', 'final', 'native', 'strictfp', 'synchronized'.", + "(line 1,col 13) 'transient' is not allowed here.", + "(line 1,col 13) 'volatile' is not allowed here.", + "(line 1,col 13) 'transitive' is not allowed here." + ); + } + + @Test + public void modules() { + ParseResult<CompilationUnit> result = javaParser.parse(COMPILATION_UNIT, provider("open module x {}")); + assertNoProblems(result); + } + + @Test + public void tryWithResourceReference() { + ParseResult<Statement> result = javaParser.parse(STATEMENT, provider("try(a.b.c){}")); + assertNoProblems(result); + } + +} |