Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2014)

Unified Diff: mojom/mojom_parser/parser/resolution_test.go

Issue 1511353002: New Mojom parser: Fix error message for invalid enum value initailizers. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/mojom_parser/parser/parsing.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/parser/resolution_test.go
diff --git a/mojom/mojom_parser/parser/resolution_test.go b/mojom/mojom_parser/parser/resolution_test.go
index fbf2cb887e8ce5c9aaccb925e3d036daf2da47ab..57c0cb92e2e380f50e6326c5cebc6285c42d050a 100644
--- a/mojom/mojom_parser/parser/resolution_test.go
+++ b/mojom/mojom_parser/parser/resolution_test.go
@@ -245,7 +245,7 @@ func TestSingleFileValueValidationErrors(t *testing.T) {
`
test.addTestCase(contents, []string{
"Illegal assignment",
- "The enum value MyEnum.TWO may not be assigned to Bar of type int32"})
+ "The enum value MyEnum.TWO of type MyEnum may not be assigned to Bar of type int32"})
}
////////////////////////////////////////////////////////////
@@ -333,7 +333,7 @@ func TestSingleFileValueValidationErrors(t *testing.T) {
`
test.addTestCase(contents, []string{
"Illegal assignment",
- "The enum value MyEnum.TWO may not be assigned to Bar of type string"})
+ "The enum value MyEnum.TWO of type MyEnum may not be assigned to Bar of type string"})
}
////////////////////////////////////////////////////////////
@@ -452,7 +452,53 @@ func TestSingleFileValueValidationErrors(t *testing.T) {
`
test.addTestCase(contents, []string{
"Illegal assignment",
- "The enum value MyOtherEnum.TWO may not be assigned to Bar of type MyEnum"})
+ "The enum value MyOtherEnum.TWO of type MyOtherEnum may not be assigned to Bar of type MyEnum"})
+ }
+
+ ////////////////////////////////////////////////////////////
+ // Test Case: Use an enum value from a different enum as an enum value initializer.
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ enum MyEnum {
+ ONE,
+ TWO,
+ THREE
+ };
+
+ enum MyOtherEnum {
+ ONE,
+ TWO = MyEnum.TWO,
+ THREE
+ };
+ `
+ test.addTestCase(contents, []string{
+ "Illegal assignment",
+ "The enum value MyEnum.TWO of type MyEnum may not be used as an initializer for TWO of type MyOtherEnum."})
+ }
+
+ ////////////////////////////////////////////////////////////
+ // Test Case: Use an enum value from a different enum as an enum value initializer.
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ enum MyEnum {
+ ONE,
+ TWO,
+ THREE
+ };
+
+ const MyEnum Bar = MyEnum.TWO;
+
+ enum MyOtherEnum {
+ ONE,
+ TWO = Bar,
+ THREE
+ };
+ `
+ test.addTestCase(contents, []string{
+ "Illegal assignment",
+ "Bar with the value MyEnum.TWO may not be used as an initializer for TWO of type MyOtherEnum."})
}
////////////////////////////////////////////////////////////
« no previous file with comments | « mojom/mojom_parser/parser/parsing.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698