Patrick Kenyon
08/18/2023, 9:11 PM@Test
fun testRegex() {
runBlocking{
launch(Dispatchers.Default){
var string = "hello"
var regex = "(hello)"
for(i in 1..10){
string += string
regex += regex
}
println(regex)
println(string)
Regex(regex).find(string) <--- Crash with no exception
}
}
}
Jeremiah Van Offeren
08/18/2023, 9:33 PM@Test
fun testRegex() {
runBlocking{
launch(Dispatchers.Default){
var string = "hello"
var regex = "(hello)"
for(i in 1..10){
string += string
regex += regex
}
println(regex)
println(string)
Regex(regex).find(string) <--- Crash with no exception
}.join()
}
}
Patrick Kenyon
08/18/2023, 9:34 PM.join()
in my comment.Mohammadreza Khahani
08/19/2023, 1:31 PM@Test
fun testRegex() = runTest {
var string = "hello"
var regex = "(hello)"
for (i in 1..10) {
string += string
regex += regex
}
println(regex)
println(string)
Regex(regex).find(string)
}
You may need to add this dependency to have the runTest
.
dependencies {
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3'
}
More info about testing coroutines:
https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/Patrick Kenyon
08/22/2023, 6:16 PM