aboutsummaryrefslogtreecommitdiffstats
path: root/javaparser-testing/src/test/java/com/github/javaparser/ParserConfigurationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'javaparser-testing/src/test/java/com/github/javaparser/ParserConfigurationTest.java')
-rw-r--r--javaparser-testing/src/test/java/com/github/javaparser/ParserConfigurationTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/javaparser-testing/src/test/java/com/github/javaparser/ParserConfigurationTest.java b/javaparser-testing/src/test/java/com/github/javaparser/ParserConfigurationTest.java
new file mode 100644
index 000000000..abc400912
--- /dev/null
+++ b/javaparser-testing/src/test/java/com/github/javaparser/ParserConfigurationTest.java
@@ -0,0 +1,33 @@
+package com.github.javaparser;
+
+import com.github.javaparser.ast.CompilationUnit;
+import com.github.javaparser.ast.Node;
+import com.github.javaparser.ast.stmt.Statement;
+import org.junit.Test;
+
+import static com.github.javaparser.ParseStart.STATEMENT;
+import static com.github.javaparser.ParserConfiguration.LanguageLevel.*;
+import static com.github.javaparser.Providers.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class ParserConfigurationTest {
+ @Test
+ public void storeNoTokens() {
+ ParseResult<CompilationUnit> result = new JavaParser(new ParserConfiguration().setStoreTokens(false)).parse(ParseStart.COMPILATION_UNIT, provider("class X{}"));
+
+ assertFalse(result.getResult().get().getTokenRange().isPresent());
+ assertTrue(result.getResult().get().findAll(Node.class).stream().noneMatch(node -> node.getTokenRange().isPresent()));
+ }
+
+ @Test
+ public void noProblemsHere() {
+ ParseResult<Statement> result =
+ new JavaParser(new ParserConfiguration().setLanguageLevel(RAW))
+ .parse(STATEMENT, provider("try{}"));
+ assertEquals(true, result.isSuccessful());
+ }
+
+
+}