Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more tests for ignore-comment #47

Merged
merged 1 commit into from Jul 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 72 additions & 1 deletion testdata/src/ignore-comment/ignore_comment.go
Expand Up @@ -27,7 +27,7 @@ func _b() {
var d Direction

// this should not report.
//exhaustive:ignore
//exhaustive:ignore ... more arbitrary comment content (e.g. an explanation) ...
switch d {
case N:
case S:
Expand All @@ -44,6 +44,77 @@ func _b() {
}
}

func _c0() {
var d Direction

// this should report: according to go/ast, the comment is not considered to
// be associated with the switch statement node.
switch d { //exhaustive:ignore // want "^missing cases in switch of type Direction: E, directionInvalid$"
case N:
case S:
case W:
default:
}

// this should report.
switch d { // want "^missing cases in switch of type Direction: E, directionInvalid$"
case N:
case S:
case W:
default:
}
}

func _c1() {
var d Direction

// this should report: according to go/ast, the comment is not considered to
// be associated with the switch statement node.
switch d { // want "^missing cases in switch of type Direction: E, directionInvalid$"
//exhaustive:ignore
case N:
case S:
case W:
default:
}

// this should report.
switch d { // want "^missing cases in switch of type Direction: E, directionInvalid$"
case N:
case S:
case W:
default:
}
}

func _d() {
// this should report.
switch (func() Direction { // want "^missing cases in switch of type Direction: E, directionInvalid$"
// this should not report.
var x Direction
//exhaustive:ignore
switch x {
case N, S:
}
return N
})() {
case N:
case S:
case W:
default:
}

var d Direction

// this should report.
switch d { // want "^missing cases in switch of type Direction: E, directionInvalid$"
case N:
case S:
case W:
default:
}
}

func _nested() {
var d Direction

Expand Down