Add tests for callees through function variables

This commit is contained in:
Owen Mansel-Chan
2022-04-13 16:51:34 +01:00
parent 528a735a0d
commit 373017ab9d
3 changed files with 18 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
missingCallee
| test.go:58:2:58:8 | call to f | test.go:41:1:53:1 | function declaration |
spuriousCallee
| main.go:44:3:44:7 | call to m | main.go:17:1:17:17 | function declaration |
| main.go:44:3:44:7 | call to m | main.go:21:1:21:20 | function declaration |
| main.go:56:2:56:6 | call to m | main.go:21:1:21:20 | function declaration |
| test.go:42:2:42:13 | call to Write | test.go:36:1:39:1 | function declaration |
| test.go:44:2:44:8 | call to f1 | test.go:36:1:39:1 | function declaration |

View File

@@ -40,10 +40,20 @@ func (_ MockWriter) Write(p []byte) (n int, err error) { // name: MockWriter.Wri
func test5(h hash.Hash, w io.Writer) { // name: test5
h.Write(nil) // callee: MockHash.Write
f1 := h.Write
f1(nil) // callee: MockHash.Write
w.Write(nil) // callee: MockWriter.Write callee: MockHash.Write
h.Reset() // callee: Resetter.Reset
f2 := w.Write
f2(nil) // callee: MockWriter.Write callee: MockHash.Write
h.Reset() // callee: Resetter.Reset
f3 := h.Reset
f3() // callee: Resetter.Reset
}
func test6(h MockHash, w MockWriter) {
test5(h, w) // callee: test5
f := test5
f(h, w) // callee: test5
}

View File

@@ -1,2 +1,7 @@
missingCallee
| test.go:44:2:44:8 | call to f1 | test.go:17:1:20:1 | function declaration |
| test.go:48:2:48:8 | call to f2 | test.go:17:1:20:1 | function declaration |
| test.go:48:2:48:8 | call to f2 | test.go:36:1:39:1 | function declaration |
| test.go:52:2:52:5 | call to f3 | test.go:11:1:11:28 | function declaration |
| test.go:58:2:58:8 | call to f | test.go:41:1:53:1 | function declaration |
spuriousCallee