package io.github.nomisrev
import arrow.core.NonEmptyList
import arrow.core.None
import arrow.core.Option
import arrow.core.Some
import arrow.core.ValidatedNel
import arrow.core.continuations.AtomicRef
import arrow.core.continuations.update
import arrow.core.identity
import arrow.core.invalidNel
import arrow.core.traverse
import arrow.core.valid
import arrow.fx.coroutines.ExitCase
import arrow.fx.coroutines.Platform
import arrow.fx.coroutines.Resource
import arrow.fx.coroutines.bracketCase
import arrow.fx.coroutines.continuations.ResourceScope
import io.kotest.common.runBlocking
import io.kotest.core.TestConfiguration
import io.kotest.core.listeners.TestListener
import io.kotest.core.spec.Spec
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
// TODO move this to Kotest Arrow Extensions
public fun TestConfiguration.resource(resource: Resource): ReadOnlyProperty =
TestResource(resource).also(::listener)
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
private class TestResource(private val resource: Resource) :
TestListener, ResourceScope, ReadOnlyProperty {
private val value: AtomicRef