-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Issue3064Test.java
42 lines (33 loc) · 1.48 KB
/
Issue3064Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.github.javaparser;
import com.github.javaparser.ast.CompilationUnit;
import org.junit.jupiter.api.Test;
import java.io.StringReader;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class Issue3064Test {
@Test
public void test0() {
String str = "import java.util.function.Supplier;\n" +
"\n" +
"public class MyClass {\n" +
"\n" +
" public MyClass() {\n" +
" Supplier<String> aStringSupplier = false ? () -> \"\" : true ? () -> \"\" : () -> \"path\";\n" +
" }\n" +
"}\n";
JavaParser parser = new JavaParser();
ParseResult<CompilationUnit> unitOpt = parser.parse(new StringReader(str));
unitOpt.getProblems().stream().forEach(p -> System.err.println(p.toString()));
CompilationUnit unit = unitOpt.getResult().orElseThrow(() -> new IllegalStateException("Could not parse file"));
assertEquals(str, unit.toString());
}
@Test
public void test1() {
String str = "public class MyClass {\n" +
" {\n" +
" Supplier<String> aStringSupplier = false ? () -> \"F\" : true ? () -> \"T\" : () -> \"path\";\n" +
" }\n" +
"}";
CompilationUnit unit = StaticJavaParser.parse(str);
assertEquals(str.replace("\n", ""), unit.toString().replace("\n", ""));
}
}