Add test for positive filter followed by a negated filter

This test shows that R8 is compatible with PG regarding the
interpretation of a positive clause followed by a negated. The spec
also states that the negation only relates to subsequent clauses.

Fixes: 203527191
Change-Id: I3507325cdeec930713f3bd511ad6a83424c678d5
diff --git a/src/test/java/com/android/tools/r8/shaking/negatedrules/NegatedKeepRulesTest.java b/src/test/java/com/android/tools/r8/shaking/negatedrules/NegatedKeepRulesTest.java
index b8de479..9afdd92 100644
--- a/src/test/java/com/android/tools/r8/shaking/negatedrules/NegatedKeepRulesTest.java
+++ b/src/test/java/com/android/tools/r8/shaking/negatedrules/NegatedKeepRulesTest.java
@@ -301,6 +301,35 @@
             });
   }
 
+  @Test
+  public void testPositiveWithNegatedR8Compat() throws Exception {
+    testPositiveWithNegated(testForR8Compat(parameters.getBackend()));
+  }
+
+  @Test
+  public void testPositiveWithNegatedR8Full() throws Exception {
+    testPositiveWithNegated(testForR8(parameters.getBackend()));
+  }
+
+  @Test
+  public void testPositiveWithNegatedProguard() throws Exception {
+    testPositiveWithNegated(testForProguard(ProguardVersion.V7_0_0).addKeepRules("-dontwarn"));
+  }
+
+  public void testPositiveWithNegated(TestShrinkerBuilder<?, ?, ?, ?, ?> testBuilder)
+      throws Exception {
+    run(testBuilder.addKeepRules("-keep class **Bar,!**$Foo* { *; }"))
+        .inspect(
+            inspector -> {
+              assertThat(inspector.clazz(BarBar.class), isPresent());
+              assertThat(inspector.clazz(FooBar.class), isPresent());
+              assertThat(inspector.clazz(A.class), isPresent());
+              assertThat(inspector.clazz(B.class), isPresent());
+              assertThat(inspector.clazz(C.class), isPresent());
+              assertThat(inspector.clazz(D.class), isPresent());
+            });
+  }
+
   private TestCompileResult<?, ?> run(TestShrinkerBuilder<?, ?, ?, ?, ?> testBuilder)
       throws Exception {
     return testBuilder