Skip to content

Commit f6a0164

Browse files
gkdncopybara-github
authored andcommitted
Improve test coverage in GwtIncompatibleStripperTest.
The new tests cover stripping of declarations with multiple annotations, Javadoc, and multi-variable field declarations. PiperOrigin-RevId: 886374675
1 parent bd71b91 commit f6a0164

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

tools/javatests/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripperTest.java

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,89 @@ public void testProcessMultiple() {
277277
assertEquals(after, GwtIncompatibleStripper.strip(before, ImmutableList.of("GwtIncompatible")));
278278
}
279279

280+
@Test
281+
public void testProcessUnrelatedAnnotations() {
282+
String before =
283+
lines(
284+
"public class Foo {",
285+
" @GwtIncompatible",
286+
" @Override",
287+
" public void m() {}",
288+
" @Override",
289+
" @GwtIncompatible",
290+
" public void n() {}",
291+
"}");
292+
String after =
293+
lines(
294+
"public class Foo {",
295+
stripped(" @GwtIncompatible"),
296+
stripped(" @Override"),
297+
stripped(" public void m() {}"),
298+
stripped(" @Override"),
299+
stripped(" @GwtIncompatible"),
300+
stripped(" public void n() {}"),
301+
"}");
302+
assertEquals(after, GwtIncompatibleStripper.strip(before, ImmutableList.of("GwtIncompatible")));
303+
}
304+
305+
@Test
306+
public void testProcessJavadoc() {
307+
String before =
308+
lines(
309+
"public class Foo {",
310+
" /**",
311+
" * doc",
312+
" */",
313+
" @GwtIncompatible",
314+
" public void m() {}",
315+
"}");
316+
String after =
317+
lines(
318+
"public class Foo {",
319+
stripped(" /**"),
320+
stripped(" * doc"),
321+
stripped(" */"),
322+
stripped(" @GwtIncompatible"),
323+
stripped(" public void m() {}"),
324+
"}");
325+
assertEquals(after, GwtIncompatibleStripper.strip(before, ImmutableList.of("GwtIncompatible")));
326+
}
327+
328+
@Test
329+
public void testProcessMultiVariable() {
330+
String before = lines("public class Foo {", " @GwtIncompatible", " public String a, b;", "}");
331+
String after =
332+
lines(
333+
"public class Foo {",
334+
stripped(" @GwtIncompatible"),
335+
stripped(" public String a, b;"),
336+
"}");
337+
assertEquals(after, GwtIncompatibleStripper.strip(before, ImmutableList.of("GwtIncompatible")));
338+
}
339+
340+
@Test
341+
public void testProcessMultiVariableJavadoc() {
342+
String before =
343+
lines(
344+
"public class Foo {",
345+
" /**",
346+
" * doc",
347+
" */",
348+
" @GwtIncompatible",
349+
" public String a, b;",
350+
"}");
351+
String after =
352+
lines(
353+
"public class Foo {",
354+
stripped(" /**"),
355+
stripped(" * doc"),
356+
stripped(" */"),
357+
stripped(" @GwtIncompatible"),
358+
stripped(" public String a, b;"),
359+
"}");
360+
assertEquals(after, GwtIncompatibleStripper.strip(before, ImmutableList.of("GwtIncompatible")));
361+
}
362+
280363
@Test
281364
public void testNestedComment() {
282365
String before =

0 commit comments

Comments
 (0)