8264664: use text blocks in javac module tests

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2021-04-03 01:18:00 +00:00
parent cec66cf8ef
commit e8eda655bb
18 changed files with 630 additions and 503 deletions

View file

@ -49,23 +49,26 @@ public class WrongErrorMessageForNestedServiceProviderTest extends ModuleTestBas
}
private static final String twoServicesModuleDef =
"module m {\n" +
" exports example;\n" +
" provides example.SomeService with example.ServiceImpl;\n" +
" provides example.SomeServiceOuter with example.Outer.ServiceImplOuter;\n" +
"}";
"""
module m {
exports example;
provides example.SomeService with example.ServiceImpl;
provides example.SomeServiceOuter with example.Outer.ServiceImplOuter;
}""";
private static final String someServiceInt =
"package example;\n" +
"public interface SomeService {\n" +
" public void foo();\n" +
"}";
"""
package example;
public interface SomeService {
public void foo();
}""";
private static final String someServiceIntOuter =
"package example;\n" +
"public interface SomeServiceOuter {\n" +
" public void foo();\n" +
"}";
"""
package example;
public interface SomeServiceOuter {
public void foo();
}""";
@Test
public void testPositive(Path base) throws Exception {
@ -74,19 +77,21 @@ public class WrongErrorMessageForNestedServiceProviderTest extends ModuleTestBas
twoServicesModuleDef,
someServiceInt,
someServiceIntOuter,
"package example;\n" +
"public class ServiceImpl implements example.SomeService {\n" +
" public ServiceImpl() {}\n" +
" public void foo() {}\n" +
"}",
"""
package example;
public class ServiceImpl implements example.SomeService {
public ServiceImpl() {}
public void foo() {}
}""",
"package example;\n" +
"class Outer {\n" +
" public static class ServiceImplOuter implements example.SomeServiceOuter {\n" +
" public ServiceImplOuter() {}\n" +
" public void foo() {}\n" +
" }\n" +
"}");
"""
package example;
class Outer {
public static class ServiceImplOuter implements example.SomeServiceOuter {
public ServiceImplOuter() {}
public void foo() {}
}
}""");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
@ -110,20 +115,21 @@ public class WrongErrorMessageForNestedServiceProviderTest extends ModuleTestBas
twoServicesModuleDef,
someServiceInt,
someServiceIntOuter,
"""
package example;
class ServiceImpl implements example.SomeService {
public ServiceImpl() {}
public void foo() {}
}""",
"package example;\n" +
"class ServiceImpl implements example.SomeService {\n" +
" public ServiceImpl() {}\n" +
" public void foo() {}\n" +
"}",
"package example;\n" +
"class Outer {\n" +
" static class ServiceImplOuter implements example.SomeServiceOuter {\n" +
" public ServiceImplOuter() {}\n" +
" public void foo() {}\n" +
" }\n" +
"}");
"""
package example;
class Outer {
static class ServiceImplOuter implements example.SomeServiceOuter {
public ServiceImplOuter() {}
public void foo() {}
}
}""");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
@ -147,22 +153,24 @@ public class WrongErrorMessageForNestedServiceProviderTest extends ModuleTestBas
public void testClassWrappedByPrivateClass(Path base) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src,
"module m {\n" +
" exports example;\n" +
" provides example.SomeServiceOuter with example.Outer1.Outer2.ServiceImplOuter;\n" +
"}",
"""
module m {
exports example;
provides example.SomeServiceOuter with example.Outer1.Outer2.ServiceImplOuter;
}""",
someServiceIntOuter,
"package example;\n" +
"class Outer1 {\n" +
" static private class Outer2 {\n" +
" public static class ServiceImplOuter implements example.SomeServiceOuter {\n" +
" public ServiceImplOuter() {}\n" +
" public void foo() {}\n" +
" }\n" +
" }\n" +
"}");
"""
package example;
class Outer1 {
static private class Outer2 {
public static class ServiceImplOuter implements example.SomeServiceOuter {
public ServiceImplOuter() {}
public void foo() {}
}
}
}""");
Path classes = base.resolve("classes");
Files.createDirectories(classes);