mirror of
https://github.com/golang/go
synced 2024-11-18 23:05:06 -07:00
go/analysis/analysistest: accept comments of /* */ form
Testing on analysis of location of comments, or lack of comments may need /* */-style comments to avoid interfere with the tested code. Change-Id: Id190aa243dc8ca90808c58f6d5dd4db1ade9f1c4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/212636 Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
parent
9fb4d21460
commit
2912ce79fc
@ -193,11 +193,13 @@ func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis
|
||||
for _, c := range cgroup.List {
|
||||
|
||||
text := strings.TrimPrefix(c.Text, "//")
|
||||
if text == c.Text {
|
||||
continue // not a //-comment
|
||||
if text == c.Text { // not a //-comment.
|
||||
text = strings.TrimPrefix(text, "/*")
|
||||
text = strings.TrimSuffix(text, "*/")
|
||||
}
|
||||
|
||||
// Hack: treat a comment of the form "//...// want..."
|
||||
// or "/*...// want... */
|
||||
// as if it starts at 'want'.
|
||||
// This allows us to add comments on comments,
|
||||
// as required when testing the buildtag analyzer.
|
||||
|
@ -54,6 +54,15 @@ func main() {
|
||||
// OK
|
||||
println("hello, world") // want "call of println"
|
||||
|
||||
// OK /* */-form.
|
||||
println("안녕, 세계") /* want "call of println" */
|
||||
|
||||
// OK (nested comment)
|
||||
println("Γειά σου, Κόσμε") // some comment // want "call of println"
|
||||
|
||||
// OK (nested comment in /**/)
|
||||
println("你好,世界") /* some comment // want "call of println" */
|
||||
|
||||
// OK (multiple expectations on same line)
|
||||
println(); println() // want "call of println(...)" "call of println(...)"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user