Skip to content

Missing line separator in a generated kotlin file #842

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
CaelmBleidd opened this issue Sep 2, 2022 · 3 comments
Open

Missing line separator in a generated kotlin file #842

CaelmBleidd opened this issue Sep 2, 2022 · 3 comments
Assignees
Labels
comp-codegen Issue is related to code generator ctg-bug Issue is a bug lang-kotlin Issue is related to Kotlin language support

Comments

@CaelmBleidd
Copy link
Member

CaelmBleidd commented Sep 2, 2022

Description

When UTBot generates kotlin file with a failing test, there is a missing line separator in it.

To Reproduce

Steps to reproduce the behavior:

Example:

  1. Run any project with runtime error in the code in IntelliJ Idea
  2. Use the plugin to generate tests
  3. Open the generated test

Expected behavior

A line with "/* This test fails because...", line separator and line that fails

Actual behavior

Missing line separator

Visual proofs (screenshots, logs, images)

image

Environment

No specific environment is required.

Additional context

There is no additional context.

@korifey korifey moved this to Todo in UTBot Java Sep 2, 2022
@CaelmBleidd CaelmBleidd added ctg-bug Issue is a bug comp-codegen Issue is related to code generator labels Sep 2, 2022
@alisevych alisevych assigned denis-fokin and unassigned Damtev Sep 7, 2022
@alisevych alisevych modified the milestone: Release preparation Sep 7, 2022
@tyuldashev tyuldashev added the lang-kotlin Issue is related to Kotlin language support label Oct 28, 2022
@tyuldashev
Copy link
Collaborator

There is bigger problem with javadoc formatting, does dedicated issue is required?
image
as result displayed as
image

@EgorkaKulikov
Copy link
Collaborator

Actually this issue may be irrelevant because kotlin docs are now disabled.

@sofurihafe
Copy link
Member

sofurihafe commented Nov 11, 2022

Just tried to reproduce the problem with the following java & kotlin code samples. The missing line separator is present for both of them.

Code to generate tests for:
№1

public void methodThrowingException1() {
    int[] array = new int[1];
    int a = array[2];
}

public void methodThrowingException3() {
    int[] array = null;
    int a = array.length;
}

№2

fun methodThrowingException1() {
    val array = Array<Int>(1) { 1 };
    val a = array[2]
}

fun methodThrowingException2() {
    val array: Array<Int>? = null
    val a = array!![1]
}

Generated results:
№1

@Test
fun testMethodThrowingException11() {
    val simpleClass = SimpleClass()
    
    /* This test fails because method [SimpleClass.methodThrowingException1] produces [java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1]
        SimpleClass.methodThrowingException1(SimpleClass.java:4) */
    simpleClass.methodThrowingException1()
}

@Test
fun testMethodThrowingException31() {
    val simpleClass = SimpleClass()
    
    /* This test fails because method [SimpleClass.methodThrowingException3] produces [java.lang.NullPointerException]
        SimpleClass.methodThrowingException3(SimpleClass.java:9) */
    simpleClass.methodThrowingException3()
}

№2

@Test
fun testMethodThrowingException11() {
    val a = A()
    
    /* This test fails because method [A.methodThrowingException1] produces [java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1]
        A.methodThrowingException1(Main.kt:4) */
    a.methodThrowingException1()
}

@Test
fun testMethodThrowingException21() {
    val a = A()
    
    /* This test fails because method [A.methodThrowingException2] produces [java.lang.NullPointerException]
        A.methodThrowingException2(Main.kt:9) */
    a.methodThrowingException2()
}

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 ctg-bug Issue is a bug lang-kotlin Issue is related to Kotlin language support
Projects
Status: Todo
Development

No branches or pull requests

8 participants