Skip to content

Commit

Permalink
add more tests for ignore-comment (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
nishanths committed Jul 24, 2022
1 parent d513b10 commit 7935df2
Showing 1 changed file with 72 additions and 1 deletion.
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

0 comments on commit 7935df2

Please sign in to comment.