Skip to content

Commit cbf504b

Browse files
committed
fix: fix Show.baddiff
Given a `BadVDiff` with at least one node, `Show.baddiff` uses `VariationTree.toVariationDiff` which previously required all created nodes to have `DiffType.NON`. However, `Show.baddiff` supplies nodes with `DiffType.ADD` and `DiffType.REM` which triggered an assert in `DiffNode.addChild` during the `VariationTree.toVariationDiff` construction process.
1 parent 9de8a26 commit cbf504b

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/main/java/org/variantsync/diffdetective/variation/diff/DiffNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ public static <T extends VariationNode<T, L1>, L1 extends Label, L2 extends Labe
741741

742742
for (var variationChildNode : variationNode.getChildren()) {
743743
var diffChildNode = unchanged(convert, variationChildNode);
744-
Time.forAll(time -> diffNode.addChild(diffChildNode, time));
744+
diffChildNode.getDiffType().forAllTimesOfExistence(time -> diffNode.addChild(diffChildNode, time));
745745
}
746746

747747
return diffNode;

src/test/java/ShowTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.Test;
3+
import org.variantsync.diffdetective.diff.result.DiffParseException;
4+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
5+
import org.variantsync.diffdetective.variation.diff.VariationDiff;
6+
import org.variantsync.diffdetective.variation.diff.bad.BadVDiff;
7+
import org.variantsync.diffdetective.variation.diff.parse.VariationDiffParseOptions;
8+
9+
import org.variantsync.diffdetective.show.Show;
10+
import org.variantsync.diffdetective.show.engine.GameEngine;
11+
12+
import java.io.IOException;
13+
import java.nio.file.Path;
14+
15+
public class ShowTest {
16+
@Disabled("GUI test, needs to be run manually")
17+
@Test
18+
public void toGood_after_fromGood_idempotency() throws IOException, DiffParseException {
19+
final Path testfile = Constants.RESOURCE_DIR.resolve("badvdiff").resolve("1.diff");
20+
final VariationDiff<DiffLinesLabel> vdiff = VariationDiff.fromFile(testfile, new VariationDiffParseOptions(false, false));
21+
final BadVDiff<DiffLinesLabel> badDiff = BadVDiff.fromGood(vdiff);
22+
23+
GameEngine.showAndAwaitAll(Show.baddiff(badDiff));
24+
}
25+
}

0 commit comments

Comments
 (0)