<commit_before>package circlet.runtime

import circlet.utils.*
import com.intellij.mock.*
import com.intellij.openapi.application.*
import junit.framework.*
import junit.framework.TestCase.*
import kotlinx.coroutines.experimental.*
import java.lang.Runnable
import java.util.concurrent.*


class TestApplicationDispatcher : TestCase() {
    private val dispatcher: ApplicationDispatcher

    init {
        ApplicationManager.setApplication(TestApplication(), {})
        dispatcher = ApplicationDispatcher(application)
    }

    fun testCoroutineDispatched() = runBlocking {
        val job = async(dispatcher.coroutineContext) {
            application.assertIsDispatchThread()
        }
        job.await()
    }

    fun testCoroutineDelay() = runBlocking {
        val job = async(dispatcher.coroutineContext) {
            delay(10)
            application.assertIsDispatchThread()
        }
        job.await()
    }

    fun testDispatch() {
        val runner = DispatchRunner(CountDownLatch(1))
        dispatcher.dispatch {
            runner.run {
                application.assertIsDispatchThread()
            }
        }
        runner.assertNoError()
    }

    fun testDispatchWithDelay() {
        val runner = DispatchRunner(CountDownLatch(1))
        dispatcher.dispatch(10) {<commit_msg>add GlobalScope to "async" coroutine builder<commit_after>package circlet.runtime

import circlet.utils.*
import com.intellij.mock.*
import com.intellij.openapi.application.*
import junit.framework.*
import junit.framework.TestCase.*
import kotlinx.coroutines.experimental.*
import java.util.concurrent.*


class TestApplicationDispatcher : TestCase() {
    private val dispatcher: ApplicationDispatcher

    init {
        ApplicationManager.setApplication(TestApplication(), {})
        dispatcher = ApplicationDispatcher(application)
    }

    fun testCoroutineDispatched() = runBlocking {
        val job = GlobalScope.async(dispatcher.coroutineContext) {
            application.assertIsDispatchThread()
        }
        job.await()
    }

    fun testCoroutineDelay() = runBlocking {
        val job = GlobalScope.async(dispatcher.coroutineContext) {
            delay(10)
            application.assertIsDispatchThread()
        }
        job.await()
    }

    fun testDispatch() {
        val runner = DispatchRunner(CountDownLatch(1))
        dispatcher.dispatch {
            runner.run {
                application.assertIsDispatchThread()
            }
        }
        runner.assertNoError()
    }

    fun testDispatchWithDelay() {
        val runner = DispatchRunner(CountDownLatch(1))
        dispatcher.dispatch(10) {
{'fraction_non_alphanumeric': 0.09135522838807097, 'fraction_numerical': 0.004530011325028313, 'mean_word_length': 2.670360110803324, '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': '4156153', 'n_tokens_mistral': 717, 'n_tokens_neox': 704, 'n_words': 125}