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

Side by Side Diff: mojom/mojom_parser/parser/comment_merger_test.go

Issue 1767033002: Mojom parser: Compute and validate struct field ordinals. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Maintain the property that the fields of a module.Struct are sorted in declaration order. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « mojom/mojom_parser/mojom/user_defined_types.go ('k') | mojom/mojom_parser/parser/parser_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698