Skip to content

Commit

Permalink
facts: move relevant tests into facts package
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikh committed May 3, 2019
1 parent 75d2b9e commit a577b01
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
15 changes: 15 additions & 0 deletions facts/facts_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package facts

import (
"testing"

"golang.org/x/tools/go/analysis/analysistest"
)

func TestDeprecated(t *testing.T) {
analysistest.Run(t, analysistest.TestData(), Deprecated, "Deprecated")
}

func TestPurity(t *testing.T) {
analysistest.Run(t, analysistest.TestData(), Purity, "Purity")
}
5 changes: 5 additions & 0 deletions facts/testdata/src/Deprecated/Deprecated.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package pkg

// Deprecated: Don't use this.
func fn2() { // want fn2:`Deprecated: Don't use this\.`
}
17 changes: 17 additions & 0 deletions facts/testdata/src/Purity/CheckPureFunctions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package pkg

func foo(a, b int) int { return a + b } // want foo:"is pure"
func bar(a, b int) int {
println(a + b)
return a + b
}

func empty() {}
func stubPointer() *int { return nil }
func stubInt() int { return 0 }

func fn3() {
empty()
stubPointer()
stubInt()
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func fn1(err error) {
}

// Deprecated: Don't use this.
func fn2() { // want fn2:`Deprecated: Don't use this\.`
func fn2() {
_ = syscall.StringByteSlice("")

anon := func(x int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func fn1(err error) {
}

// Deprecated: Don't use this.
func fn2() { // want fn2:`Deprecated: Don't use this\.`
func fn2() {
_ = syscall.StringByteSlice("")

anon := func(x int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func fn2() {
r.WithContext(context.Background()) // want `is a pure function but its return value is ignored`
}

func foo(a, b int) int { return a + b } // want foo:"IsPure"
func foo(a, b int) int { return a + b }
func bar(a, b int) int {
println(a + b)
return a + b
Expand Down

0 comments on commit a577b01

Please sign in to comment.