| OLD | NEW |
| 1 package parser | 1 package parser |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "mojom/mojom_parser/lexer" | 4 "mojom/mojom_parser/lexer" |
| 5 "mojom/mojom_parser/mojom" | 5 "mojom/mojom_parser/mojom" |
| 6 "testing" | 6 "testing" |
| 7 ) | 7 ) |
| 8 | 8 |
| 9 func TestAttachComments(t *testing.T) { | 9 func TestAttachComments(t *testing.T) { |
| 10 checkEq := func(expected, actual interface{}) { | 10 checkEq := func(expected, actual interface{}) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 interfaceFoo := mojomFile.DeclaredObjects[0].(*mojom.MojomInterface) | 60 interfaceFoo := mojomFile.DeclaredObjects[0].(*mojom.MojomInterface) |
| 61 // Sanity-check that we got the right object. | 61 // Sanity-check that we got the right object. |
| 62 checkEq("InterfaceFoo", interfaceFoo.SimpleName()) | 62 checkEq("InterfaceFoo", interfaceFoo.SimpleName()) |
| 63 checkEq("// FinalInterfaceComment", interfaceFoo.AttachedComments().Fina
l[0].Text) | 63 checkEq("// FinalInterfaceComment", interfaceFoo.AttachedComments().Fina
l[0].Text) |
| 64 | 64 |
| 65 method1 := interfaceFoo.MethodsByOrdinal[0] | 65 method1 := interfaceFoo.MethodsByOrdinal[0] |
| 66 // Sanity-check that we got the right method. | 66 // Sanity-check that we got the right method. |
| 67 checkEq("Method1", method1.SimpleName()) | 67 checkEq("Method1", method1.SimpleName()) |
| 68 | 68 |
| 69 » inParam1 := method1.Parameters.Fields[0] | 69 » inParam1 := method1.Parameters.FieldsInLexicalOrder[0] |
| 70 // Sanity-check that we got the right field. | 70 // Sanity-check that we got the right field. |
| 71 checkEq("in_param1", inParam1.SimpleName()) | 71 checkEq("in_param1", inParam1.SimpleName()) |
| 72 | 72 |
| 73 checkEq("// Method1RightComment", method1.AttachedComments().Right[0].Te
xt) | 73 checkEq("// Method1RightComment", method1.AttachedComments().Right[0].Te
xt) |
| 74 checkEq("/* InParam1Comment */", inParam1.AttachedComments().Right[0].Te
xt) | 74 checkEq("/* InParam1Comment */", inParam1.AttachedComments().Right[0].Te
xt) |
| 75 | 75 |
| 76 checkEq(lexer.EmptyLine, mojomFile.FinalComments[0].Kind) | 76 checkEq(lexer.EmptyLine, mojomFile.FinalComments[0].Kind) |
| 77 checkEq("// FinalComments", mojomFile.FinalComments[1].Text) | 77 checkEq("// FinalComments", mojomFile.FinalComments[1].Text) |
| 78 } | 78 } |
| 79 | 79 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ` | 112 ` |
| 113 descriptor := mojom.NewMojomDescriptor() | 113 descriptor := mojom.NewMojomDescriptor() |
| 114 parser := MakeParser("TestOnlyComments", "TestOnlyComments", source, des
criptor, nil) | 114 parser := MakeParser("TestOnlyComments", "TestOnlyComments", source, des
criptor, nil) |
| 115 parser.Parse() | 115 parser.Parse() |
| 116 | 116 |
| 117 mojomFile := parser.GetMojomFile() | 117 mojomFile := parser.GetMojomFile() |
| 118 comments := parser.GetComments() | 118 comments := parser.GetComments() |
| 119 | 119 |
| 120 mojom.AttachCommentsToMojomFile(mojomFile, comments) | 120 mojom.AttachCommentsToMojomFile(mojomFile, comments) |
| 121 } | 121 } |
| OLD | NEW |