<commit_before>package com.petertackage.kotlinoptions.assertions

import com.petertackage.kotlinoptions.Option

fun <T : Any> assertThat(actual: Option<T>): OptionAssertions<T> {
    return OptionAssertions(actual)
}

fun <T : Any> Option<T>.assertIsSome(): Option<T> {
    return apply { assertThat(this).isSome() }
}

fun <T : Any> Option<T>.assertIsNone(): Option<T> {
    return apply { assertThat(this).isNone() }
}

fun <T : Any> Option<T>.assertHasValue(expected: T): Option<T> {
    return apply { assertThat(this).hasValue(expected) }
}

fun <T : Any> Option<T>.assertHasValue(predicate: (T) -> Boolean): Option<T> {
    return apply { assertThat(this).hasValue(predicate) }
}

class OptionAssertions<T : Any> internal constructor(private val actual: Option<T>) {

    fun isSome(): OptionAssertions<T> {
        return apply {
            assert(actual.isSome(),
                    { "Expected: <Some> but was: <None>" })
        }
    }

    fun isNone(): OptionAssertions<T> {
        return apply {
            assert(actual.isNone(),
                    { "Expected: <None> but was: <Some>" })
        }
    }

    fun hasValue(expected: T): OptionAssertions<T> {
        isSome()
        val actualValue: T = actual.getUnsafe()
        return apply { assert(expected == actualValue, { "Expected value: <$expected> but was: <$actualValue>" }) }
    }

    fun hasValue(predicate: (T) -> Boolean): OptionAssertions<T> {
        isSome()
        val actualValue = actual.getUnsafe()
        return apply { assert(predicate(actualValue), { "Expected predicate did not match: <$actualValue>" }) }
    }
}<commit_msg>Rename predicate to expectedPredicate<commit_after>package com.petertackage.kotlinoptions.assertions

import com.petertackage.kotlinoptions.Option

fun <T : Any> assertThat(actual: Option<T>): OptionAssertions<T> {
    return OptionAssertions(actual)
}

fun <T : Any> Option<T>.assertIsSome(): Option<T> {
    return apply { assertThat(this).isSome() }
}

fun <T : Any> Option<T>.assertIsNone(): Option<T> {
    return apply { assertThat(this).isNone() }
}

fun <T : Any> Option<T>.assertHasValue(expected: T): Option<T> {
    return apply { assertThat(this).hasValue(expected) }
}

fun <T : Any> Option<T>.assertHasValue(predicate: (T) -> Boolean): Option<T> {
    return apply { assertThat(this).hasValue(predicate) }
}

class OptionAssertions<T : Any> internal constructor(private val actual: Option<T>) {

    fun isSome(): OptionAssertions<T> {
        return apply {
            assert(actual.isSome(),
                    { "Expected: <Some> but was: <None>" })
        }
    }

    fun isNone(): OptionAssertions<T> {
        return apply {
            assert(actual.isNone(),
                    { "Expected: <None> but was: <Some>" })
        }
    }

    fun hasValue(expected: T): OptionAssertions<T> {
        isSome()
        val actualValue: T = actual.getUnsafe()
        return apply { assert(expected == actualValue, { "Expected value: <$expected> but was: <$actualValue>" }) }
    }

    fun hasValue(expectedPredicate: (T) -> Boolean): OptionAssertions<T> {
        isSome()
        val actualValue = actual.getUnsafe()
        return apply { assert(expectedPredicate(actualValue), { "Expected predicate did not match: <$actualValue>" }) }
    }
}
{'fraction_non_alphanumeric': 0.14389799635701275, 'fraction_numerical': 0.0, 'mean_word_length': 3.149874055415617, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 63, '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': '1122138', 'n_tokens_mistral': 1022, 'n_tokens_neox': 1007, 'n_words': 231}