Skip to content

Commit

Permalink
NotNull assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla authored and DenWav committed Nov 9, 2021
1 parent c0ae124 commit 6f3594b
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@DisplayName("[asm] Scenario 03 - Synthetic members (Java 16)")
Expand All @@ -43,25 +44,33 @@ public class Scenario03 extends TestScenarioBase {
@DisplayName("Test expected synthetic members are synthetic")
public void testSyntheticMembers() throws Exception {
final var testClass = this.context().getProvider().findClass("scenario03/TestClass");
assertNotNull(testClass);
final var inner = this.context().getProvider().findClass("scenario03/TestClass$Inner");
assertNotNull(inner);

final MethodData intSupplierSynth = testClass.method("lambda$intSupplier$0", MethodDescriptor.parseDescriptor("(Lscenario03/TestClass$Inner;)I"));
assertNotNull(intSupplierSynth, "Did not find expected lambda$intSupplier$0 synthetic member in TestClass");
assertTrue(intSupplierSynth.isSynthetic());

final FieldData innerSyntheticOuterThisField = inner.field("this$0", new ClassType("scenario03.TestClass"));
assertNotNull(innerSyntheticOuterThisField, "Did not find expected this$0 synthetic member in TestClass$Inner");
assertTrue(innerSyntheticOuterThisField.isSynthetic());
}

@Test
@DisplayName("Test declared members are not synthetic")
public void testNonSyntheticMembers() throws Exception {
final var testClass = this.context().getProvider().findClass("scenario03/TestClass");
assertNotNull(testClass);
final var inner = this.context().getProvider().findClass("scenario03/TestClass$Inner");
assertNotNull(inner);

final MethodData intSupplier = testClass.method("intSupplier", MethodDescriptor.parseDescriptor("(Lscenario03/TestClass$Inner;)Ljava/util/function/IntSupplier;"));
assertNotNull(intSupplier, "Did not find expected method intSupplier in TestClass");
assertFalse(intSupplier.isSynthetic());

final FieldData innerDeclaredField = inner.field("notSynthetic", PrimitiveType.INT);
assertNotNull(innerDeclaredField, "Did not find expected field notSynthetic in TestClass$Inner");
assertFalse(innerDeclaredField.isSynthetic());
}
}

0 comments on commit 6f3594b

Please sign in to comment.