Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ protected UnresolvedNamePattern createTestInstance() {
protected UnresolvedNamePattern mutateInstance(UnresolvedNamePattern instance) {
Source source = instance.source();
String name = instance.name();
String pattern = instance.pattern();
switch (between(0, 1)) {
case 0 -> name = randomValueOtherThan(name, () -> randomAlphaOfLength(4));
case 1 -> pattern = randomValueOtherThan(pattern, () -> randomAlphaOfLength(4));
String pattern = randomValueOtherThan(instance.pattern(), () -> randomAlphaOfLength(4));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't follow the normal pattern of "retrieve all relevant instance attributes, randomly mutated one". The pattern is always mutated. We need to test the case when the pattern stays the same and only the name is mutated.

Changing just the name should lead to inequality. I think this PR uncovered a genuine bug in UnresolvedNamePattern that needs fixing instead.

if (randomBoolean()) {
name = randomValueOtherThan(name, () -> randomAlphaOfLength(4));
}
return new UnresolvedNamePattern(source, null, name, pattern);
return new UnresolvedNamePattern(source, null, pattern, name);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapping the arguments is a correct test fix. We should only merge this part and leave the mutation logic as it was before.

}

@Override
Expand Down