Skip to content

Commit

Permalink
Improve the sorting of body mappers
Browse files Browse the repository at this point in the history
Fixes matching of methods in
platform-tests/src/test/java/org/junit/platform/engine/discovery/DiscoverySelectorsTests.java
junit-team/junit5@c71d671
  • Loading branch information
tsantalis committed Jan 14, 2025
1 parent be8dadc commit f6d8175
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3968,6 +3968,9 @@ public boolean allMappingsAreIdentical() {
if(mapping.getFragment1().getString().equals(mapping.getFragment2().getString())) {
identical++;
}
else {
break;
}
}
return identical == this.getMappings().size() && identical > 0;
}
Expand Down Expand Up @@ -9762,12 +9765,18 @@ else if(identicalStringRepresentation2) {
otherMappings++;
}
}
if(thisMappings != otherMappings) {
return -Integer.compare(thisMappings, otherMappings);
int thisExactMatches = this.exactMatches();
int otherExactMatches = operationBodyMapper.exactMatches();
if(thisMappings > otherMappings && thisExactMatches >= otherExactMatches) {
return -1;
}
else if(thisMappings < otherMappings && thisExactMatches <= otherExactMatches) {
return 1;
}
//if(thisMappings != otherMappings) {
// return -Integer.compare(thisMappings, otherMappings);
//}
else {
int thisExactMatches = this.exactMatches();
int otherExactMatches = operationBodyMapper.exactMatches();
if(thisExactMatches != otherExactMatches) {
return -Integer.compare(thisExactMatches, otherExactMatches);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public void testAllRefactorings() throws Exception {
GitHistoryRefactoringMinerImpl detector = new GitHistoryRefactoringMinerImpl();
TestBuilder test = new TestBuilder(detector, REPOS, Refactorings.All.getValue());
RefactoringPopulator.feedRefactoringsInstances(Refactorings.All.getValue(), Systems.FSE.getValue(), test);
test.assertExpectationsWithGitHubAPI(12402, 18, 226);
test.assertExpectationsWithGitHubAPI(12402, 16, 226);
}
}
28 changes: 7 additions & 21 deletions src/test/resources/oracle/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -32367,13 +32367,6 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": "Nikos"
}, {
"type": "Change Parameter Type",
"description": "Change Parameter Type meta : long to meta : long[] in method private createResult(number long, meta long[]) : long[] from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence",
"comment": "<p>createResult() is extracted from <span class='blob-code-inner blob-code-marker' data-code-marker=' '><span class='pl-k'>public</span> <span class='pl-k'>long</span>[] <span class='pl-en'>get</span>()</span>, in which there is a local variable meta whose type is changing from long to long[] and is passed as argument to createResult()</p>",
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": "Nikos"
}, {
"type": "Change Parameter Type",
"description": "Change Parameter Type meta : long to meta : long[] in method public seen(number long, meta long[]) : boolean from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence",
Expand Down Expand Up @@ -32500,13 +32493,6 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": "Nikos"
}, {
"type": "Rename Method",
"description": "Rename Method private pack(meta long) : long[] renamed to private createResult(number long, meta long[]) : long[] in class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence",
"comment": "null",
"validation": "FP",
"detectionTools": "RefactoringMiner",
"validators": "Nikos"
}, {
"type": "Change Variable Type",
"description": "Change Variable Type logRotationControl : LogRotationControl to logRotationControl : StoreFlusher in method public shouldWriteSomeDataIntoTheLog() : void from class org.neo4j.kernel.impl.transaction.log.PhysicalLogFileTest",
Expand Down Expand Up @@ -32850,13 +32836,6 @@
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Add Parameter",
"description": "Add Parameter number : long in method private createResult(number long, meta long[]) : long[] from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence",
"comment": "null",
"validation": "FP",
"detectionTools": "RefactoringMiner",
"validators": "Nikos"
}, {
"type": "Remove Parameter",
"description": "Remove Parameter transactionId : long in method public checkPoint(transactionId long, logPosition LogPosition) : void from class org.neo4j.kernel.impl.transaction.log.TransactionLogWriter",
Expand Down Expand Up @@ -33347,6 +33326,13 @@
"validation": "CTP",
"detectionTools": "RefactoringMiner",
"validators": null
}, {
"type": "Change Parameter Type",
"description": "Change Parameter Type meta : long to meta : long[] in method private pack(meta long[]) : long[] from class org.neo4j.kernel.impl.util.ArrayQueueOutOfOrderSequence",
"comment": null,
"validation": "TP",
"detectionTools": "RefactoringMiner",
"validators": null
}],
"refDiffExecutionTime": 11758
}, {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/oracle/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ e19c6874431dc2c3046436c2ac249a0ab2ef3457, 2, 0, 0
5a38d0bca0e48853c3f7c00a0f098bada64797df, 42, 0, 1
a26b61201cd86c9a8773b418d9c84b446e95a601, 70, 0, 4
74d2cc420e5590ba3bc0ffcc15b30b76a9cbef0b, 10, 0, 5
001de307492df8f84ad15f6aaa0bd1e748d4ce27, 161, 2, 7
001de307492df8f84ad15f6aaa0bd1e748d4ce27, 161, 0, 7
4712de476aabe69cd762233c9641dd3cf9f8361b, 54, 0, 2
dc199688d69416da58b370ca2aa728e935fc8e0d, 25, 1, 0
77fab3caea4495798a248035f0e928f745c7c2db, 91, 0, 2
Expand Down

0 comments on commit f6d8175

Please sign in to comment.