Closed AmitPr closed 1 week ago
The changes in the pull request focus on the LineExpanderTest
class within the languagetool-language-modules
project. The primary modification involves replacing existing assertions with a new method, assertSetsEqual
, to compare sets derived from expanded strings, enhancing the clarity of tests by disregarding element order. Additionally, a helper method, parseStringToSet
, has been introduced to facilitate the conversion of bracketed strings into sets. The updates include adjustments to various test cases while maintaining existing error handling mechanisms.
File Path | Change Summary |
---|---|
languagetool-language-modules/de/src/test/java/org/languagetool/rules/de/LineExpanderTest.java | - Replaced assertThat assertions with assertSetsEqual for set equality checks.- Added method private void assertSetsEqual(String expected, String actual) .- Added method private Set<String> parseStringToSet(String bracketString) .- Updated test cases to utilize the new assertion method. |
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Fixes issues found by NonDex, caused by the use of a
HashSet
in thelanguagetool
internals, whilst test fixtures rely on ordering in serialized data.HashSet
s and otherHash
-based data structures in Java are explicitly nondeterministic, as platform or architecture differences could cause ordering differences.This PR enforces set equality in the
LineExpanderTest
, thus guaranteeing that any set of outputs generated using the same inputs to theexpand
will be valid, without relying on nondeterministic ordering.For example, before this fix, the test may have generated the following two strings:
Any difference in serialization would cause an erroneous test failure.
To verify the issue, running NonDex via Maven can be done as follows:
Which should fail before this PR, and succeed after this PR.
Depending on seeding, you may need to re-run this command or increase
-DnondexRuns
before a test failure is observed.Happy to iterate on this PR.
Summary by CodeRabbit
Bug Fixes
Refactor