-
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.
Merge pull request #45 from ankushg/feat/supportedTarget
Create intermediate sourceset to share between Apple and non-Apple targets
- Loading branch information
Showing
16 changed files
with
89 additions
and
54 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
5 changes: 5 additions & 0 deletions
5
...oroutines-core/src/appleMain/kotlin/com/rickclephas/kmp/nativecoroutines/FreezingApple.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,5 @@ | ||
package com.rickclephas.kmp.nativecoroutines | ||
|
||
import kotlin.native.concurrent.freeze | ||
|
||
actual fun <T> T.freeze(): T = this.freeze() |
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
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
...nes-core/src/nativeCoroutinesMain/kotlin/com/rickclephas/kmp/nativecoroutines/Freezing.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,3 @@ | ||
package com.rickclephas.kmp.nativecoroutines | ||
|
||
internal expect fun <T> T.freeze(): T |
2 changes: 0 additions & 2 deletions
2
...as/kmp/nativecoroutines/NativeCallback.kt → ...as/kmp/nativecoroutines/NativeCallback.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
1 change: 0 additions & 1 deletion
1
...kmp/nativecoroutines/NativeCancellable.kt → ...kmp/nativecoroutines/NativeCancellable.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
11 changes: 11 additions & 0 deletions
11
...-core/src/nativeCoroutinesMain/kotlin/com/rickclephas/kmp/nativecoroutines/NativeError.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,11 @@ | ||
package com.rickclephas.kmp.nativecoroutines | ||
|
||
/** | ||
* Represents an error in a way that the specific platform is able to handle | ||
*/ | ||
expect class NativeError | ||
|
||
/** | ||
* Converts a [Throwable] to a [NativeError]. | ||
*/ | ||
internal expect fun Throwable.asNativeError(): NativeError |
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
File renamed without changes.
File renamed without changes.
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") | ||
} | ||
} |
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