Omar Mainegra
04/29/2020, 8:15 PMsleep
without success)
@Test
fun `This test doesn't execute the println statement`() {
dispatch_async(dispatch_get_main_queue()) {
println("dispatch_async")
}
NSThread.sleepForTimeInterval(1.0)
}
I'm thinking about something similar to XCTestExpectation
. Any thoughts?Kris Wong
04/29/2020, 8:45 PMOmar Mainegra
04/29/2020, 8:46 PMprintln("$isMainThread")
prints true
Kris Wong
04/29/2020, 8:47 PMKris Wong
04/29/2020, 8:47 PMOmar Mainegra
04/29/2020, 8:48 PMdispatch_main()
throws
Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared common.platform.ConcurrencyModelTests.$This test doesn't execute the println statement$lambda-8$FUNCTION_REFERENCE$726@8b6ede08 from other thread
Kris Wong
04/29/2020, 8:49 PMOmar Mainegra
04/29/2020, 8:49 PMSorry, but I'm not passing anything
@Test
fun `This test doesn't execute the println statement`() {
Platform.isMemoryLeakCheckerActive = false
dispatch_async(dispatch_get_main_queue()) {
println("dispatch_async")
}
dispatch_main()
}
Kris Wong
04/29/2020, 8:49 PMOmar Mainegra
04/29/2020, 8:51 PM@Test
fun `This test doesn't execute the println statement`() {
Platform.isMemoryLeakCheckerActive = false
val block = {
println("dispatch_async")
}
dispatch_async(dispatch_get_main_queue(), block.freeze())
dispatch_main()
}
Omar Mainegra
04/29/2020, 8:51 PMKris Wong
04/29/2020, 8:51 PMKris Wong
04/29/2020, 8:52 PMOmar Mainegra
04/29/2020, 8:53 PMCFRunLoopRun
and CFRunLoopStop
could workKris Wong
04/29/2020, 8:53 PMOmar Mainegra
04/29/2020, 9:08 PM@Test
fun `This test does execute the println statement`() {
dispatch_async(dispatch_get_main_queue(), {
println("dispatch_async")
}.freeze())
NSRunLoop.currentRunLoop.runUntilDate(NSDate.dateWithTimeInterval(1.0, NSDate.now))
}
Omar Mainegra
04/29/2020, 9:08 PMKris Wong
04/29/2020, 9:42 PM