| 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 {
|
|
|