mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
godoc: re-add test for ignoring //line comments in source code
The original CL 84050044 added a test case, and it happened to be in between various CLI test cases. CLI support was removed from x/tools/cmd/godoc in CL 141397, as part of golang/go#25443. Re-add a test case for this behavior to prevent regressions. Updates golang/go#32092 Updates golang/go#25443 Updates golang/go#5247 Change-Id: I0cea74cfe40d120e398a9005676134c5bad6136c Reviewed-on: https://go-review.googlesource.com/c/tools/+/177737 Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
d238219cc2
commit
09281b52a1
@ -53,7 +53,7 @@ func (c *Corpus) parseFile(fset *token.FileSet, filename string, mode parser.Mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Temporary ad-hoc fix for issue 5247.
|
// Temporary ad-hoc fix for issue 5247.
|
||||||
// TODO(gri) Remove this in favor of a better fix, eventually (see issue 7702).
|
// TODO(gri,dmitshur) Remove this in favor of a better fix, eventually (see issue 32092).
|
||||||
replaceLinePrefixCommentsWithBlankLine(src)
|
replaceLinePrefixCommentsWithBlankLine(src)
|
||||||
|
|
||||||
return parser.ParseFile(fset, filename, src, mode)
|
return parser.ParseFile(fset, filename, src, mode)
|
||||||
|
@ -46,3 +46,24 @@ package main`}))
|
|||||||
t.Error("pInfo.FSet = nil; want non-nil.")
|
t.Error("pInfo.FSet = nil; want non-nil.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue5247(t *testing.T) {
|
||||||
|
const packagePath = "example.com/p"
|
||||||
|
c := NewCorpus(mapfs.New(map[string]string{
|
||||||
|
"src/" + packagePath + "/p.go": `package p
|
||||||
|
|
||||||
|
//line notgen.go:3
|
||||||
|
// F doc //line 1 should appear
|
||||||
|
// line 2 should appear
|
||||||
|
func F()
|
||||||
|
//line foo.go:100`})) // No newline at end to check corner cases.
|
||||||
|
|
||||||
|
srv := &handlerServer{
|
||||||
|
p: &Presentation{Corpus: c},
|
||||||
|
c: c,
|
||||||
|
}
|
||||||
|
pInfo := srv.GetPageInfo("/src/"+packagePath, packagePath, 0, "linux", "amd64")
|
||||||
|
if got, want := pInfo.PDoc.Funcs[0].Doc, "F doc //line 1 should appear\nline 2 should appear\n"; got != want {
|
||||||
|
t.Errorf("pInfo.PDoc.Funcs[0].Doc = %q; want %q", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user