-
-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enum values that repeat the same number become aliases.
Fixes #1611
- Loading branch information
Showing
4 changed files
with
52 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
|
||
package com.thesamet.proto.e2e; | ||
|
||
enum EnumAllowingAlias { | ||
option allow_alias = true; | ||
EAA_UNSPECIFIED = 0; | ||
EAA_STARTED = 1; | ||
EAA_RUNNING = 1; // some doc | ||
EAA_FINISHED = 2; | ||
} |
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,17 @@ | ||
import com.thesamet.proto.e2e.enum_alias._ | ||
import org.scalatest._ | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.must.Matchers | ||
|
||
class EnumAliasSpec extends AnyFlatSpec with Matchers with OptionValues { | ||
"aliased enums" should "be equal" in { | ||
EnumAllowingAlias.EAA_RUNNING must be(EnumAllowingAlias.EAA_STARTED) | ||
} | ||
|
||
it should "report isX true for all aliases" in { | ||
EnumAllowingAlias.EAA_RUNNING.isEaaRunning must be(true) | ||
EnumAllowingAlias.EAA_RUNNING.isEaaStarted must be(true) | ||
EnumAllowingAlias.EAA_FINISHED.isEaaStarted must be(false) | ||
EnumAllowingAlias.EAA_FINISHED.isEaaRunning must be(false) | ||
} | ||
} |