Skip to content

Commit

Permalink
apply testing.F
Browse files Browse the repository at this point in the history
  • Loading branch information
sivchari committed Apr 2, 2022
1 parent a4468e3 commit 60539c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tenv.go
Expand Up @@ -182,7 +182,7 @@ func checkStarExprTarget(typ *ast.StarExpr) bool {
}
targetName := x.Name + "." + selector.Sel.Name
switch targetName {
case "testing.T", "testing.B":
case "testing.T", "testing.B", "testing.F":
return true
default:
return false
Expand Down
9 changes: 9 additions & 0 deletions testdata/src/a/a.go
Expand Up @@ -46,3 +46,12 @@ func TBF(tb testing.TB) {
_ = err
}
}

func FF(f *testing.F) {
os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `f\\.Setenv\\(\\)` in FF"
err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `f\\.Setenv\\(\\)` in FF"
_ = err
if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `f\\.Setenv\\(\\)` in FF"
_ = err
}
}
9 changes: 9 additions & 0 deletions testdata/src/a/a_test.go
Expand Up @@ -46,3 +46,12 @@ func TB(tb testing.TB) {
_ = err
}
}

func FuzzF(f *testing.F) {
os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `f\\.Setenv\\(\\)` in FuzzF"
err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `f\\.Setenv\\(\\)` in FuzzF"
_ = err
if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `f\\.Setenv\\(\\)` in FuzzF"
_ = err
}
}

0 comments on commit 60539c5

Please sign in to comment.