Skip to content

Commit

Permalink
tests: add test that shows difference in classfile version only
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Aug 1, 2024
1 parent 8a1585e commit e4874e6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,29 @@ void shouldShowDiffIf_orderOfFieldAndMethodsAreFlipped() throws IOException {
List<Action> rootOperations = diff.getSimplifiedOperations().asList();
assertThat(rootOperations).size().isEqualTo(12);
}

@Test
void shouldShowDiff_onlyInClassfileVersion() throws IOException {
// arrange
Path proxy1 = RESOURCES.resolve("classfileVersion").resolve("ClientMain6.class");
Path proxy2 = RESOURCES.resolve("classfileVersion").resolve("ClientMain8.class");
byte[] bytes1 = Files.readAllBytes(proxy1);
byte[] bytes2 = Files.readAllBytes(proxy2);
final Builder scanner = new Builder();

// act
DiffImpl diff = new DiffImpl(scanner.getTreeContext(), scanner.getTree(bytes1), scanner.getTree(bytes2));
diff.computeDiff();

// assert
List<Action> rootOperations = diff.getSimplifiedOperations().asList();
assertThat(rootOperations).size().isEqualTo(1);

Update classfileVersion = (Update) rootOperations.get(0);
assertThat(classfileVersion.getNode().getType()).isEqualTo(TypeSet.type(DiffTypes.DIFF_IN_MAJOR_VERSION));
String oldVersion = classfileVersion.getNode().getLabel();
assertThat(oldVersion).isEqualTo("50");
String newVersion = classfileVersion.getValue();
assertThat(newVersion).isEqualTo("52");
}
}
Binary file not shown.
Binary file not shown.

0 comments on commit e4874e6

Please sign in to comment.