-
Notifications
You must be signed in to change notification settings - Fork 22
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 #66 from icerockdev/develop
Release 0.6.1
- Loading branch information
Showing
8 changed files
with
177 additions
and
5 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
63 changes: 63 additions & 0 deletions
63
sample/ios-app/Tests/ExternalGenericSealedClassesToSwiftEnumTests.swift
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,63 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import XCTest | ||
@testable import MultiPlatformLibrary | ||
@testable import MultiPlatformLibrarySwift | ||
|
||
// ===> NEED TO GENERATE | ||
extension TestExternalGenericSealedClass { | ||
var withoutPropertyKs: ExternalGenericSealedClassKs<NSString, NSString> { | ||
get { | ||
return ExternalGenericSealedClassKs(self.withoutProperty) | ||
} | ||
} | ||
var withOnePropertyTKs: ExternalGenericSealedClassKs<NSString, NSString> { | ||
get { | ||
return ExternalGenericSealedClassKs(self.withOnePropertyT) | ||
} | ||
} | ||
var withOnePropertyUKs: ExternalGenericSealedClassKs<NSString, NSString> { | ||
get { | ||
return ExternalGenericSealedClassKs(self.withOnePropertyU) | ||
} | ||
} | ||
var withTwoPropertiesKs: ExternalGenericSealedClassKs<NSString, NSString> { | ||
get { | ||
return ExternalGenericSealedClassKs(self.withTwoProperties) | ||
} | ||
} | ||
} | ||
// <=== NEED TO GENERATE | ||
|
||
class ExternalGenericSealedClassToSwiftEnumTests: XCTestCase { | ||
private let testSource = TestExternalGenericSealedClass() | ||
|
||
func testWithoutProperty() throws { | ||
if case .externalGenericWithoutProperty = testSource.withoutPropertyKs { } else { XCTFail() } | ||
XCTAssertEqual(testSource.withoutPropertyKs.sealed, ExternalGenericWithoutProperty()) | ||
} | ||
|
||
func testWithOnePropertyT() throws { | ||
if case .externalGenericWithOnePropertyT(let data) = testSource.withOnePropertyTKs { | ||
XCTAssertEqual(data.value, "test") | ||
} else { XCTFail() } | ||
XCTAssertEqual(testSource.withOnePropertyTKs.sealed, ExternalGenericWithOnePropertyT<NSString>(value: "test")) | ||
} | ||
|
||
func testWithOnePropertyU() throws { | ||
if case .externalGenericWithOnePropertyU(let data) = testSource.withOnePropertyUKs { | ||
XCTAssertEqual(data.value, "test") | ||
} else { XCTFail() } | ||
XCTAssertEqual(testSource.withOnePropertyUKs.sealed, ExternalGenericWithOnePropertyU<NSString>(value: "test")) | ||
} | ||
|
||
func testWithTwoProperties() throws { | ||
if case .externalGenericWithTwoProperties(let data) = testSource.withTwoPropertiesKs { | ||
XCTAssertEqual(data.value1, "test1") | ||
XCTAssertEqual(data.value2, "test2") | ||
} else { XCTFail() } | ||
XCTAssertEqual(testSource.withTwoPropertiesKs.sealed, ExternalGenericWithTwoProperties<NSString, NSString>(value1: "test1", value2: "test2")) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
sample/ios-app/Tests/ExternalNonGenericSealedClassesToSwiftEnumTests.swift
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,38 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
import XCTest | ||
@testable import MultiPlatformLibrary | ||
@testable import MultiPlatformLibrarySwift | ||
|
||
// ===> NEED TO GENERATE | ||
extension ExternalNonGenericSealedClass { | ||
var withoutPropertyKs: ExternalNonGenericSealedClassKs { | ||
get { | ||
return ExternalNonGenericSealedClassKs(ExternalNonGenericWithoutProperty()) | ||
} | ||
} | ||
var withPropertyKs: ExternalNonGenericSealedClassKs { | ||
get { | ||
return ExternalNonGenericSealedClassKs(ExternalNonGenericWithProperty(value: "test")) | ||
} | ||
} | ||
} | ||
// <=== NEED TO GENERATE | ||
|
||
class ExternalNonGenericSealedClassToSwiftEnumTests: XCTestCase { | ||
private let testSource = ExternalNonGenericSealedClass() | ||
|
||
func testWithoutProperty() throws { | ||
if case .externalNonGenericWithoutProperty = testSource.withoutPropertyKs { } else { XCTFail() } | ||
XCTAssertEqual(testSource.withoutPropertyKs.sealed, ExternalNonGenericWithoutProperty()) | ||
} | ||
|
||
func testWithProperty() throws { | ||
if case .externalNonGenericWithProperty(let data) = testSource.withPropertyKs { | ||
XCTAssertEqual(data.value, "test") | ||
} else { XCTFail() } | ||
XCTAssertEqual(testSource.withPropertyKs.sealed, ExternalNonGenericWithProperty(value: "test")) | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
...le/mpp-library/src/commonMain/kotlin/com/icerockdev/library/ExternalGenericSealedClass.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,44 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package com.icerockdev.library | ||
|
||
/** | ||
* This sealed class was created to test alongside the [ExternalNonGenericSealedClass] type to ensure that kswift | ||
* creates the correct enum types for generic sealed classes with multiple type parameters. | ||
* Here, subclasses are defined out of the body of the parent class. | ||
* See [GenericSealedClass] to see an example of nested subclasses | ||
*/ | ||
sealed class ExternalGenericSealedClass<out T, out U> | ||
|
||
/** A test `object` with no parameters and hard-coded types. */ | ||
object ExternalGenericWithoutProperty : ExternalGenericSealedClass<Nothing, Nothing>() | ||
|
||
/** | ||
* A test `data class` with one parameter, one generic type, and one hard-coded type. Hard-codes | ||
* the second type parameter (U). | ||
*/ | ||
data class ExternalGenericWithOnePropertyT<T>(val value: T) : | ||
ExternalGenericSealedClass<T, Nothing>() | ||
|
||
/** | ||
* A test `data class` with one parameter, one generic type, and one hard-coded type. Hard-codes | ||
* the first type parameter (T). | ||
*/ | ||
data class ExternalGenericWithOnePropertyU<U>(val value: U) : | ||
ExternalGenericSealedClass<Nothing, U>() | ||
|
||
/** A test `data class` with two parameters and two generic types. */ | ||
data class ExternalGenericWithTwoProperties<T, U>(val value1: T, val value2: U) : | ||
ExternalGenericSealedClass<T, U>() | ||
|
||
class TestExternalGenericSealedClass { | ||
val withoutProperty: ExternalGenericSealedClass<String, String> = ExternalGenericWithoutProperty | ||
val withOnePropertyT: ExternalGenericSealedClass<String, String> = | ||
ExternalGenericWithOnePropertyT("test") | ||
val withOnePropertyU: ExternalGenericSealedClass<String, String> = | ||
ExternalGenericWithOnePropertyU("test") | ||
val withTwoProperties: ExternalGenericSealedClass<String, String> = | ||
ExternalGenericWithTwoProperties("test1", "test2") | ||
} |
19 changes: 19 additions & 0 deletions
19
...mpp-library/src/commonMain/kotlin/com/icerockdev/library/ExternalNonGenericSealedClass.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,19 @@ | ||
/* | ||
* Copyright 2022 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package com.icerockdev.library | ||
|
||
/** | ||
* This sealed class was created to test alongside the [ExternalGenericSealedClass] type to ensure that | ||
* kswift creates the correct enum types for both generic and non-generic sealed classes. | ||
* Here, subclasses are defined out of the body of the parent class. | ||
* See [NonGenericSealedClass] to see an example of nested subclasses | ||
*/ | ||
sealed class ExternalNonGenericSealedClass | ||
|
||
/** A test `object` that has no property. */ | ||
object ExternalNonGenericWithoutProperty : ExternalNonGenericSealedClass() | ||
|
||
/** A test `data class` with an associated value. */ | ||
data class ExternalNonGenericWithProperty(val value: String) : ExternalNonGenericSealedClass() |