Skip to content

Fix broken summaries JavaDoc rendering #1767

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

Merged
merged 1 commit into from
Feb 3, 2023

Conversation

sofurihafe
Copy link
Member

@sofurihafe sofurihafe commented Feb 2, 2023

Description

The problem was related to incorrect if-statement index evaluation after ternary operation mapping (in JimpleToASTMap).

Also, the new test was introduced in order to fixate summary generation behavior for methods with user defined docs.

Fixes # (1605)

How to test

Automated tests

utbot-samples.

Manual tests

Generate a test for the following piece of code with 100% symbolic:

class A {
    /**
     * Returns the .
     * Ttt
     * Tta
     *
     * @param a a
     * @param b b, ...
     * @return the result.
     */
    public int result(long a, int b) {
        return (int) (a < 0 ? a + b : a);
    }
}

Result must be compilable and be without user defined JavaDocs in JavaDocs.

public final class ATest {
    ///region Test suites for executable A.result

    ///region SYMBOLIC EXECUTION: SUCCESSFUL EXECUTIONS for method result(long, int)

    /**
     * @utbot.classUnderTest {@link A}
     * @utbot.methodUnderTest {@link A#result(long, int)}
     * @utbot.returnsFrom {@code return (int) (a < 0 ? a + b : a);}
     */
    @Test
    @DisplayName("result: return (int) (a < 0 ? a + b : a) : False -> return (int) (a < 0 ? a + b : a)")
    public void testResult_A0aba() {
        A a = new A();

        int actual = a.result(0L, -255);

        assertEquals(0, actual);
    }

    /**
     * @utbot.classUnderTest {@link A}
     * @utbot.methodUnderTest {@link A#result(long, int)}
     * @utbot.returnsFrom {@code return (int) (a < 0 ? a + b : a);}
     */
    @Test
    @DisplayName("result: return (int) (a < 0 ? a + b : a) : True -> return (int) (a < 0 ? a + b : a)")
    public void testResult_A0aba_1() {
        A a = new A();

        int actual = a.result(-255L, -255);

        assertEquals(-510, actual);
    }
    ///endregion

    ///endregion
}

@sofurihafe sofurihafe added comp-codegen Issue is related to code generator comp-summaries Something related to the method names, code comments and display names generation ctg-bug-fix PR is fixing a bug labels Feb 2, 2023
@sofurihafe sofurihafe linked an issue Feb 3, 2023 that may be closed by this pull request
@sofurihafe sofurihafe force-pushed the andrey-t/jimple-ternary-tricks branch from 3802288 to aef984a Compare February 3, 2023 09:26
@EgorkaKulikov EgorkaKulikov enabled auto-merge (squash) February 3, 2023 09:32
@EgorkaKulikov EgorkaKulikov merged commit 8b1b5f7 into main Feb 3, 2023
@EgorkaKulikov EgorkaKulikov deleted the andrey-t/jimple-ternary-tricks branch February 3, 2023 09:50
tamarinvs19 pushed a commit that referenced this pull request Feb 6, 2023
Fix ternary return line alignment
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator comp-summaries Something related to the method names, code comments and display names generation ctg-bug-fix PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Summaries corrupted for a method documented with Java docs
3 participants