<commit_before>import io.reactivex.Observable
import io.reactivex.RxMarble
import io.reactivex.Single
import io.reactivex.exceptions.CompositeException
import io.reactivex.schedulers.TestScheduler
import org.junit.Test
import java.lang.RuntimeException

/**
 * Created by jmfayard on 18.07.17.
 */

class Rxjava2Test {

    @Test fun join() {

        fun <T> just(observable: Observable<T>) = io.reactivex.functions.Function {
            i : Int -> observable
        }

        val scheduler = TestScheduler()
        val marble = RxMarble(scheduler = scheduler)
        val ints = marble.cold(
            "--1---3-4---5--6----7-9", List(10) { it*it  })
        val lifecycle = marble.cold(
            "----1-----2---1---2--1-", listOf(0, 1)
        )

<commit_msg>Rxjava2: cleaner to way to emit a list with a delay<commit_after>import io.reactivex.Observable
import io.reactivex.RxMarble
import io.reactivex.Single
import io.reactivex.exceptions.CompositeException
import io.reactivex.rxkotlin.merge
import io.reactivex.schedulers.Schedulers
import io.reactivex.schedulers.TestScheduler
import org.junit.Test
import java.lang.RuntimeException
import java.util.concurrent.TimeUnit

/**
 * Created by jmfayard on 18.07.17.
 */

class Rxjava2Test {

    @Test fun emitListWithTimer() {
        // better alternatives to Observable.interval() to emit a list of values
        val valuesToEmit = listOf("un", "deux", "trois", "quatre", "cinq")
        val observable = valuesToEmit.mapIndexed { index, value ->
            Observable.timer(index * 50L, TimeUnit.MILLISECONDS, Schedulers.computation()).map { value }
        }.merge()
        observable.blockingSubscribe(::println)
    }

    @Test fun join() {

        fun <T> just(observable: Observable<T>) = io.reactivex.functions.Function {
            i : Int -> observable
        }

        val scheduler = TestScheduler()
        val marble = RxMarble(scheduler = scheduler)
        val ints = marble.cold(
            "--1---3-4---5--6----7-9", List(10) { it*it  })
        val lifecycle = marble.cold(
            "----1-----2---1---2--1-", listOf(0, 1)
        )


{'fraction_non_alphanumeric': 0.1357444809769845, 'fraction_numerical': 0.023015500234852042, 'mean_word_length': 2.4918032786885247, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '7028498', 'n_tokens_mistral': 717, 'n_tokens_neox': 666, 'n_words': 150}