-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move NativeError.kotlinCause from main to test
- Loading branch information
Showing
4 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
.../src/nativeCoroutinesTest/kotlin/com/rickclephas/kmp/nativecoroutines/NativeErrorTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.rickclephas.kmp.nativecoroutines | ||
|
||
import kotlin.native.concurrent.isFrozen | ||
import kotlin.test.* | ||
|
||
/** | ||
* Get the [Throwable] that is represented by the given [NativeError] | ||
*/ | ||
internal expect val NativeError.kotlinCause: Throwable? | ||
|
||
class NativeErrorTests { | ||
@Test | ||
fun `ensure frozen`() { | ||
val exception = RandomException() | ||
assertFalse(exception.isFrozen, "Exception shouldn't be frozen yet") | ||
val nsError = exception.asNativeError() | ||
assertTrue(nsError.isFrozen, "NSError should be frozen") | ||
assertTrue(exception.isFrozen, "Exception should be frozen") | ||
} | ||
|
||
@Test | ||
fun `ensure exception is part of user info`() { | ||
val exception = RandomException() | ||
val nsError = exception.asNativeError() | ||
assertSame(exception, nsError.kotlinCause, "Exception isn't part of the NativeError") | ||
} | ||
} |