Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.base.Joiner;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -55,19 +54,19 @@ public void restoreLocale() throws Exception {
@Test
public void parseError() throws Exception {
String input =
Joiner.on('\n')
.join(
"public class InvalidSyntax {",
" private static NumPrinter {",
" public static void print(int n) {",
" System.out.printf(\"%d%n\", n);",
" }",
" }",
"",
" public static void main(String[] args) {",
" NumPrinter.print(args.length);",
" }",
"}");
"""
public class InvalidSyntax {
private static NumPrinter {
public static void print(int n) {
System.out.printf("%d%n", n);
}
}

public static void main(String[] args) {
NumPrinter.print(args.length);
}
}\
""";

StringWriter stdout = new StringWriter();
StringWriter stderr = new StringWriter();
Expand Down Expand Up @@ -150,7 +149,11 @@ public void oneFileParseErrorReplace() throws Exception {

@Test
public void parseError2() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g() } }";
String input =
"""
class Foo { void f() {
g() } }
""";

Path tmpdir = testFolder.newFolder().toPath();
Path path = tmpdir.resolve("A.java");
Expand All @@ -169,7 +172,11 @@ public void parseError2() throws FormatterException, IOException, UsageException

@Test
public void parseErrorStdin() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g() } }";
String input =
"""
class Foo { void f() {
g() } }
""";

InputStream inStream = new ByteArrayInputStream(input.getBytes(UTF_8));
StringWriter out = new StringWriter();
Expand All @@ -184,7 +191,11 @@ public void parseErrorStdin() throws FormatterException, IOException, UsageExcep

@Test
public void lexError2() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g('foo'); } }";
String input =
"""
class Foo { void f() {
g('foo'); } }
""";

Path tmpdir = testFolder.newFolder().toPath();
Path path = tmpdir.resolve("A.java");
Expand All @@ -203,7 +214,11 @@ public void lexError2() throws FormatterException, IOException, UsageException {

@Test
public void lexErrorStdin() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g('foo'); } }";
String input =
"""
class Foo { void f() {
g('foo'); } }
""";
InputStream inStream = new ByteArrayInputStream(input.getBytes(UTF_8));
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
Expand Down
Loading
Loading