Skip to content

Commit f9d6d3c

Browse files
cushonJavac Team
authored and
Javac Team
committed
Use text blocks in turbine integration tests
PiperOrigin-RevId: 673953961
1 parent 5a874b7 commit f9d6d3c

14 files changed

+2158
-2045
lines changed

javatests/com/google/turbine/binder/BinderErrorTest.java

Lines changed: 986 additions & 997 deletions
Large diffs are not rendered by default.

javatests/com/google/turbine/deps/DependenciesTest.java

Lines changed: 127 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ public void excluded() throws Exception {
148148
new LibraryBuilder()
149149
.setClasspath(liba)
150150
.addSourceLines(
151-
"B.java", //
152-
"class B {",
153-
" public static final A a = new A();",
154-
"}")
151+
"B.java",
152+
"""
153+
class B {
154+
public static final A a = new A();
155+
}
156+
""")
155157
.compileToJar("libb.jar");
156158
DepsProto.Dependencies deps =
157159
new DepsBuilder()
@@ -167,10 +169,12 @@ public void transitive() throws Exception {
167169
Path liba =
168170
new LibraryBuilder()
169171
.addSourceLines(
170-
"A.java", //
171-
"class A {",
172-
" public static final class Y {}",
173-
"}")
172+
"A.java",
173+
"""
174+
class A {
175+
public static final class Y {}
176+
}
177+
""")
174178
.compileToJar("liba.jar");
175179
Path libb =
176180
new LibraryBuilder()
@@ -181,10 +185,12 @@ public void transitive() throws Exception {
181185
new DepsBuilder()
182186
.setClasspath(liba, libb)
183187
.addSourceLines(
184-
"Test.java", //
185-
"class Test extends B {",
186-
" public static class X extends Y {}",
187-
"}")
188+
"Test.java",
189+
"""
190+
class Test extends B {
191+
public static class X extends Y {}
192+
}
193+
""")
188194
.run();
189195
assertThat(depsMap(deps))
190196
.containsExactly(
@@ -197,35 +203,49 @@ public void closure() throws Exception {
197203
new LibraryBuilder()
198204
.addSourceLines(
199205
"i/I.java",
200-
"package i;", //
201-
"public interface I {}")
206+
"""
207+
package i;
208+
209+
public interface I {}
210+
""")
202211
.compileToJar("libi.jar");
203212
Path liba =
204213
new LibraryBuilder()
205214
.setClasspath(libi)
206215
.addSourceLines(
207-
"a/A.java", //
208-
"package a;",
209-
"import i.I;",
210-
"public class A implements I {}")
216+
"a/A.java",
217+
"""
218+
package a;
219+
220+
import i.I;
221+
222+
public class A implements I {}
223+
""")
211224
.compileToJar("liba.jar");
212225
Path libb =
213226
new LibraryBuilder()
214227
.setClasspath(liba, libi)
215228
.addSourceLines(
216-
"b/B.java", //
217-
"package b;",
218-
"import a.A;",
219-
"public class B extends A {}")
229+
"b/B.java",
230+
"""
231+
package b;
232+
233+
import a.A;
234+
235+
public class B extends A {}
236+
""")
220237
.compileToJar("libb.jar");
221238
{
222239
DepsProto.Dependencies deps =
223240
new DepsBuilder()
224241
.setClasspath(liba, libb, libi)
225242
.addSourceLines(
226-
"Test.java", //
227-
"import b.B;",
228-
"class Test extends B {}")
243+
"Test.java",
244+
"""
245+
import b.B;
246+
247+
class Test extends B {}
248+
""")
229249
.run();
230250
assertThat(depsMap(deps))
231251
.containsExactly(
@@ -242,9 +262,12 @@ public void closure() throws Exception {
242262
new DepsBuilder()
243263
.setClasspath(liba, libb)
244264
.addSourceLines(
245-
"Test.java", //
246-
"import b.B;",
247-
"class Test extends B {}")
265+
"Test.java",
266+
"""
267+
import b.B;
268+
269+
class Test extends B {}
270+
""")
248271
.run();
249272
assertThat(depsMap(deps))
250273
.containsExactly(
@@ -298,34 +321,46 @@ public void packageInfo() throws Exception {
298321
new LibraryBuilder()
299322
.addSourceLines(
300323
"p/Anno.java",
301-
"package p;",
302-
"import java.lang.annotation.Retention;",
303-
"import static java.lang.annotation.RetentionPolicy.RUNTIME;",
304-
"@Retention(RUNTIME)",
305-
"@interface Anno {}")
324+
"""
325+
package p;
326+
327+
import java.lang.annotation.Retention;
328+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
329+
330+
@Retention(RUNTIME)
331+
@interface Anno {}
332+
""")
306333
.addSourceLines(
307-
"p/package-info.java", //
308-
"@Anno",
309-
"package p;")
334+
"p/package-info.java",
335+
"""
336+
@Anno
337+
package p;
338+
""")
310339
.compileToJar("libpackage-info.jar");
311340
Path libp =
312341
new LibraryBuilder()
313342
.setClasspath(libpackageInfo)
314343
.addSourceLines(
315-
"p/P.java", //
316-
"package p;",
317-
"public class P {}")
344+
"p/P.java",
345+
"""
346+
package p;
347+
348+
public class P {}
349+
""")
318350
.compileToJar("libp.jar");
319351
{
320352
DepsProto.Dependencies deps =
321353
new DepsBuilder()
322354
.setClasspath(libp, libpackageInfo)
323355
.addSourceLines(
324-
"Test.java", //
325-
"import p.P;",
326-
"class Test {",
327-
" P p;",
328-
"}")
356+
"Test.java",
357+
"""
358+
import p.P;
359+
360+
class Test {
361+
P p;
362+
}
363+
""")
329364
.run();
330365
assertThat(depsMap(deps))
331366
.containsExactly(
@@ -345,12 +380,14 @@ public void annotations_recursive() throws Exception {
345380
new DepsBuilder()
346381
.setClasspath(libA, libB)
347382
.addSourceLines(
348-
"Test.java", //
349-
"import a.A;",
350-
"import b.B;",
351-
"@A(B.class)",
352-
"class Test {",
353-
"}")
383+
"Test.java",
384+
"""
385+
import a.A;
386+
import b.B;
387+
388+
@A(B.class)
389+
class Test {}
390+
""")
354391
.run();
355392
assertThat(depsMap(deps))
356393
.containsExactly(
@@ -365,13 +402,16 @@ public void annotations_field() throws Exception {
365402
new DepsBuilder()
366403
.setClasspath(libA, libB)
367404
.addSourceLines(
368-
"Test.java", //
369-
"import a.A;",
370-
"import b.B;",
371-
"class Test {",
372-
" @A(B.class)",
373-
" int x;",
374-
"}")
405+
"Test.java",
406+
"""
407+
import a.A;
408+
import b.B;
409+
410+
class Test {
411+
@A(B.class)
412+
int x;
413+
}
414+
""")
375415
.run();
376416
assertThat(depsMap(deps))
377417
.containsExactly(
@@ -386,13 +426,16 @@ public void annotations_method() throws Exception {
386426
new DepsBuilder()
387427
.setClasspath(libA, libB)
388428
.addSourceLines(
389-
"Test.java", //
390-
"import a.A;",
391-
"import b.B;",
392-
"class Test {",
393-
" @A(B.class)",
394-
" void f() {}",
395-
"}")
429+
"Test.java",
430+
"""
431+
import a.A;
432+
import b.B;
433+
434+
class Test {
435+
@A(B.class)
436+
void f() {}
437+
}
438+
""")
396439
.run();
397440
assertThat(depsMap(deps))
398441
.containsExactly(
@@ -403,26 +446,33 @@ private Path libB() throws Exception {
403446
return new LibraryBuilder()
404447
.addSourceLines(
405448
"b/B.java",
406-
"package b;",
407-
"import java.lang.annotation.Retention;",
408-
"import static java.lang.annotation.RetentionPolicy.RUNTIME;",
409-
"@Retention(RUNTIME)",
410-
"public @interface B {",
411-
"}")
449+
"""
450+
package b;
451+
452+
import java.lang.annotation.Retention;
453+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
454+
455+
@Retention(RUNTIME)
456+
public @interface B {}
457+
""")
412458
.compileToJar("libb.jar");
413459
}
414460

415461
private Path libA() throws Exception {
416462
return new LibraryBuilder()
417463
.addSourceLines(
418464
"a/A.java",
419-
"package a;",
420-
"import java.lang.annotation.Retention;",
421-
"import static java.lang.annotation.RetentionPolicy.RUNTIME;",
422-
"@Retention(RUNTIME)",
423-
"public @interface A {",
424-
" Class<?> value() default Object.class;",
425-
"}")
465+
"""
466+
package a;
467+
468+
import java.lang.annotation.Retention;
469+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
470+
471+
@Retention(RUNTIME)
472+
public @interface A {
473+
Class<?> value() default Object.class;
474+
}
475+
""")
426476
.compileToJar("liba.jar");
427477
}
428478

0 commit comments

Comments
 (0)