Skip to content

Commit

Permalink
added a test for the issue golang#22371
Browse files Browse the repository at this point in the history
Change-Id: Ic250826fa2effa7920825271195e6d55b481a999
  • Loading branch information
sauterp committed May 9, 2021
1 parent d2fd503 commit 2d527c9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/go/ast/commentmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func f1() {
// also associated with s2
s2() // line comment for s2
// another comment also associated with s2
}
// associated with f1
// also associated with f1
Expand Down Expand Up @@ -87,11 +89,11 @@ var res = map[string]string{
"25: *ast.GenDecl": "x\nx = 0\nalso associated with x\n",
"29: *ast.FuncDecl": "f1\nassociated with f1\nalso associated with f1\n",
"31: *ast.ExprStmt": " associated with s1\nalso associated with s1\n",
"37: *ast.ExprStmt": "associated with s2\nalso associated with s2\nline comment for s2\n",
"45: *ast.FuncDecl": "associated with f2\nf2\n",
"49: *ast.AssignStmt": "addition\n",
"49: *ast.BasicLit": " 1\n",
"50: *ast.Ident": "the very last comment\n",
"37: *ast.ExprStmt": "associated with s2\nalso associated with s2\nline comment for s2\nanother comment also associated with s2\n",
"47: *ast.FuncDecl": "associated with f2\nf2\n",
"51: *ast.AssignStmt": "addition\n",
"51: *ast.BasicLit": " 1\n",
"52: *ast.Ident": "the very last comment\n",
}

func ctext(list []*CommentGroup) string {
Expand All @@ -110,7 +112,7 @@ func TestCommentMap(t *testing.T) {
}
cmap := NewCommentMap(fset, f, f.Comments)

// very correct association of comments
// verify correct association of comments
for n, list := range cmap {
key := fmt.Sprintf("%2d: %T", fset.Position(n.Pos()).Line, n)
got := ctext(list)
Expand Down

0 comments on commit 2d527c9

Please sign in to comment.