Skip to content

Unneeded variable creation for final Enum state #2020

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

Open
alisevych opened this issue Mar 22, 2023 · 0 comments
Open

Unneeded variable creation for final Enum state #2020

alisevych opened this issue Mar 22, 2023 · 0 comments
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug

Comments

@alisevych
Copy link
Member

Description

There is used Enum variable duplication in the test generated by Symbolic engine.

To Reproduce

  1. Run the 'utbot' project in IntelliJ Idea 2022.3 Ultimate
  2. Install plugin built from unit-test-bot/rc2023.3 branch
  3. Use plugin to generate tests for enums/ClassWithEnum
  4. Open the generated test

Expected behavior

No unneeded variables are expected to be created.

Actual behavior

There is unneeded variable finalStatusEnum create after assertion.
It contains the same value as statusEnum used in the test.

Visual proofs (screenshots, logs, images)

    ///region SYMBOLIC EXECUTION: SUCCESSFUL EXECUTIONS for method changeMutableField(enums.ClassWithEnum.StatusEnum)

    /**
     * @utbot.classUnderTest {@link ClassWithEnum}
     * @utbot.methodUnderTest {@link ClassWithEnum#changeMutableField(StatusEnum)}
     * @utbot.executesCondition {@code (statusEnum == StatusEnum.READY): True}
     * @utbot.returnsFrom {@code return StatusEnum.READY.mutableInt;}
     */
    @Test
    public void testChangeMutableField_StatusEnumEqualsStatusEnumREADY() {
        ClassWithEnum classWithEnum = new ClassWithEnum();
        StatusEnum statusEnum = StatusEnum.READY;

        int actual = classWithEnum.changeMutableField(statusEnum);

        assertEquals(2, actual);

        StatusEnum finalStatusEnum = statusEnum;

    }

Environment

Windows 10 Pro
IntelliJ IDEA 2022.3.3 Ultimate
IntelliJ project, JDK 17

Additional context

There were workarounds for Enums already made, but it happens to be the issue in the engine.

@alisevych alisevych added ctg-bug Issue is a bug comp-symbolic-engine Issue is related to the symbolic execution engine labels Mar 22, 2023
@alisevych alisevych added this to the 2023.03 Release milestone Mar 22, 2023
@alisevych alisevych removed this from the 2023.03 Release milestone Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug
Projects
Status: Todo
Development

No branches or pull requests

2 participants