diff --git a/ql/test/library-tests/semmle/go/Function/getParameter.expected b/ql/test/library-tests/semmle/go/Function/getParameter.expected new file mode 100644 index 00000000000..b801a11f7ff --- /dev/null +++ b/ql/test/library-tests/semmle/go/Function/getParameter.expected @@ -0,0 +1,11 @@ +| main.go:7:6:7:7 | f1 | 0 | main.go:7:9:7:9 | x | +| main.go:9:12:9:13 | f2 | 0 | main.go:9:15:9:15 | x | +| main.go:9:12:9:13 | f2 | 1 | main.go:9:18:9:18 | y | +| main.go:9:12:9:13 | f2 | -1 | main.go:9:7:9:7 | t | +| main.go:11:12:11:13 | f3 | 0 | main.go:11:15:11:15 | x | +| main.go:11:12:11:13 | f3 | 1 | main.go:11:22:11:22 | y | +| main.go:11:12:11:13 | f3 | -1 | main.go:11:7:11:7 | _ | +| main.go:13:6:13:7 | f4 | 0 | main.go:13:9:13:9 | x | +| main.go:13:6:13:7 | f4 | 1 | main.go:13:16:13:16 | y | +| main.go:15:6:15:7 | f5 | 0 | main.go:15:9:15:9 | x | +| main.go:17:6:17:7 | f6 | 0 | main.go:17:9:17:9 | x | diff --git a/ql/test/library-tests/semmle/go/Function/getParameter.ql b/ql/test/library-tests/semmle/go/Function/getParameter.ql new file mode 100644 index 00000000000..c44a507edbd --- /dev/null +++ b/ql/test/library-tests/semmle/go/Function/getParameter.ql @@ -0,0 +1,4 @@ +import go + +from Function f, int i +select f, i, f.getParameter(i) diff --git a/ql/test/library-tests/semmle/go/Function/getResult.expected b/ql/test/library-tests/semmle/go/Function/getResult.expected new file mode 100644 index 00000000000..4f3d364e10b --- /dev/null +++ b/ql/test/library-tests/semmle/go/Function/getResult.expected @@ -0,0 +1,7 @@ +| main.go:17:6:17:7 | f6 | 0 | main.go:17:17:17:17 | y | +| main.go:19:6:19:7 | f7 | 0 | main.go:19:12:19:12 | x | +| main.go:19:6:19:7 | f7 | 1 | main.go:19:15:19:15 | y | +| main.go:21:6:21:7 | f8 | 0 | main.go:21:12:21:12 | x | +| main.go:21:6:21:7 | f8 | 1 | main.go:21:19:21:19 | _ | +| main.go:23:6:23:7 | f9 | 0 | main.go:23:12:23:12 | _ | +| main.go:23:6:23:7 | f9 | 1 | main.go:23:19:23:19 | y | diff --git a/ql/test/library-tests/semmle/go/Function/getResult.ql b/ql/test/library-tests/semmle/go/Function/getResult.ql new file mode 100644 index 00000000000..18dfec88626 --- /dev/null +++ b/ql/test/library-tests/semmle/go/Function/getResult.ql @@ -0,0 +1,4 @@ +import go + +from Function f, int i +select f, i, f.getResult(i) diff --git a/ql/test/library-tests/semmle/go/Function/main.go b/ql/test/library-tests/semmle/go/Function/main.go new file mode 100644 index 00000000000..7b60d28382c --- /dev/null +++ b/ql/test/library-tests/semmle/go/Function/main.go @@ -0,0 +1,23 @@ +package main + +type t int + +func main() {} + +func f1(x int) {} + +func (t t) f2(x, y int) {} + +func (_ t) f3(x int, y string) {} + +func f4(x int, y ...string) {} + +func f5(x int) int { return 0 } + +func f6(x int) (y int) { return 0 } + +func f7() (x, y int) { return 0, 0 } + +func f8() (x int, _ string) { return 0, "" } + +func f9() (_ int, y string) { return 0, "" }