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

Unified Diff: mojom/mojom_tool/integration_tests/resolution_test.go

Issue 1933563002: Mojom frontend: Start populating |resolved_concrete_value| field in mojom_types.mojom (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Grammar fix. Created 4 years, 8 months 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
Index: mojom/mojom_tool/integration_tests/resolution_test.go
diff --git a/mojom/mojom_tool/integration_tests/resolution_test.go b/mojom/mojom_tool/integration_tests/resolution_test.go
index f1434e22eac07226dff573a8ccd95ee0755b9b72..8f1385252352abf7fd43dc21e753294741cae844 100644
--- a/mojom/mojom_tool/integration_tests/resolution_test.go
+++ b/mojom/mojom_tool/integration_tests/resolution_test.go
@@ -107,6 +107,22 @@ func TestSingleFileResolutionErrors(t *testing.T) {
}
////////////////////////////////////////////////////////////
+ // Test Case: Circular reference of constants
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ const int32 MyConst1 = MyConst2;
+ const int32 MyConst2 = MyConst3;
+ const int32 MyConst3 = MyConst1;`
+
+ test.addTestCase(contents, []string{
+ "Use of unresolved value: \"MyConst2\"",
+ "Use of unresolved value: \"MyConst3\"",
+ "Use of unresolved value: \"MyConst1\"",
+ })
+ }
+
+ ////////////////////////////////////////////////////////////
// Execute all of the test cases.
////////////////////////////////////////////////////////////
for i, c := range test.cases {
@@ -1058,6 +1074,48 @@ func TestSingleFileResolutionSuccess(t *testing.T) {
}
////////////////////////////////////////////////////////////
+ // Test Case: A non-circular list of constant references.
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ const int32 MyConst1 = MyConst2;
+ const int32 MyConst2 = MyConst3;
+ const int32 MyConst3 = 42;`
+
+ testFunc := func(descriptor *mojom.MojomDescriptor) error {
+ myConst1 := descriptor.ValuesByKey["TYPE_KEY:MyConst1"].(*mojom.UserDefinedConstant)
+ value := myConst1.ValueRef().ResolvedConcreteValue().Value()
+ if value != int8(42) {
+ return fmt.Errorf("%v(%T) != 42", value, value)
+ }
+
+ return nil
+ }
+ test.addTestCase("", contents, testFunc)
+ }
+
+ ////////////////////////////////////////////////////////////
+ // Test Case: Circular reference of enum values
+ //
+ // NOTE: Even though we have a circular reference of enum values
+ // this case passes resolution. But the error will be detected during
+ // data computation phase when we attempt to produce integer values
+ // for the enum values. See TestEnumComputedDataError in computed_data_test.go. The reason this
+ // passes resoultion is that an enum value is a concrete value and so
+ // FIRST_VALUE has fully resolved to the concrete value MyEnum.x.
+ ////////////////////////////////////////////////////////////
+ {
+ contents := `
+ enum MyEnum {
+ x = FIRST_VALUE,
+ y,
+ z
+ };
+ const MyEnum FIRST_VALUE = MyEnum.x;`
+ test.addTestCase("", contents, nil)
+ }
+
+ ////////////////////////////////////////////////////////////
// Execute all of the test cases.
////////////////////////////////////////////////////////////
for i, c := range test.cases {
« no previous file with comments | « mojom/mojom_tool/integration_tests/computed_data_test.go ('k') | mojom/mojom_tool/mojom/user_defined_types.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698