-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
105 additions
and
95 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...s/common/src/commonTest/kotlin/com/livefront/sealedenum/compilation/usecases/FlagTests.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,38 @@ | ||
package com.livefront.sealedenum.compilation.usecases | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class FlagTests { | ||
@Test | ||
fun two_objects_sealed_class() { | ||
assertEquals( | ||
listOf(Flag.FirstFlag, Flag.SecondFlag), | ||
FlagSealedEnum.values | ||
) | ||
} | ||
|
||
@Test | ||
fun two_enums_for_sealed_class() { | ||
assertEquals( | ||
listOf( | ||
FlagEnum.Flag_FirstFlag, | ||
FlagEnum.Flag_SecondFlag | ||
), | ||
enumValues<FlagEnum>().toList() | ||
) | ||
} | ||
|
||
@Test | ||
fun two_enums_for_sealed_class_with_mapping() { | ||
assertEquals( | ||
Flag.values.map(Flag::enum), | ||
enumValues<FlagEnum>().toList() | ||
) | ||
} | ||
|
||
@Test | ||
fun correct_enum_class() { | ||
assertEquals(FlagEnum::class, FlagSealedEnum.enumClass) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...ommonTest/kotlin/com/livefront/sealedenum/compilation/usecases/MultiInterfaceFlagTests.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,39 @@ | ||
package com.livefront.sealedenum.compilation.usecases | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class MultiInterfaceFlagTests { | ||
@Test | ||
fun three_objects_sealed_interface() { | ||
assertEquals( | ||
listOf(MultiInterfaceFlag.BothFlags, MultiInterfaceFlag.FirstFlag, MultiInterfaceFlag.SecondFlag), | ||
MultiInterfaceFlag.values | ||
) | ||
} | ||
|
||
@Test | ||
fun three_enums_for_sealed_class() { | ||
assertEquals( | ||
listOf( | ||
MultiInterfaceFlagEnum.MultiInterfaceFlag_BothFlags, | ||
MultiInterfaceFlagEnum.MultiInterfaceFlag_FirstFlag, | ||
MultiInterfaceFlagEnum.MultiInterfaceFlag_SecondFlag | ||
), | ||
enumValues<MultiInterfaceFlagEnum>().toList() | ||
) | ||
} | ||
|
||
@Test | ||
fun three_enums_for_sealed_interface_with_mapping() { | ||
assertEquals( | ||
MultiInterfaceFlag.values.map(MultiInterfaceFlag::enum), | ||
enumValues<MultiInterfaceFlagEnum>().toList() | ||
) | ||
} | ||
|
||
@Test | ||
fun correct_enum_class() { | ||
assertEquals(MultiInterfaceFlagEnum::class, MultiInterfaceFlagSealedEnum.enumClass) | ||
} | ||
} |
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
...otlin/com/livefront/sealedenum/compilation/usecases/MultiInterfaceFlagCompilationTests.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.livefront.sealedenum.compilation.usecases | ||
|
||
import com.livefront.sealedenum.testing.PlatformSourceType | ||
import com.livefront.sealedenum.testing.SharableProcessingSourceType | ||
import com.livefront.sealedenum.testing.assertCompiles | ||
import com.livefront.sealedenum.testing.assertGeneratedFileMatches | ||
import com.livefront.sealedenum.testing.compile | ||
import com.livefront.sealedenum.testing.getSourceFile | ||
import org.junit.jupiter.api.Test | ||
|
||
class MultiInterfaceFlagCompilationTests { | ||
@Test | ||
fun `compilation generates correct code`() { | ||
val result = compile( | ||
getSourceFile( | ||
SharableProcessingSourceType.COMMMON, | ||
PlatformSourceType.COMMON, | ||
"compilation", | ||
"usecases", | ||
"MultiInterfaceFlag.kt" | ||
) | ||
) | ||
|
||
assertCompiles(result) | ||
assertGeneratedFileMatches("MultiInterfaceFlag_SealedEnum.kt", multiInterfaceFlagGenerated, result) | ||
} | ||
} |
61 changes: 0 additions & 61 deletions
61
...c/jvmTest/kotlin/com/livefront/sealedenum/compilation/usecases/MultiInterfaceFlagTests.kt
This file was deleted.
Oops, something went wrong.