rocketraman
11/09/2023, 3:42 PMTypeError
, but note if mapOf
is changed to listOf
it works. Also note, if I use kotlin.test
instead of kotest, the test passes as well. This is clearly a bug somewhere, but I'm trying to figure out whether its a kotlin/js bug, or whether its a kotest bug. Thoughts? More details in 🧵. Here is a repo to play with locally: https://github.com/rocketraman/test-kt-duration-in-map
class DurationKoTest : FunSpec({
test("Duration in map") {
val tests = mapOf(
15.seconds to 0L,
)
tests.forEach { (input, output) ->
input.toLong(DurationUnit.DAYS) shouldBe output
}
}
})
TypeError: _get_rawValue__5zfu4e(...).shr_9fl3wl_k$ is not a function
at <global>._get_value__a43j40(/home/raman/source/test-kt-duration-in-map/compileSync/js/test/testDevelopmentExecutable/kotlin/src/kotlin/time/Duration.kt:37)
at <global>.Duration__toLong_impl_shr43i(/home/raman/source/test-kt-duration-in-map/compileSync/js/test/testDevelopmentExecutable/kotlin/src/kotlin/time/Duration.kt:789)
at protoOf.doResume_5yljmg(/home/raman/source/test-kt-duration-in-map/src/commonTest/kotlin/DurationKotest.kt:13)
at protoOf.invoke_s5vbtx(test-kt-duration-in-map-test.934710764.js:71230)
at slambda.$test(test-kt-duration-in-map-test.934710764.js:71272)
at protoOf.doResume_5yljmg(/runner/work/kotest/kotest/kotest-framework/kotest-framework-api/src/commonMain/kotlin/io/kotest/core/spec/style/scopes/RootScope.kt:36)
at protoOf.invoke_s5vbtx(test-kt-duration-in-map-test.934710764.js:10912)
at <global>.l(test-kt-duration-in-map-test.934710764.js:10959)
at protoOf.doResume_5yljmg(/runner/work/kotest/kotest/kotest-framework/kotest-framework-engine/src/commonMain/kotlin/io/kotest/engine/test/TestCaseExecutor.kt:91)
at protoOf.invoke_peurmw(test-kt-duration-in-map-test.934710764.js:28107)
Casey Brooks
11/09/2023, 4:19 PMMap.Entry
is destructured, but works fine if you access the key/value properties normally
// this works
tests.forEach {
val input = it.key
val output = it.value
input.toLong(DurationUnit.DAYS) shouldBe output
}
// this fails with the same error
tests.forEach {
val (input, output) = it
input.toLong(DurationUnit.DAYS) shouldBe output
}
rocketraman
11/09/2023, 4:26 PMCasey Brooks
11/09/2023, 4:31 PM