Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(kotlin_generator.dart, enum.dart, enum.gen.dart, EnumTest.kt): a…
…dd SnakeCase enum member to EnumState

refactor(kotlin_generator.dart): simplify nameScreamingSnakeCase regex replacement logic
test(EnumTest.kt): update test cases to use new SnakeCase enum member for better coverage
  • Loading branch information
erdzan12 committed Jan 19, 2024
commit 1fa26d63c73642e965b41970792515a295703f22
3 changes: 1 addition & 2 deletions packages/pigeon/lib/kotlin_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ class KotlinGenerator extends StructuredGenerator<KotlinOptions> {
indent, member.documentationComments, _docCommentSpec);
final String nameScreamingSnakeCase = member.name
.replaceAllMapped(
RegExp(r'(?<=[a-z])[A-Z]'),
(Match m) => '_${m.group(0)}')
RegExp(r'(?<=[a-z])[A-Z]'), (Match m) => '_${m.group(0)}')
.toUpperCase();
indent.write('$nameScreamingSnakeCase($index)');
if (index != anEnum.members.length - 1) {
Expand Down
3 changes: 3 additions & 0 deletions packages/pigeon/pigeons/enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ enum EnumState {

/// This comment is to test enum member (Error) documentation comments.
Error,

/// This comment is to test enum member (SnakeCase) documentation comments.
SnakeCase,
}

/// This comment is to test class documentation comments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ enum EnumState {

/// This comment is to test enum member (Error) documentation comments.
Error,

/// This comment is to test enum member (SnakeCase) documentation comments.
SnakeCase,
}

/// This comment is to test class documentation comments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class EnumTest : TestCase() {
val api = mockk<EnumApi2Host>()

val channelName = "dev.flutter.pigeon.pigeon_integration_tests.EnumApi2Host.echo"
val input = DataWithEnum(EnumState.SUCCESS)
val input = DataWithEnum(EnumState.SNAKE_CASE)

val handlerSlot = slot<BinaryMessenger.BinaryMessageHandler>()

Expand Down Expand Up @@ -52,7 +52,7 @@ internal class EnumTest : TestCase() {
val binaryMessenger = mockk<BinaryMessenger>()
val api = EnumApi2Flutter(binaryMessenger)

val input = DataWithEnum(EnumState.SUCCESS)
val input = DataWithEnum(EnumState.SNAKE_CASE)

every { binaryMessenger.send(any(), any(), any()) } answers
{
Expand Down