<commit_before>package com.github.kmizu.kollection
import org.jetbrains.spek.api.Spek
import org.junit.Test
import kotlin.test.assertEquals
import com.github.kmizu.kollection.KList.*

class KListSpec(): Spek() {
    init {

        given("A KList") {
            on("which is a KCons") {
                val klist = KList(1, 2, 3, 4, 5)
                it("cons()") {
                    assertEquals(klist, 1 cons (2 cons (3 cons (4 cons (5 cons KNil)))))
                }
                it("reverse()") {
                    assertEquals(KList(5, 4, 3, 2, 1), klist.reverse())
                }
                it("foldLeft()") {
                    assertEquals(15, klist.foldLeft(0){l, r -> l + r})
                }
                it("foldRight()") {
                    assertEquals(-15, klist.foldRight(0){l, r -> r - l})
                }
                it("map()") {
                    assertEquals(KList(2, 3, 4, 5, 6), klist.map {it + 1})
                }
                it("flatMap()") {
                    val list = KList(1, 2, 3)
                    assertEquals(KList(1, 1, 2, 2, 3, 3), list.flatMap{ x -> KList(x, x)})
                }
                it("concat()") {
                    val list = KList(1, 2, 3)
                    assertEquals(KList(1, 2, 3, 4, 5, 1, 2, 3), klist concat list)
                }
                it("isEmpty()") {
                    assertEquals(false, klist.isEmpty())
                }
                it("length()") {
                    assertEquals(5, klist.length())
                }
                it("zip() -- 1") {
                    assertEquals(KList(1 to 0, 2 to 1, 3 to 2, 4 to 3, 5 to 4), klist zip KList(0, 1, 2, 3, 4))
                }
                it("zip() -- 2") {
                    assertEquals(KList(1 to 0, 2 to 1, 3 to 2, 4 to 3), klist zip KList(0, 1, 2, 3))
                }
            }<commit_msg>Test of unzip(), forAll, exists()<commit_after>package com.github.kmizu.kollection
import org.jetbrains.spek.api.Spek
import org.junit.Test
import kotlin.test.assertEquals
import com.github.kmizu.kollection.KList.*

class KListSpec(): Spek() {
    init {

        given("A KList") {
            on("which is a KCons") {
                val klist = KList(1, 2, 3, 4, 5)
                it("cons()") {
                    assertEquals(klist, 1 cons (2 cons (3 cons (4 cons (5 cons KNil)))))
                }
                it("reverse()") {
                    assertEquals(KList(5, 4, 3, 2, 1), klist.reverse())
                }
                it("foldLeft()") {
                    assertEquals(15, klist.foldLeft(0){l, r -> l + r})
                }
                it("foldRight()") {
                    assertEquals(-15, klist.foldRight(0){l, r -> r - l})
                }
                it("map()") {
                    assertEquals(KList(2, 3, 4, 5, 6), klist.map {it + 1})
                }
                it("flatMap()") {
                    val list = KList(1, 2, 3)
                    assertEquals(KList(1, 1, 2, 2, 3, 3), list.flatMap{ x -> KList(x, x)})
                }
                it("concat()") {
                    val list = KList(1, 2, 3)
                    assertEquals(KList(1, 2, 3, 4, 5, 1, 2, 3), klist concat list)
                }
                it("isEmpty()") {
                    assertEquals(false, klist.isEmpty())
                }
                it("length()") {
                    assertEquals(5, klist.length())
                }
                it("zip() -- 1") {
                    assertEquals(KList(1 to 0, 2 to 1, 3 to 2, 4 to 3, 5 to 4), klist zip KList(0, 1, 2, 3, 4))
                }
                it("zip() -- 2") {
                    assertEquals(KList(1 to 0, 2 to 1, 3 to 2, 4 to 3), klist zip KList(0, 1, 2, 3))
                }
                it("unzip()") {
                    assertEquals(Pair(KList(1, 2, 3, 4, 5), KList(2, 3, 4, 5, 6)), (klist zip KList(2, 3, 4, 5, 6)).unzip())
                }
                it("forAll() -- 1") {
                    assertEquals(true, klist.forAll { it < 6 })
                }
                it("forAll() -- 2") {
                    assertEquals(false, klist.forAll { it % 2 == 0 })
                }
                it("exists() -- 1") {
                    assertEquals(true, klist.exists { it % 2 == 0 })
                }
                it("exists() -- 2") {
                    assertEquals(false, klist.exists { it > 5 })
                }
            }
{'fraction_non_alphanumeric': 0.14967655587776044, 'fraction_numerical': 0.039928619228195406, 'mean_word_length': 1.113100848256362, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2366012', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1314, 'n_words': 350}