-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(matching): Incorrect calculation of perfect node matching (#58)
Previously, we were only running an equality check between both nodes contents. Now, we rely on the property that two nodes are equal if their matching score equals the sum of their trees' sizes. This makes the check more accurate and more aligned with the strategies we're using in the tool.
- Loading branch information
Showing
10 changed files
with
115 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ pathfinding = "4.9.1" | |
|
||
[dev-dependencies] | ||
uuid = { workspace = true } | ||
parsing = { path = "../parsing" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use matching::matching_configuration::MatchingConfiguration; | ||
use model::language::Language; | ||
use parsing::ParserConfiguration; | ||
|
||
#[test] | ||
fn the_perfect_matching_calculation_is_correct() -> Result<(), Box<dyn std::error::Error>> { | ||
let config = ParserConfiguration::from(Language::Java); | ||
let left = parsing::parse_string( | ||
r#""" | ||
public class Main { | ||
static { | ||
int x = 2; | ||
} | ||
public static void main() { | ||
int a = 0; | ||
} | ||
public static void teste() { | ||
} | ||
} | ||
"""#, | ||
&config, | ||
)?; | ||
|
||
let right = parsing::parse_string( | ||
r#""" | ||
public class Main { | ||
public static void teste() { | ||
} | ||
static { | ||
int x = 2; | ||
} | ||
public static void main() { | ||
int a = 0; | ||
} | ||
} | ||
"""#, | ||
&config, | ||
)?; | ||
|
||
let matching_configuration = MatchingConfiguration::from(Language::Java); | ||
let matchings = matching::calculate_matchings(&left, &right, &matching_configuration); | ||
assert!( | ||
matchings | ||
.get_matching_entry(&left, &right) | ||
.unwrap() | ||
.is_perfect_match | ||
); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters