aboutsummaryrefslogtreecommitdiffstats
path: root/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-03-04 08:21:35 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-03-04 08:21:35 +0000
commitb4c1397d5df9370f6358d4f8e9efd27e0f67dec1 (patch)
tree6789ec288d344cf5fd5d057bcf1efc9545b1af28 /javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java
parent92d661a1d239131fb5c1e019a8f2ac7584d2d3f6 (diff)
parent1afe9e0652b9b53edade5aa276162abe27b32a67 (diff)
downloadplatform_external_javaparser-android-9.0.0_r7.tar.gz
platform_external_javaparser-android-9.0.0_r7.tar.bz2
platform_external_javaparser-android-9.0.0_r7.zip
Snap for 4632767 from 1afe9e0652b9b53edade5aa276162abe27b32a67 to pi-releaseandroid-wear-9.0.0_r9android-wear-9.0.0_r8android-wear-9.0.0_r7android-wear-9.0.0_r6android-wear-9.0.0_r5android-wear-9.0.0_r4android-wear-9.0.0_r3android-wear-9.0.0_r23android-wear-9.0.0_r22android-wear-9.0.0_r21android-wear-9.0.0_r20android-wear-9.0.0_r2android-wear-9.0.0_r19android-wear-9.0.0_r18android-wear-9.0.0_r17android-wear-9.0.0_r16android-wear-9.0.0_r15android-wear-9.0.0_r14android-wear-9.0.0_r13android-wear-9.0.0_r12android-wear-9.0.0_r11android-wear-9.0.0_r10android-wear-9.0.0_r1android-vts-9.0_r9android-vts-9.0_r8android-vts-9.0_r7android-vts-9.0_r6android-vts-9.0_r5android-vts-9.0_r4android-vts-9.0_r14android-vts-9.0_r13android-vts-9.0_r12android-vts-9.0_r11android-vts-9.0_r10android-cts-9.0_r9android-cts-9.0_r8android-cts-9.0_r7android-cts-9.0_r6android-cts-9.0_r5android-cts-9.0_r4android-cts-9.0_r3android-cts-9.0_r2android-cts-9.0_r13android-cts-9.0_r12android-cts-9.0_r11android-cts-9.0_r10android-cts-9.0_r1android-9.0.0_r9android-9.0.0_r8android-9.0.0_r7android-9.0.0_r60android-9.0.0_r6android-9.0.0_r59android-9.0.0_r58android-9.0.0_r57android-9.0.0_r56android-9.0.0_r55android-9.0.0_r54android-9.0.0_r53android-9.0.0_r52android-9.0.0_r51android-9.0.0_r50android-9.0.0_r5android-9.0.0_r49android-9.0.0_r48android-9.0.0_r3android-9.0.0_r2android-9.0.0_r18android-9.0.0_r17android-9.0.0_r10android-9.0.0_r1security-pi-releasepie-vts-releasepie-security-releasepie-s2-releasepie-release-2pie-releasepie-r2-s2-releasepie-r2-s1-releasepie-r2-releasepie-platform-releasepie-gsipie-cuttlefish-testingpie-cts-release
Change-Id: Ibe65883e94ed5a7272dff3f100393987a1cf3da2
Diffstat (limited to 'javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java')
-rw-r--r--javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java79
1 files changed, 79 insertions, 0 deletions
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java b/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java
new file mode 100644
index 000000000..911f6a984
--- /dev/null
+++ b/javaparser-testing/src/test/java/com/github/javaparser/ast/validator/Java9ValidatorTest.java
@@ -0,0 +1,79 @@
+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.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 Java9ValidatorTest {
+ public static final JavaParser javaParser = new JavaParser(new ParserConfiguration().setLanguageLevel(JAVA_9));
+
+ @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);
+ }
+
+}