| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package serialization | 5 package serialization |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "compress/gzip" | 9 "compress/gzip" |
| 10 "encoding/base64" | 10 "encoding/base64" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 func (test *singleFileTest) addTestCase(moduleNameSpace, contents string) { | 57 func (test *singleFileTest) addTestCase(moduleNameSpace, contents string) { |
| 58 fileName := fmt.Sprintf("file%d", test.testCaseNum) | 58 fileName := fmt.Sprintf("file%d", test.testCaseNum) |
| 59 test.cases = append(test.cases, singleFileTestCase{fileName, contents, f
alse, | 59 test.cases = append(test.cases, singleFileTestCase{fileName, contents, f
alse, |
| 60 new(mojom_files.MojomFile), new(mojom_files.MojomFileGraph)}) | 60 new(mojom_files.MojomFile), new(mojom_files.MojomFileGraph)}) |
| 61 | 61 |
| 62 test.expectedFile().FileName = fileName | 62 test.expectedFile().FileName = fileName |
| 63 test.expectedFile().SpecifiedFileName = stringPointer(fileName) | 63 test.expectedFile().SpecifiedFileName = stringPointer(fileName) |
| 64 test.expectedFile().ModuleNamespace = &moduleNameSpace | 64 test.expectedFile().ModuleNamespace = &moduleNameSpace |
| 65 | 65 |
| 66 test.expectedGraph().ResolvedTypes = make(map[string]mojom_types.UserDef
inedType) | 66 test.expectedGraph().ResolvedTypes = make(map[string]mojom_types.UserDef
inedType) |
| 67 » test.expectedGraph().ResolvedValues = make(map[string]mojom_types.UserDe
finedValue) | 67 » test.expectedGraph().ResolvedConstants = make(map[string]mojom_types.Dec
laredConstant) |
| 68 } | 68 } |
| 69 | 69 |
| 70 // endTestCase() should be invoked at the end of a case in | 70 // endTestCase() should be invoked at the end of a case in |
| 71 // TestSingleFileSerialization. | 71 // TestSingleFileSerialization. |
| 72 func (test *singleFileTest) endTestCase() { | 72 func (test *singleFileTest) endTestCase() { |
| 73 test.expectedGraph().Files = make(map[string]mojom_files.MojomFile) | 73 test.expectedGraph().Files = make(map[string]mojom_files.MojomFile) |
| 74 test.expectedGraph().Files[test.fileName()] = *test.expectedFile() | 74 test.expectedGraph().Files[test.fileName()] = *test.expectedFile() |
| 75 test.testCaseNum += 1 | 75 test.testCaseNum += 1 |
| 76 } | 76 } |
| 77 | 77 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 X0, | 523 X0, |
| 524 X1 = 42, | 524 X1 = 42, |
| 525 X2 = X1 | 525 X2 = X1 |
| 526 };` | 526 };` |
| 527 | 527 |
| 528 test.addTestCase("", contents) | 528 test.addTestCase("", contents) |
| 529 | 529 |
| 530 // DeclaredMojomObjects | 530 // DeclaredMojomObjects |
| 531 test.expectedFile().DeclaredMojomObjects.TopLevelEnums = &[]stri
ng{"TYPE_KEY:Foo"} | 531 test.expectedFile().DeclaredMojomObjects.TopLevelEnums = &[]stri
ng{"TYPE_KEY:Foo"} |
| 532 | 532 |
| 533 // Resolved Values | |
| 534 | |
| 535 // Foo.X0 | |
| 536 test.expectedGraph().ResolvedValues["TYPE_KEY:Foo.X0"] = &mojom_
types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 537 DeclData: test.newDeclData("X0", "Foo.X0"), | |
| 538 EnumTypeKey: "TYPE_KEY:Foo", | |
| 539 IntValue: 0, | |
| 540 }} | |
| 541 | |
| 542 // Foo.X1 | |
| 543 test.expectedGraph().ResolvedValues["TYPE_KEY:Foo.X1"] = &mojom_
types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 544 DeclData: test.newDeclData("X1", "Foo.X1"), | |
| 545 EnumTypeKey: "TYPE_KEY:Foo", | |
| 546 InitializerValue: &mojom_types.ValueLiteralValue{&mojom_
types.LiteralValueInt8Value{42}}, | |
| 547 IntValue: 42, | |
| 548 }} | |
| 549 | |
| 550 // Foo.X2 | |
| 551 test.expectedGraph().ResolvedValues["TYPE_KEY:Foo.X2"] = &mojom_
types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 552 DeclData: test.newDeclData("X2", "Foo.X2"), | |
| 553 EnumTypeKey: "TYPE_KEY:Foo", | |
| 554 InitializerValue: &mojom_types.ValueUserValueReference{m
ojom_types.UserValueReference{ | |
| 555 Identifier: "X1", | |
| 556 ValueKey: stringPointer("TYPE_KEY:Foo.X1"), | |
| 557 }}, | |
| 558 IntValue: 42, | |
| 559 }} | |
| 560 | |
| 561 // ResolvedTypes | 533 // ResolvedTypes |
| 562 | 534 |
| 563 // enum Foo | 535 // enum Foo |
| 564 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeEnumType{mojom_types.MojomEnum{ | 536 test.expectedGraph().ResolvedTypes["TYPE_KEY:Foo"] = &mojom_type
s.UserDefinedTypeEnumType{mojom_types.MojomEnum{ |
| 565 DeclData: test.newDeclData("Foo", "Foo"), | 537 DeclData: test.newDeclData("Foo", "Foo"), |
| 566 Values: []mojom_types.EnumValue{ | 538 Values: []mojom_types.EnumValue{ |
| 567 // Note(rudominer) It is a bug that we need to c
opy the enum values here. | |
| 568 // See https://github.com/domokit/mojo/issues/51
3. | |
| 569 // value X1 | 539 // value X1 |
| 570 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Fo
o.X0"].(*mojom_types.UserDefinedValueEnumValue).Value, | 540 » » » » mojom_types.EnumValue{ |
| 541 » » » » » DeclData: test.newDeclData("X0", "Foo.X0
"), |
| 542 » » » » » IntValue: 0, |
| 543 » » » » }, |
| 571 // value X1 | 544 // value X1 |
| 572 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Fo
o.X1"].(*mojom_types.UserDefinedValueEnumValue).Value, | 545 » » » » mojom_types.EnumValue{ |
| 546 » » » » » DeclData: test.newDeclData("X1",
"Foo.X1"), |
| 547 » » » » » InitializerValue: &mojom_types.ValueLite
ralValue{&mojom_types.LiteralValueInt8Value{42}}, |
| 548 » » » » » IntValue: 42, |
| 549 » » » » }, |
| 573 // value X2 | 550 // value X2 |
| 574 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Fo
o.X2"].(*mojom_types.UserDefinedValueEnumValue).Value, | 551 » » » » mojom_types.EnumValue{ |
| 552 » » » » » DeclData: test.newDeclData("X2", "Foo.X2
"), |
| 553 » » » » » InitializerValue: &mojom_types.ValueEnum
ValueReference{mojom_types.EnumValueReference{ |
| 554 » » » » » » Identifier: "X1", |
| 555 » » » » » » EnumTypeKey: "TYPE_KEY:Foo", |
| 556 » » » » » » EnumValueIndex: 1, |
| 557 » » » » » }}, |
| 558 » » » » » IntValue: 42, |
| 559 » » » » }, |
| 575 }, | 560 }, |
| 576 }} | 561 }} |
| 577 | 562 |
| 578 test.endTestCase() | 563 test.endTestCase() |
| 579 } | 564 } |
| 580 | 565 |
| 581 //////////////////////////////////////////////////////////// | 566 //////////////////////////////////////////////////////////// |
| 582 // Test Case: enum value name is shadowed by local constant declaration. | 567 // Test Case: enum value name is shadowed by local constant declaration. |
| 583 //////////////////////////////////////////////////////////// | 568 //////////////////////////////////////////////////////////// |
| 584 { | 569 { |
| 585 | 570 |
| 586 contents := ` | 571 contents := ` |
| 587 enum Color{ | 572 enum Color{ |
| 588 RED, BLUE | 573 RED, BLUE |
| 589 }; | 574 }; |
| 590 | 575 |
| 591 struct MyStruct { | 576 struct MyStruct { |
| 592 const Color RED = BLUE; | 577 const Color RED = BLUE; |
| 593 | 578 |
| 594 Color a_color = RED; // This should resolve to the local constant RED. | 579 Color a_color = RED; // This should resolve to the local constant RED. |
| 595 };` | 580 };` |
| 596 | 581 |
| 597 test.addTestCase("", contents) | 582 test.addTestCase("", contents) |
| 598 | 583 |
| 599 // DeclaredMojomObjects | 584 // DeclaredMojomObjects |
| 600 test.expectedFile().DeclaredMojomObjects.TopLevelEnums = &[]stri
ng{"TYPE_KEY:Color"} | 585 test.expectedFile().DeclaredMojomObjects.TopLevelEnums = &[]stri
ng{"TYPE_KEY:Color"} |
| 601 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:MyStruct"} | 586 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:MyStruct"} |
| 602 | 587 |
| 603 » » // Resolved Values | 588 » » // Resolved Constants |
| 604 | |
| 605 » » // Color.RED | |
| 606 » » test.expectedGraph().ResolvedValues["TYPE_KEY:Color.RED"] = &moj
om_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 607 » » » DeclData: test.newDeclData("RED", "Color.RED"), | |
| 608 » » » EnumTypeKey: "TYPE_KEY:Color", | |
| 609 » » » IntValue: 0, | |
| 610 » » }} | |
| 611 | |
| 612 » » // Color.BLUE | |
| 613 » » test.expectedGraph().ResolvedValues["TYPE_KEY:Color.BLUE"] = &mo
jom_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 614 » » » DeclData: test.newDeclData("BLUE", "Color.BLUE"), | |
| 615 » » » EnumTypeKey: "TYPE_KEY:Color", | |
| 616 » » » IntValue: 1, | |
| 617 » » }} | |
| 618 | 589 |
| 619 // MyStruct.RED | 590 // MyStruct.RED |
| 620 » » test.expectedGraph().ResolvedValues["TYPE_KEY:MyStruct.RED"] = &
mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 591 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:MyStruct.RED"]
= mojom_types.DeclaredConstant{ |
| 621 DeclData: *test.newContainedDeclData("RED", "MyStruct.RE
D", stringPointer("TYPE_KEY:MyStruct")), | 592 DeclData: *test.newContainedDeclData("RED", "MyStruct.RE
D", stringPointer("TYPE_KEY:MyStruct")), |
| 622 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ | 593 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ |
| 623 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, | 594 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, |
| 624 » » » Value: &mojom_types.ValueUserValueReference{ | 595 » » » Value: &mojom_types.ValueEnumValueReference{ |
| 625 » » » » mojom_types.UserValueReference{ | 596 » » » » mojom_types.EnumValueReference{ |
| 626 » » » » » Identifier: "BLUE", | 597 » » » » » Identifier: "BLUE", |
| 627 » » » » » ValueKey: stringPointer("TYPE_KEY:Colo
r.BLUE")}}, | 598 » » » » » EnumTypeKey: "TYPE_KEY:Color", |
| 628 » » }} | 599 » » » » » EnumValueIndex: 1}}, |
| 600 » » } |
| 629 | 601 |
| 630 // ResolvedTypes | 602 // ResolvedTypes |
| 631 | 603 |
| 632 // enum Color | 604 // enum Color |
| 633 test.expectedGraph().ResolvedTypes["TYPE_KEY:Color"] = &mojom_ty
pes.UserDefinedTypeEnumType{mojom_types.MojomEnum{ | 605 test.expectedGraph().ResolvedTypes["TYPE_KEY:Color"] = &mojom_ty
pes.UserDefinedTypeEnumType{mojom_types.MojomEnum{ |
| 634 DeclData: test.newDeclData("Color", "Color"), | 606 DeclData: test.newDeclData("Color", "Color"), |
| 635 Values: []mojom_types.EnumValue{ | 607 Values: []mojom_types.EnumValue{ |
| 636 // Note(rudominer) It is a bug that we need to c
opy the enum values here. | |
| 637 // See https://github.com/domokit/mojo/issues/51
3. | |
| 638 // value RED | 608 // value RED |
| 639 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Co
lor.RED"].(*mojom_types.UserDefinedValueEnumValue).Value, | 609 » » » » mojom_types.EnumValue{ |
| 610 » » » » » DeclData: test.newDeclData("RED", "Color
.RED"), |
| 611 » » » » » IntValue: 0, |
| 612 » » » » }, |
| 640 // value BLUE | 613 // value BLUE |
| 641 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Co
lor.BLUE"].(*mojom_types.UserDefinedValueEnumValue).Value, | 614 » » » » mojom_types.EnumValue{ |
| 615 » » » » » DeclData: test.newDeclData("BLUE", "Colo
r.BLUE"), |
| 616 » » » » » IntValue: 1, |
| 617 » » » » }, |
| 642 }, | 618 }, |
| 643 }} | 619 }} |
| 644 | 620 |
| 645 // struct MyStruct | 621 // struct MyStruct |
| 646 test.expectedGraph().ResolvedTypes["TYPE_KEY:MyStruct"] = &mojom
_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 622 test.expectedGraph().ResolvedTypes["TYPE_KEY:MyStruct"] = &mojom
_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 647 DeclData: &mojom_types.DeclarationData{ | 623 DeclData: &mojom_types.DeclarationData{ |
| 648 ShortName: stringPointer("MyStruct"), | 624 ShortName: stringPointer("MyStruct"), |
| 649 FullIdentifier: stringPointer("MyStruct"), | 625 FullIdentifier: stringPointer("MyStruct"), |
| 650 DeclaredOrdinal: -1, | 626 DeclaredOrdinal: -1, |
| 651 DeclarationOrder: -1, | 627 DeclarationOrder: -1, |
| 652 SourceFileInfo: &mojom_types.SourceFileInfo{ | 628 SourceFileInfo: &mojom_types.SourceFileInfo{ |
| 653 FileName: test.fileName(), | 629 FileName: test.fileName(), |
| 654 }, | 630 }, |
| 655 ContainedDeclarations: &mojom_types.ContainedDec
larations{ | 631 ContainedDeclarations: &mojom_types.ContainedDec
larations{ |
| 656 Constants: &[]string{"TYPE_KEY:MyStruct.
RED"}}, | 632 Constants: &[]string{"TYPE_KEY:MyStruct.
RED"}}, |
| 657 }, | 633 }, |
| 658 Fields: []mojom_types.StructField{ | 634 Fields: []mojom_types.StructField{ |
| 659 // field a_color | 635 // field a_color |
| 660 { | 636 { |
| 661 DeclData: test.newShortDeclDataO(0, -1,
"a_color"), | 637 DeclData: test.newShortDeclDataO(0, -1,
"a_color"), |
| 662 Type: &mojom_types.TypeTypeReference{moj
om_types.TypeReference{ | 638 Type: &mojom_types.TypeTypeReference{moj
om_types.TypeReference{ |
| 663 false, false, stringPointer("Col
or"), stringPointer("TYPE_KEY:Color")}}, | 639 false, false, stringPointer("Col
or"), stringPointer("TYPE_KEY:Color")}}, |
| 664 » » » » » DefaultValue: &mojom_types.DefaultFieldV
alueValue{&mojom_types.ValueUserValueReference{ | 640 » » » » » DefaultValue: &mojom_types.DefaultFieldV
alueValue{&mojom_types.ValueConstantReference{ |
| 665 » » » » » » mojom_types.UserValueReference{ | 641 » » » » » » mojom_types.ConstantReference{ |
| 666 » » » » » » » Identifier: "RED", | 642 » » » » » » » Identifier: "RED", |
| 667 » » » » » » » ValueKey: stringPointe
r("TYPE_KEY:MyStruct.RED")}}}, // Note this refers to MyStruct.RED and not Color
.RED. | 643 » » » » » » » ConstantKey: "TYPE_KEY:M
yStruct.RED"}}}, // Note this refers to MyStruct.RED and not Color.RED. |
| 668 }, | 644 }, |
| 669 }, | 645 }, |
| 670 }} | 646 }} |
| 671 | 647 |
| 672 test.endTestCase() | 648 test.endTestCase() |
| 673 } | 649 } |
| 674 | 650 |
| 675 //////////////////////////////////////////////////////////// | 651 //////////////////////////////////////////////////////////// |
| 676 // Test Case: In-Out method parameters with the same name. | 652 // Test Case: In-Out method parameters with the same name. |
| 677 //////////////////////////////////////////////////////////// | 653 //////////////////////////////////////////////////////////// |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 | 838 |
| 863 // DeclaredMojomObjects | 839 // DeclaredMojomObjects |
| 864 | 840 |
| 865 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{ | 841 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{ |
| 866 "TYPE_KEY:xu8", "TYPE_KEY:x8", "TYPE_KEY:xu16", "TYPE_KE
Y:x16", | 842 "TYPE_KEY:xu8", "TYPE_KEY:x8", "TYPE_KEY:xu16", "TYPE_KE
Y:x16", |
| 867 "TYPE_KEY:xu32", "TYPE_KEY:x32", "TYPE_KEY:xu64", "TYPE_
KEY:x64"} | 843 "TYPE_KEY:xu32", "TYPE_KEY:x32", "TYPE_KEY:xu64", "TYPE_
KEY:x64"} |
| 868 | 844 |
| 869 // Resolved Values | 845 // Resolved Values |
| 870 | 846 |
| 871 // xu8 | 847 // xu8 |
| 872 » » test.expectedGraph().ResolvedValues["TYPE_KEY:xu8"] = &mojom_typ
es.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 848 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:xu8"] = mojom_t
ypes.DeclaredConstant{ |
| 873 DeclData: *test.newDeclData("xu8", "xu8"), | 849 DeclData: *test.newDeclData("xu8", "xu8"), |
| 874 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint8}, | 850 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint8}, |
| 875 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint8Value{255}}, | 851 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint8Value{255}}, |
| 876 » » }} | 852 » » } |
| 877 | 853 |
| 878 // x8 | 854 // x8 |
| 879 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x8"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 855 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x8"] = mojom_ty
pes.DeclaredConstant{ |
| 880 DeclData: *test.newDeclData("x8", "x8"), | 856 DeclData: *test.newDeclData("x8", "x8"), |
| 881 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int8}, | 857 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int8}, |
| 882 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt8Value{-127}}, | 858 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt8Value{-127}}, |
| 883 » » }} | 859 » » } |
| 884 | 860 |
| 885 // xu16 | 861 // xu16 |
| 886 » » test.expectedGraph().ResolvedValues["TYPE_KEY:xu16"] = &mojom_ty
pes.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 862 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:xu16"] = mojom_
types.DeclaredConstant{ |
| 887 DeclData: *test.newDeclData("xu16", "xu16"), | 863 DeclData: *test.newDeclData("xu16", "xu16"), |
| 888 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint16}, | 864 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint16}, |
| 889 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint16Value{0xFFFF}}, | 865 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint16Value{0xFFFF}}, |
| 890 » » }} | 866 » » } |
| 891 | 867 |
| 892 // x16 | 868 // x16 |
| 893 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x16"] = &mojom_typ
es.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 869 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x16"] = mojom_t
ypes.DeclaredConstant{ |
| 894 DeclData: *test.newDeclData("x16", "x16"), | 870 DeclData: *test.newDeclData("x16", "x16"), |
| 895 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int16}, | 871 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int16}, |
| 896 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt16Value{-0x7FFF}}, | 872 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt16Value{-0x7FFF}}, |
| 897 » » }} | 873 » » } |
| 898 | 874 |
| 899 // xu32 | 875 // xu32 |
| 900 » » test.expectedGraph().ResolvedValues["TYPE_KEY:xu32"] = &mojom_ty
pes.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 876 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:xu32"] = mojom_
types.DeclaredConstant{ |
| 901 DeclData: *test.newDeclData("xu32", "xu32"), | 877 DeclData: *test.newDeclData("xu32", "xu32"), |
| 902 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint32}, | 878 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint32}, |
| 903 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint32Value{4294967295}}, | 879 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint32Value{4294967295}}, |
| 904 » » }} | 880 » » } |
| 905 | 881 |
| 906 // x32 | 882 // x32 |
| 907 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x32"] = &mojom_typ
es.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 883 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x32"] = mojom_t
ypes.DeclaredConstant{ |
| 908 DeclData: *test.newDeclData("x32", "x32"), | 884 DeclData: *test.newDeclData("x32", "x32"), |
| 909 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, | 885 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, |
| 910 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt32Value{-2147483647}}, | 886 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt32Value{-2147483647}}, |
| 911 » » }} | 887 » » } |
| 912 | 888 |
| 913 // xu64 | 889 // xu64 |
| 914 » » test.expectedGraph().ResolvedValues["TYPE_KEY:xu64"] = &mojom_ty
pes.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 890 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:xu64"] = mojom_
types.DeclaredConstant{ |
| 915 DeclData: *test.newDeclData("xu64", "xu64"), | 891 DeclData: *test.newDeclData("xu64", "xu64"), |
| 916 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint64}, | 892 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint64}, |
| 917 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint64Value{0xFFFFFFFFFFFFFFFF}}, | 893 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueUint64Value{0xFFFFFFFFFFFFFFFF}}, |
| 918 » » }} | 894 » » } |
| 919 | 895 |
| 920 // x64 | 896 // x64 |
| 921 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x64"] = &mojom_typ
es.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 897 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x64"] = mojom_t
ypes.DeclaredConstant{ |
| 922 DeclData: *test.newDeclData("x64", "x64"), | 898 DeclData: *test.newDeclData("x64", "x64"), |
| 923 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int64}, | 899 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int64}, |
| 924 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt64Value{-0x7FFFFFFFFFFFFFFF}}, | 900 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt64Value{-0x7FFFFFFFFFFFFFFF}}, |
| 925 » » }} | 901 » » } |
| 926 | 902 |
| 927 test.endTestCase() | 903 test.endTestCase() |
| 928 } | 904 } |
| 929 | 905 |
| 930 //////////////////////////////////////////////////////////// | 906 //////////////////////////////////////////////////////////// |
| 931 // Test Case: Builtin Floating-Point Constants | 907 // Test Case: Builtin Floating-Point Constants |
| 932 //////////////////////////////////////////////////////////// | 908 //////////////////////////////////////////////////////////// |
| 933 { | 909 { |
| 934 | 910 |
| 935 contents := ` | 911 contents := ` |
| 936 const float f1 = float.INFINITY; | 912 const float f1 = float.INFINITY; |
| 937 const float f2 = float.NEGATIVE_INFINITY; | 913 const float f2 = float.NEGATIVE_INFINITY; |
| 938 const float f3 = float.NAN; | 914 const float f3 = float.NAN; |
| 939 const double d1 = double.INFINITY; | 915 const double d1 = double.INFINITY; |
| 940 const double d2 = double.NEGATIVE_INFINITY; | 916 const double d2 = double.NEGATIVE_INFINITY; |
| 941 const double d3 = double.NAN; | 917 const double d3 = double.NAN; |
| 942 ` | 918 ` |
| 943 test.addTestCase("", contents) | 919 test.addTestCase("", contents) |
| 944 | 920 |
| 945 // DeclaredMojomObjects | 921 // DeclaredMojomObjects |
| 946 | 922 |
| 947 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{ | 923 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{ |
| 948 "TYPE_KEY:f1", "TYPE_KEY:f2", "TYPE_KEY:f3", "TYPE_KEY:d
1", "TYPE_KEY:d2", "TYPE_KEY:d3"} | 924 "TYPE_KEY:f1", "TYPE_KEY:f2", "TYPE_KEY:f3", "TYPE_KEY:d
1", "TYPE_KEY:d2", "TYPE_KEY:d3"} |
| 949 | 925 |
| 950 // Resolved Values | 926 // Resolved Values |
| 951 | 927 |
| 952 // f1 | 928 // f1 |
| 953 » » test.expectedGraph().ResolvedValues["TYPE_KEY:f1"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 929 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:f1"] = mojom_ty
pes.DeclaredConstant{ |
| 954 DeclData: *test.newDeclData("f1", "f1"), | 930 DeclData: *test.newDeclData("f1", "f1"), |
| 955 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Float}, | 931 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Float}, |
| 956 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_FloatInfinity}, | 932 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_FloatInfinity}, |
| 957 » » }} | 933 » » } |
| 958 | 934 |
| 959 // f2 | 935 // f2 |
| 960 » » test.expectedGraph().ResolvedValues["TYPE_KEY:f2"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 936 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:f2"] = mojom_ty
pes.DeclaredConstant{ |
| 961 DeclData: *test.newDeclData("f2", "f2"), | 937 DeclData: *test.newDeclData("f2", "f2"), |
| 962 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Float}, | 938 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Float}, |
| 963 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_FloatNegativeInfinity}, | 939 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_FloatNegativeInfinity}, |
| 964 » » }} | 940 » » } |
| 965 | 941 |
| 966 // f3 | 942 // f3 |
| 967 » » test.expectedGraph().ResolvedValues["TYPE_KEY:f3"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 943 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:f3"] = mojom_ty
pes.DeclaredConstant{ |
| 968 DeclData: *test.newDeclData("f3", "f3"), | 944 DeclData: *test.newDeclData("f3", "f3"), |
| 969 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Float}, | 945 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Float}, |
| 970 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_FloatNan}, | 946 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_FloatNan}, |
| 971 » » }} | 947 » » } |
| 972 | 948 |
| 973 // d1 | 949 // d1 |
| 974 » » test.expectedGraph().ResolvedValues["TYPE_KEY:d1"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 950 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:d1"] = mojom_ty
pes.DeclaredConstant{ |
| 975 DeclData: *test.newDeclData("d1", "d1"), | 951 DeclData: *test.newDeclData("d1", "d1"), |
| 976 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Double}, | 952 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Double}, |
| 977 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_DoubleInfinity}, | 953 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_DoubleInfinity}, |
| 978 » » }} | 954 » » } |
| 979 | 955 |
| 980 // d2 | 956 // d2 |
| 981 » » test.expectedGraph().ResolvedValues["TYPE_KEY:d2"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 957 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:d2"] = mojom_ty
pes.DeclaredConstant{ |
| 982 DeclData: *test.newDeclData("d2", "d2"), | 958 DeclData: *test.newDeclData("d2", "d2"), |
| 983 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Double}, | 959 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Double}, |
| 984 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_DoubleNegativeInfinity}, | 960 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_DoubleNegativeInfinity}, |
| 985 » » }} | 961 » » } |
| 986 | 962 |
| 987 // d3 | 963 // d3 |
| 988 » » test.expectedGraph().ResolvedValues["TYPE_KEY:d3"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 964 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:d3"] = mojom_ty
pes.DeclaredConstant{ |
| 989 DeclData: *test.newDeclData("d3", "d3"), | 965 DeclData: *test.newDeclData("d3", "d3"), |
| 990 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Double}, | 966 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Double}, |
| 991 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_DoubleNan}, | 967 Value: &mojom_types.ValueBuiltinValue{mojom_types.Bui
ltinConstantValue_DoubleNan}, |
| 992 » » }} | 968 » » } |
| 993 | 969 |
| 994 test.endTestCase() | 970 test.endTestCase() |
| 995 } | 971 } |
| 996 | 972 |
| 997 //////////////////////////////////////////////////////////// | 973 //////////////////////////////////////////////////////////// |
| 998 // Test Case: Constants defined in terms of other constants. | 974 // Test Case: Constants defined in terms of other constants. |
| 999 //////////////////////////////////////////////////////////// | 975 //////////////////////////////////////////////////////////// |
| 1000 { | 976 { |
| 1001 | 977 |
| 1002 contents := ` | 978 contents := ` |
| 1003 enum Color{ | 979 enum Color{ |
| 1004 RED, BLUE | 980 RED, BLUE |
| 1005 }; | 981 }; |
| 1006 | 982 |
| 1007 const int32 x1 = 42; | 983 const int32 x1 = 42; |
| 1008 const int32 x2 = x1; | 984 const int32 x2 = x1; |
| 1009 const int32 x3 = x2; | 985 const int32 x3 = x2; |
| 1010 | 986 |
| 1011 const Color c1 = RED; | 987 const Color c1 = RED; |
| 1012 const Color c2 = c1; | 988 const Color c2 = c1; |
| 1013 const Color c3 = c2; | 989 const Color c3 = c2; |
| 1014 ` | 990 ` |
| 1015 test.addTestCase("", contents) | 991 test.addTestCase("", contents) |
| 1016 | 992 |
| 1017 // DeclaredMojomObjects | 993 // DeclaredMojomObjects |
| 1018 test.expectedFile().DeclaredMojomObjects.TopLevelEnums = &[]stri
ng{"TYPE_KEY:Color"} | 994 test.expectedFile().DeclaredMojomObjects.TopLevelEnums = &[]stri
ng{"TYPE_KEY:Color"} |
| 1019 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{"TYPE_KEY:x1", "TYPE_KEY:x2", | 995 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{"TYPE_KEY:x1", "TYPE_KEY:x2", |
| 1020 "TYPE_KEY:x3", "TYPE_KEY:c1", "TYPE_KEY:c2", "TYPE_KEY:c
3"} | 996 "TYPE_KEY:x3", "TYPE_KEY:c1", "TYPE_KEY:c2", "TYPE_KEY:c
3"} |
| 1021 | 997 |
| 1022 » » // Resolved Values | 998 » » // Resolved Constants |
| 1023 | |
| 1024 » » // Color.RED | |
| 1025 » » test.expectedGraph().ResolvedValues["TYPE_KEY:Color.RED"] = &moj
om_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 1026 » » » DeclData: test.newDeclData("RED", "Color.RED"), | |
| 1027 » » » EnumTypeKey: "TYPE_KEY:Color", | |
| 1028 » » » IntValue: 0, | |
| 1029 » » }} | |
| 1030 | |
| 1031 » » // Color.BLUE | |
| 1032 » » test.expectedGraph().ResolvedValues["TYPE_KEY:Color.BLUE"] = &mo
jom_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 1033 » » » DeclData: test.newDeclData("BLUE", "Color.BLUE"), | |
| 1034 » » » EnumTypeKey: "TYPE_KEY:Color", | |
| 1035 » » » IntValue: 1, | |
| 1036 » » }} | |
| 1037 | 999 |
| 1038 // x1 | 1000 // x1 |
| 1039 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x1"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 1001 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x1"] = mojom_ty
pes.DeclaredConstant{ |
| 1040 DeclData: *test.newDeclData("x1", "x1"), | 1002 DeclData: *test.newDeclData("x1", "x1"), |
| 1041 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, | 1003 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, |
| 1042 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt8Value{42}}, | 1004 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt8Value{42}}, |
| 1043 » » }} | 1005 » » } |
| 1044 | 1006 |
| 1045 // x2 | 1007 // x2 |
| 1046 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x2"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 1008 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x2"] = mojom_ty
pes.DeclaredConstant{ |
| 1047 DeclData: *test.newDeclData("x2", "x2"), | 1009 DeclData: *test.newDeclData("x2", "x2"), |
| 1048 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, | 1010 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, |
| 1049 » » » Value: &mojom_types.ValueUserValueReference{mojom_types.
UserValueReference{ | 1011 » » » Value: &mojom_types.ValueConstantReference{mojom_types.C
onstantReference{ |
| 1050 » » » » Identifier: "x1", | 1012 » » » » Identifier: "x1", |
| 1051 » » » » ValueKey: stringPointer("TYPE_KEY:x1")}}, | 1013 » » » » ConstantKey: "TYPE_KEY:x1"}}, |
| 1052 ResolvedConcreteValue: &mojom_types.ValueLiteralValue{&m
ojom_types.LiteralValueInt8Value{42}}, | 1014 ResolvedConcreteValue: &mojom_types.ValueLiteralValue{&m
ojom_types.LiteralValueInt8Value{42}}, |
| 1053 » » }} | 1015 » » } |
| 1054 | 1016 |
| 1055 // x3 | 1017 // x3 |
| 1056 » » test.expectedGraph().ResolvedValues["TYPE_KEY:x3"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 1018 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:x3"] = mojom_ty
pes.DeclaredConstant{ |
| 1057 DeclData: *test.newDeclData("x3", "x3"), | 1019 DeclData: *test.newDeclData("x3", "x3"), |
| 1058 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, | 1020 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Int32}, |
| 1059 » » » Value: &mojom_types.ValueUserValueReference{mojom_types.
UserValueReference{ | 1021 » » » Value: &mojom_types.ValueConstantReference{mojom_types.C
onstantReference{ |
| 1060 » » » » Identifier: "x2", | 1022 » » » » Identifier: "x2", |
| 1061 » » » » ValueKey: stringPointer("TYPE_KEY:x2")}}, | 1023 » » » » ConstantKey: "TYPE_KEY:x2"}}, |
| 1062 ResolvedConcreteValue: &mojom_types.ValueLiteralValue{&m
ojom_types.LiteralValueInt8Value{42}}, | 1024 ResolvedConcreteValue: &mojom_types.ValueLiteralValue{&m
ojom_types.LiteralValueInt8Value{42}}, |
| 1063 » » }} | 1025 » » } |
| 1064 | 1026 |
| 1065 // c1 | 1027 // c1 |
| 1066 » » test.expectedGraph().ResolvedValues["TYPE_KEY:c1"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 1028 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:c1"] = mojom_ty
pes.DeclaredConstant{ |
| 1067 DeclData: *test.newDeclData("c1", "c1"), | 1029 DeclData: *test.newDeclData("c1", "c1"), |
| 1068 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ | 1030 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ |
| 1069 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, | 1031 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, |
| 1070 » » » Value: &mojom_types.ValueUserValueReference{mojom_types.
UserValueReference{ | 1032 » » » Value: &mojom_types.ValueEnumValueReference{mojom_types.
EnumValueReference{ |
| 1071 » » » » Identifier: "RED", | 1033 » » » » Identifier: "RED", |
| 1072 » » » » ValueKey: stringPointer("TYPE_KEY:Color.RED")}
}, | 1034 » » » » EnumTypeKey: "TYPE_KEY:Color", |
| 1073 » » }} | 1035 » » » » EnumValueIndex: 0}}, |
| 1036 » » } |
| 1074 | 1037 |
| 1075 // c2 | 1038 // c2 |
| 1076 » » test.expectedGraph().ResolvedValues["TYPE_KEY:c2"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 1039 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:c2"] = mojom_ty
pes.DeclaredConstant{ |
| 1077 DeclData: *test.newDeclData("c2", "c2"), | 1040 DeclData: *test.newDeclData("c2", "c2"), |
| 1078 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ | 1041 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ |
| 1079 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, | 1042 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, |
| 1080 » » » Value: &mojom_types.ValueUserValueReference{mojom_types.
UserValueReference{ | 1043 » » » Value: &mojom_types.ValueConstantReference{mojom_types.C
onstantReference{ |
| 1081 » » » » Identifier: "c1", | 1044 » » » » Identifier: "c1", |
| 1082 » » » » ValueKey: stringPointer("TYPE_KEY:c1")}}, | 1045 » » » » ConstantKey: "TYPE_KEY:c1"}}, |
| 1083 » » » ResolvedConcreteValue: &mojom_types.ValueUserValueRefere
nce{mojom_types.UserValueReference{ | 1046 » » » ResolvedConcreteValue: &mojom_types.ValueEnumValueRefere
nce{mojom_types.EnumValueReference{ |
| 1084 » » » » ValueKey: stringPointer("TYPE_KEY:Color.RED")}}, | 1047 » » » » EnumTypeKey: "TYPE_KEY:Color", |
| 1085 » » }} | 1048 » » » » EnumValueIndex: 0}}, |
| 1049 » » } |
| 1086 | 1050 |
| 1087 // c3 | 1051 // c3 |
| 1088 » » test.expectedGraph().ResolvedValues["TYPE_KEY:c3"] = &mojom_type
s.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant{ | 1052 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:c3"] = mojom_ty
pes.DeclaredConstant{ |
| 1089 DeclData: *test.newDeclData("c3", "c3"), | 1053 DeclData: *test.newDeclData("c3", "c3"), |
| 1090 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ | 1054 Type: &mojom_types.TypeTypeReference{mojom_types.TypeRef
erence{ |
| 1091 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, | 1055 false, false, stringPointer("Color"), stringPoin
ter("TYPE_KEY:Color")}}, |
| 1092 » » » Value: &mojom_types.ValueUserValueReference{mojom_types.
UserValueReference{ | 1056 » » » Value: &mojom_types.ValueConstantReference{mojom_types.C
onstantReference{ |
| 1093 » » » » Identifier: "c2", | 1057 » » » » Identifier: "c2", |
| 1094 » » » » ValueKey: stringPointer("TYPE_KEY:c2")}}, | 1058 » » » » ConstantKey: "TYPE_KEY:c2"}}, |
| 1095 » » » ResolvedConcreteValue: &mojom_types.ValueUserValueRefere
nce{mojom_types.UserValueReference{ | 1059 » » » ResolvedConcreteValue: &mojom_types.ValueEnumValueRefere
nce{mojom_types.EnumValueReference{ |
| 1096 » » » » ValueKey: stringPointer("TYPE_KEY:Color.RED")}}, | 1060 » » » » EnumTypeKey: "TYPE_KEY:Color", |
| 1097 » » }} | 1061 » » » » EnumValueIndex: 0}}, |
| 1062 » » } |
| 1098 | 1063 |
| 1099 // ResolvedTypes | 1064 // ResolvedTypes |
| 1100 | 1065 |
| 1101 // enum Color | 1066 // enum Color |
| 1102 test.expectedGraph().ResolvedTypes["TYPE_KEY:Color"] = &mojom_ty
pes.UserDefinedTypeEnumType{mojom_types.MojomEnum{ | 1067 test.expectedGraph().ResolvedTypes["TYPE_KEY:Color"] = &mojom_ty
pes.UserDefinedTypeEnumType{mojom_types.MojomEnum{ |
| 1103 DeclData: test.newDeclData("Color", "Color"), | 1068 DeclData: test.newDeclData("Color", "Color"), |
| 1104 Values: []mojom_types.EnumValue{ | 1069 Values: []mojom_types.EnumValue{ |
| 1105 // Note(rudominer) It is a bug that we need to c
opy the enum values here. | |
| 1106 // See https://github.com/domokit/mojo/issues/51
3. | |
| 1107 // value RED | 1070 // value RED |
| 1108 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Co
lor.RED"].(*mojom_types.UserDefinedValueEnumValue).Value, | 1071 » » » » mojom_types.EnumValue{ |
| 1072 » » » » » DeclData: test.newDeclData("RED", "Color
.RED"), |
| 1073 » » » » » IntValue: 0, |
| 1074 » » » » }, |
| 1109 // value BLUE | 1075 // value BLUE |
| 1110 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:Co
lor.BLUE"].(*mojom_types.UserDefinedValueEnumValue).Value, | 1076 » » » » mojom_types.EnumValue{ |
| 1077 » » » » » DeclData: test.newDeclData("BLUE", "Colo
r.BLUE"), |
| 1078 » » » » » IntValue: 1, |
| 1079 » » » » }, |
| 1111 }, | 1080 }, |
| 1112 }} | 1081 }} |
| 1113 | 1082 |
| 1114 test.endTestCase() | 1083 test.endTestCase() |
| 1115 } | 1084 } |
| 1116 | 1085 |
| 1117 //////////////////////////////////////////////////////////// | 1086 //////////////////////////////////////////////////////////// |
| 1118 // Test Case | 1087 // Test Case |
| 1119 //////////////////////////////////////////////////////////// | 1088 //////////////////////////////////////////////////////////// |
| 1120 { | 1089 { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 | 1123 |
| 1155 // Imports | 1124 // Imports |
| 1156 test.expectedFile().Imports = &[]string{ | 1125 test.expectedFile().Imports = &[]string{ |
| 1157 "another.file.canonical", "and.another.file.canonical", | 1126 "another.file.canonical", "and.another.file.canonical", |
| 1158 } | 1127 } |
| 1159 | 1128 |
| 1160 // DeclaredMojomObjects | 1129 // DeclaredMojomObjects |
| 1161 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:mojom.test.Foo"} | 1130 test.expectedFile().DeclaredMojomObjects.Structs = &[]string{"TY
PE_KEY:mojom.test.Foo"} |
| 1162 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{"TYPE_KEY:mojom.test.NUM_MAGI"} | 1131 test.expectedFile().DeclaredMojomObjects.TopLevelConstants = &[]
string{"TYPE_KEY:mojom.test.NUM_MAGI"} |
| 1163 | 1132 |
| 1164 » » // Resolved Values | 1133 » » // Resolved Constants |
| 1165 | 1134 |
| 1166 // NUM_MAGI | 1135 // NUM_MAGI |
| 1167 » » test.expectedGraph().ResolvedValues["TYPE_KEY:mojom.test.NUM_MAG
I"] = &mojom_types.UserDefinedValueDeclaredConstant{mojom_types.DeclaredConstant
{ | 1136 » » test.expectedGraph().ResolvedConstants["TYPE_KEY:mojom.test.NUM_
MAGI"] = mojom_types.DeclaredConstant{ |
| 1168 DeclData: *test.newDeclData("NUM_MAGI", "mojom.test.NUM_
MAGI"), | 1137 DeclData: *test.newDeclData("NUM_MAGI", "mojom.test.NUM_
MAGI"), |
| 1169 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint16}, | 1138 Type: &mojom_types.TypeSimpleType{mojom_types.Simple
Type_Uint16}, |
| 1170 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt8Value{3}}, | 1139 Value: &mojom_types.ValueLiteralValue{&mojom_types.Li
teralValueInt8Value{3}}, |
| 1171 » » }} | 1140 » » } |
| 1172 | |
| 1173 » » // Hats.TOP | |
| 1174 » » test.expectedGraph().ResolvedValues["TYPE_KEY:mojom.test.Foo.Hat
s.TOP"] = &mojom_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 1175 » » » DeclData: test.newDeclData("TOP", "mojom.test.Foo.Hat
s.TOP"), | |
| 1176 » » » EnumTypeKey: "TYPE_KEY:mojom.test.Foo.Hats", | |
| 1177 » » » IntValue: 0, | |
| 1178 » » }} | |
| 1179 | |
| 1180 » » // Hats.COWBOY | |
| 1181 » » test.expectedGraph().ResolvedValues["TYPE_KEY:mojom.test.Foo.Hat
s.COWBOY"] = &mojom_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 1182 » » » DeclData: test.newDeclData("COWBOY", "mojom.test.Foo.
Hats.COWBOY"), | |
| 1183 » » » EnumTypeKey: "TYPE_KEY:mojom.test.Foo.Hats", | |
| 1184 » » » IntValue: 3, | |
| 1185 » » » InitializerValue: &mojom_types.ValueUserValueReference{m
ojom_types.UserValueReference{ | |
| 1186 » » » » Identifier: "NUM_MAGI", | |
| 1187 » » » » ValueKey: stringPointer("TYPE_KEY:mojom.test.N
UM_MAGI"), | |
| 1188 » » » }}, | |
| 1189 » » }} | |
| 1190 | |
| 1191 » » // Hats.HARD | |
| 1192 » » test.expectedGraph().ResolvedValues["TYPE_KEY:mojom.test.Foo.Hat
s.HARD"] = &mojom_types.UserDefinedValueEnumValue{mojom_types.EnumValue{ | |
| 1193 » » » DeclData: test.newDeclData("HARD", "mojom.test.Foo.Ha
ts.HARD"), | |
| 1194 » » » EnumTypeKey: "TYPE_KEY:mojom.test.Foo.Hats", | |
| 1195 » » » IntValue: 4, | |
| 1196 » » }} | |
| 1197 | 1141 |
| 1198 // ResolvedTypes | 1142 // ResolvedTypes |
| 1199 | 1143 |
| 1200 // struct Foo | 1144 // struct Foo |
| 1201 test.expectedGraph().ResolvedTypes["TYPE_KEY:mojom.test.Foo"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ | 1145 test.expectedGraph().ResolvedTypes["TYPE_KEY:mojom.test.Foo"] =
&mojom_types.UserDefinedTypeStructType{mojom_types.MojomStruct{ |
| 1202 DeclData: &mojom_types.DeclarationData{ | 1146 DeclData: &mojom_types.DeclarationData{ |
| 1203 ShortName: stringPointer("Foo"), | 1147 ShortName: stringPointer("Foo"), |
| 1204 FullIdentifier: stringPointer("mojom.test.Foo"
), | 1148 FullIdentifier: stringPointer("mojom.test.Foo"
), |
| 1205 DeclaredOrdinal: -1, | 1149 DeclaredOrdinal: -1, |
| 1206 DeclarationOrder: -1, | 1150 DeclarationOrder: -1, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1227 DeclData: test.newShortDeclDataO(2, -1,
"z"), | 1171 DeclData: test.newShortDeclDataO(2, -1,
"z"), |
| 1228 Type: &mojom_types.TypeStringType{mo
jom_types.StringType{true}}, | 1172 Type: &mojom_types.TypeStringType{mo
jom_types.StringType{true}}, |
| 1229 }, | 1173 }, |
| 1230 }, | 1174 }, |
| 1231 }} | 1175 }} |
| 1232 | 1176 |
| 1233 // enum Hats | 1177 // enum Hats |
| 1234 test.expectedGraph().ResolvedTypes["TYPE_KEY:mojom.test.Foo.Hats
"] = &mojom_types.UserDefinedTypeEnumType{mojom_types.MojomEnum{ | 1178 test.expectedGraph().ResolvedTypes["TYPE_KEY:mojom.test.Foo.Hats
"] = &mojom_types.UserDefinedTypeEnumType{mojom_types.MojomEnum{ |
| 1235 DeclData: test.newContainedDeclData("Hats", "mojom.test.
Foo.Hats", stringPointer("TYPE_KEY:mojom.test.Foo")), | 1179 DeclData: test.newContainedDeclData("Hats", "mojom.test.
Foo.Hats", stringPointer("TYPE_KEY:mojom.test.Foo")), |
| 1236 Values: []mojom_types.EnumValue{ | 1180 Values: []mojom_types.EnumValue{ |
| 1237 // Note(rudominer) It is a bug that we need to c
opy the enum values here. | |
| 1238 // See https://github.com/domokit/mojo/issues/51
3. | |
| 1239 // value TOP | 1181 // value TOP |
| 1240 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:mo
jom.test.Foo.Hats.TOP"].(*mojom_types.UserDefinedValueEnumValue).Value, | 1182 » » » » mojom_types.EnumValue{ |
| 1183 » » » » » DeclData: test.newDeclData("TOP", "mojom
.test.Foo.Hats.TOP"), |
| 1184 » » » » » IntValue: 0, |
| 1185 » » » » }, |
| 1241 // value COWBOY | 1186 // value COWBOY |
| 1242 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:mo
jom.test.Foo.Hats.COWBOY"].(*mojom_types.UserDefinedValueEnumValue).Value, | 1187 » » » » mojom_types.EnumValue{ |
| 1188 » » » » » DeclData: test.newDeclData("COWBOY", "mo
jom.test.Foo.Hats.COWBOY"), |
| 1189 » » » » » IntValue: 3, |
| 1190 » » » » » InitializerValue: &mojom_types.ValueCons
tantReference{mojom_types.ConstantReference{ |
| 1191 » » » » » » Identifier: "NUM_MAGI", |
| 1192 » » » » » » ConstantKey: "TYPE_KEY:mojom.tes
t.NUM_MAGI", |
| 1193 » » » » » }}, |
| 1194 » » » » }, |
| 1243 // value HARD | 1195 // value HARD |
| 1244 » » » » test.expectedGraph().ResolvedValues["TYPE_KEY:mo
jom.test.Foo.Hats.HARD"].(*mojom_types.UserDefinedValueEnumValue).Value, | 1196 » » » » mojom_types.EnumValue{ |
| 1197 » » » » » DeclData: test.newDeclData("HARD", "mojo
m.test.Foo.Hats.HARD"), |
| 1198 » » » » » IntValue: 4, |
| 1199 » » » » }, |
| 1245 }, | 1200 }, |
| 1246 }} | 1201 }} |
| 1247 | 1202 |
| 1248 test.endTestCase() | 1203 test.endTestCase() |
| 1249 } | 1204 } |
| 1250 | 1205 |
| 1251 //////////////////////////////////////////////////////////// | 1206 //////////////////////////////////////////////////////////// |
| 1252 // Execute all of the test cases. | 1207 // Execute all of the test cases. |
| 1253 //////////////////////////////////////////////////////////// | 1208 //////////////////////////////////////////////////////////// |
| 1254 for _, c := range test.cases { | 1209 for _, c := range test.cases { |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2638 test.expectedFileA().ModuleNamespace = &moduleNameSpace | 2593 test.expectedFileA().ModuleNamespace = &moduleNameSpace |
| 2639 test.expectedFileB().ModuleNamespace = &moduleNameSpace | 2594 test.expectedFileB().ModuleNamespace = &moduleNameSpace |
| 2640 | 2595 |
| 2641 if importingName != "" { | 2596 if importingName != "" { |
| 2642 // Add and import to expected File A. | 2597 // Add and import to expected File A. |
| 2643 test.expectedFileA().Imports = new([]string) | 2598 test.expectedFileA().Imports = new([]string) |
| 2644 *test.expectedFileA().Imports = append(*test.expectedFileA().Imp
orts, test.expectedFileB().FileName) | 2599 *test.expectedFileA().Imports = append(*test.expectedFileA().Imp
orts, test.expectedFileB().FileName) |
| 2645 } | 2600 } |
| 2646 | 2601 |
| 2647 test.expectedGraph().ResolvedTypes = make(map[string]mojom_types.UserDef
inedType) | 2602 test.expectedGraph().ResolvedTypes = make(map[string]mojom_types.UserDef
inedType) |
| 2648 » test.expectedGraph().ResolvedValues = make(map[string]mojom_types.UserDe
finedValue) | 2603 » test.expectedGraph().ResolvedConstants = make(map[string]mojom_types.Dec
laredConstant) |
| 2649 } | 2604 } |
| 2650 | 2605 |
| 2651 // endTestCase() should be invoked at the end of a case in | 2606 // endTestCase() should be invoked at the end of a case in |
| 2652 // TestSingleFileSerialization. | 2607 // TestSingleFileSerialization. |
| 2653 func (test *twoFileTest) endTestCase() { | 2608 func (test *twoFileTest) endTestCase() { |
| 2654 test.expectedGraph().Files = make(map[string]mojom_files.MojomFile) | 2609 test.expectedGraph().Files = make(map[string]mojom_files.MojomFile) |
| 2655 test.expectedGraph().Files[test.expectedFileA().FileName] = *test.expect
edFileA() | 2610 test.expectedGraph().Files[test.expectedFileA().FileName] = *test.expect
edFileA() |
| 2656 test.expectedGraph().Files[test.expectedFileB().FileName] = *test.expect
edFileB() | 2611 test.expectedGraph().Files[test.expectedFileB().FileName] = *test.expect
edFileB() |
| 2657 test.testCaseNum += 1 | 2612 test.testCaseNum += 1 |
| 2658 } | 2613 } |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3517 } | 3472 } |
| 3518 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ | 3473 return fmt.Errorf("*****\nexpected=\n*****\n%q\n*****\na
ctual=\n*****\n%q\n*****\n"+ |
| 3519 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", | 3474 "match failed at position %d: expected=\n*****\n
%q\n******\nactual=\n*****\n%q\n******\n", |
| 3520 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) | 3475 expectedString, actualString, diffPos, mismatchE
xpected, mismatchActual) |
| 3521 } else { | 3476 } else { |
| 3522 return fmt.Errorf("expected != actual but the two printe
d equal.") | 3477 return fmt.Errorf("expected != actual but the two printe
d equal.") |
| 3523 } | 3478 } |
| 3524 } | 3479 } |
| 3525 return nil | 3480 return nil |
| 3526 } | 3481 } |
| OLD | NEW |