Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ClassId name in prettifiedName if canonical name is null #484

Merged
merged 2 commits into from
Jul 11, 2022

Conversation

dtim
Copy link
Collaborator

@dtim dtim commented Jul 11, 2022

Description

Anonymous classes do not have canonical names, It makes ClassId::canonicalName property fail with an exception. ClassId::prettifiedName fails for anonymous classes as well.

This fix changes the call to exception-throwing ClassId::canonicalName in prettifiedName with an explicit call to jClass::canonicalName which returns a nullable value. If the class has no canonical name, ClassId::name is used instead.

Fixes #459

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated Testing

Existing tests should not fail.

Manual Scenario

Run contest estimator with methodFilter = "com.google.common.base.CaseFormat.*" and projectFilter = null.

Without this fix, errors like this will be presented:

 public void testValues_errors()
     {
        // Couldn't generate some tests. List of errors:
        // 
        // 1 occurrences of:
        // ClassId com.google.common.base.CaseFormat$1 does not have canonical name
        
    }

With the fix, no these errors will be produced (many other errors will probably be generated instead, as there are related bugs and limitations in enum processing, both in engine and codegen).

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • Tests that prove my change is effective
  • All tests pass locally with my changes

@dtim dtim requested a review from Damtev July 11, 2022 13:31
Copy link
Member

@Damtev Damtev left a comment

Choose a reason for hiding this comment

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

LGTM, but could you please extend the existing documentation (in what cases do we return just a ClassId.name)?

@dtim dtim requested a review from Damtev July 11, 2022 14:59
@dtim
Copy link
Collaborator Author

dtim commented Jul 11, 2022

LGTM, but could you please extend the existing documentation (in what cases do we return just a ClassId.name)?

Done, thank you.

@dtim dtim enabled auto-merge (squash) July 11, 2022 15:17
@dtim dtim merged commit b468a42 into main Jul 11, 2022
@dtim dtim deleted the dtim/459-prettified-name-fix branch July 11, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Failed to generate tests because canonical name was not found
2 participants