Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 373017a

Browse files
committed
Add tests for callees through function variables
1 parent 528a735 commit 373017a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
missingCallee
2+
| test.go:58:2:58:8 | call to f | test.go:41:1:53:1 | function declaration |
23
spuriousCallee
34
| main.go:44:3:44:7 | call to m | main.go:17:1:17:17 | function declaration |
45
| main.go:44:3:44:7 | call to m | main.go:21:1:21:20 | function declaration |
56
| main.go:56:2:56:6 | call to m | main.go:21:1:21:20 | function declaration |
67
| test.go:42:2:42:13 | call to Write | test.go:36:1:39:1 | function declaration |
8+
| test.go:44:2:44:8 | call to f1 | test.go:36:1:39:1 | function declaration |

ql/test/library-tests/semmle/go/dataflow/CallGraph/test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,20 @@ func (_ MockWriter) Write(p []byte) (n int, err error) { // name: MockWriter.Wri
4040

4141
func test5(h hash.Hash, w io.Writer) { // name: test5
4242
h.Write(nil) // callee: MockHash.Write
43+
f1 := h.Write
44+
f1(nil) // callee: MockHash.Write
45+
4346
w.Write(nil) // callee: MockWriter.Write callee: MockHash.Write
44-
h.Reset() // callee: Resetter.Reset
47+
f2 := w.Write
48+
f2(nil) // callee: MockWriter.Write callee: MockHash.Write
49+
50+
h.Reset() // callee: Resetter.Reset
51+
f3 := h.Reset
52+
f3() // callee: Resetter.Reset
4553
}
4654

4755
func test6(h MockHash, w MockWriter) {
4856
test5(h, w) // callee: test5
57+
f := test5
58+
f(h, w) // callee: test5
4959
}
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
missingCallee
2+
| test.go:44:2:44:8 | call to f1 | test.go:17:1:20:1 | function declaration |
3+
| test.go:48:2:48:8 | call to f2 | test.go:17:1:20:1 | function declaration |
4+
| test.go:48:2:48:8 | call to f2 | test.go:36:1:39:1 | function declaration |
5+
| test.go:52:2:52:5 | call to f3 | test.go:11:1:11:28 | function declaration |
6+
| test.go:58:2:58:8 | call to f | test.go:41:1:53:1 | function declaration |
27
spuriousCallee

0 commit comments

Comments
 (0)