<commit_before>package com.github.shyiko.ktlint.ruleset.standard

import com.github.shyiko.ktlint.core.LintError
import com.github.shyiko.ktlint.test.diffFileFormat
import com.github.shyiko.ktlint.test.diffFileLint
import com.github.shyiko.ktlint.test.format
import com.github.shyiko.ktlint.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

class ImportOrderingRuleTest {

    @Test
    fun testLint() {
        assertThat(ImportOrderingRule().diffFileLint("spec/import-ordering/lint.kt.spec")).isEmpty()
    }

    @Test
    fun testFormat() {
        assertThat(
            ImportOrderingRule().diffFileFormat(
                "spec/import-ordering/format.kt.spec",
                "spec/import-ordering/format-expected.kt.spec"
            )
        ).isEmpty()
    }

    private val formattedImports =
        """
        import android.app.Activity
        import android.view.View
        import android.view.ViewGroup
        import java.util.List
        import kotlin.concurrent.Thread
        """.trimIndent()

    private val errorMessage = "Imports must be ordered in lexicographic order in a single group"

    @Test
    fun testFormatOk() {
        assertThat(ImportOrderingRule().lint(formattedImports)).isEmpty()
        assertThat(ImportOrderingRule().format(formattedImports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatWrongOrder() {
        val imports =
            """
            import android.view.ViewGroup
            import android.view.View
            import android.app.Activity
            import kotlin.concurrent.Thread
            import java.util.List
            """.trimIndent()
        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(
            listOf(LintError(1, 1, "import-ordering", errorMessage))
        )
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatWrongOrderAndBlankLines() {
        val imports =
            """
            import android.view.ViewGroup


            import android.view.View
            import android.app.Activity

            import kotlin.concurrent.Thread

            import java.util.List
            """.trimIndent()
        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(
            listOf(LintError(1, 1, "import-ordering", errorMessage))
        )
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatBlankLinesForMajorGroups() {
        val imports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup

            import java.util.List

            import kotlin.concurrent.Thread
            """.trimIndent()
        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(
            listOf(LintError(1, 1, "import-ordering", errorMessage))
        )
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatBlankLines() {
        val imports =
            """
            import android.app.Activity
            import android.view.View

            import android.view.ViewGroup
            import java.util.List


            import kotlin.concurrent.Thread
            """.trimIndent()
        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(
            listOf(LintError(1, 1, "import-ordering", errorMessage))
        )
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }
}
<commit_msg>inline expected test results<commit_after>package com.github.shyiko.ktlint.ruleset.standard

import com.github.shyiko.ktlint.core.LintError
import com.github.shyiko.ktlint.test.diffFileFormat
import com.github.shyiko.ktlint.test.diffFileLint
import com.github.shyiko.ktlint.test.format
import com.github.shyiko.ktlint.test.lint
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Test

class ImportOrderingRuleTest {

    @Test
    fun testLint() {
        assertThat(ImportOrderingRule().diffFileLint("spec/import-ordering/lint.kt.spec")).isEmpty()
    }

    @Test
    fun testFormat() {
        assertThat(
            ImportOrderingRule().diffFileFormat(
                "spec/import-ordering/format.kt.spec",
                "spec/import-ordering/format-expected.kt.spec"
            )
        ).isEmpty()
    }

    @Test
    fun testFormatOk() {
        val formattedImports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup
            import java.util.List
            import kotlin.concurrent.Thread
            """.trimIndent()

        assertThat(ImportOrderingRule().lint(formattedImports)).isEmpty()
        assertThat(ImportOrderingRule().format(formattedImports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatWrongOrder() {
        val imports =
            """
            import android.view.ViewGroup
            import android.view.View
            import android.app.Activity
            import kotlin.concurrent.Thread
            import java.util.List
            """.trimIndent()

        val expectedErrors = listOf(
            LintError(
                1,
                1,
                "import-ordering",
                "Imports must be ordered in lexicographic order in a single group"
            )
        )
        val formattedImports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup
            import java.util.List
            import kotlin.concurrent.Thread
            """.trimIndent()

        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(expectedErrors)
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatWrongOrderAndBlankLines() {
        val imports =
            """
            import android.view.ViewGroup


            import android.view.View
            import android.app.Activity

            import kotlin.concurrent.Thread

            import java.util.List
            """.trimIndent()

        val expectedErrors = listOf(
            LintError(
                1,
                1,
                "import-ordering",
                "Imports must be ordered in lexicographic order in a single group"
            )
        )
        val formattedImports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup
            import java.util.List
            import kotlin.concurrent.Thread
            """.trimIndent()

        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(expectedErrors)
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatBlankLinesForMajorGroups() {
        val imports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup

            import java.util.List

            import kotlin.concurrent.Thread
            """.trimIndent()

        val expectedErrors = listOf(
            LintError(
                1,
                1,
                "import-ordering",
                "Imports must be ordered in lexicographic order in a single group"
            )
        )
        val formattedImports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup
            import java.util.List
            import kotlin.concurrent.Thread
            """.trimIndent()

        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(expectedErrors)
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }

    @Test
    fun testFormatBlankLines() {
        val imports =
            """
            import android.app.Activity
            import android.view.View

            import android.view.ViewGroup
            import java.util.List


            import kotlin.concurrent.Thread
            """.trimIndent()

        val expectedErrors = listOf(
            LintError(
                1,
                1,
                "import-ordering",
                "Imports must be ordered in lexicographic order in a single group"
            )
        )
        val formattedImports =
            """
            import android.app.Activity
            import android.view.View
            import android.view.ViewGroup
            import java.util.List
            import kotlin.concurrent.Thread
            """.trimIndent()

        assertThat(ImportOrderingRule().lint(imports)).isEqualTo(expectedErrors)
        assertThat(ImportOrderingRule().format(imports)).isEqualTo(formattedImports)
    }
}

{'fraction_non_alphanumeric': 0.09128491620111732, 'fraction_numerical': 0.001787709497206704, 'mean_word_length': 1.899578879170716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2410915', 'n_tokens_mistral': 2373, 'n_tokens_neox': 2333, 'n_words': 398}