Skip to content

UTBot Python cannot find Division by Zero problem #1831

Closed

Description

@tyuldashev

Description

Even when all types are specified UTBot Python doesn't find case when Division by Zero happens. Both UTBotJava and UTBotCPP can find such problem and it seems quite classic example of the problem which could be revealed with static analysis, so I would expect that UTBot Python also find the error.

To Reproduce

Steps to reproduce the behavior:

def div(a: int, b: int) -> int:
    return a / b
  1. Invoke code generation on code above

Expected behavior

Test which exposes 'Division by Zero' problem is generated among the others.

Actual behavior

No such test is generated, the only test looks like that:

    def test_div(self):
        """
        a = 4
        b = 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
        """
        actual = basics.div(4, 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111)
        
        self.assertEqual(0.0, actual)

Activity

  1. added
    ctg-enhancementNew feature, improvement or change request
    comp-codegenIssue is related to code generator
    lang-pythonIssue is related to python support
    on Feb 20, 2023
  2. tyuldashev commented on Feb 21, 2023

    @tyuldashev
    CollaboratorAuthor

    Suggestion is to allow UTBot to proceed test generation/execution till timeout with to hope to find possible errors (exceptions) in the code as it's done in Java UTbot. For sure this can be done only after equal time distribution is implemented #1820.

  3. denis-fokin commented on Feb 21, 2023

    @denis-fokin
    Collaborator

    We should distinguish cases with different results. From the point of our implementation we covered the path, but arithmetic exception and regular exit are different outcome and we must consider them.

    Additionally, we can try to work in three modes depending on the task:

    1. Try to cover all paths and exit
    2. If we find an error, let's try to find the non-error execution
    3. We covered everything with non-error executions but still have time, let's spend the time with benefits and try to find possible errors
  4. added this to the 2023.03 Release milestone on Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-enhancementNew feature, improvement or change requestlang-pythonIssue is related to python supportstatus-verifiedBug fix is verified

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions