.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.1-0.20210319172145-bda8f5cee399 / cmd / guru / testdata / src / freevars / main.go
diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.1.1-0.20210319172145-bda8f5cee399/cmd/guru/testdata/src/freevars/main.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.1.1-0.20210319172145-bda8f5cee399/cmd/guru/testdata/src/freevars/main.go
new file mode 100644 (file)
index 0000000..c6aa08d
--- /dev/null
@@ -0,0 +1,40 @@
+package main
+
+// Tests of 'freevars' query.
+// See go.tools/guru/guru_test.go for explanation.
+// See freevars.golden for expected query results.
+
+// TODO(adonovan): it's hard to test this query in a single line of gofmt'd code.
+
+type T struct {
+       a, b int
+}
+
+type S struct {
+       x int
+       t T
+}
+
+func f(int) {}
+
+func main() {
+       type C int
+       x := 1
+       const exp = 6
+       if y := 2; x+y+int(C(3)) != exp { // @freevars fv1 "if.*{"
+               panic("expected 6")
+       }
+
+       var s S
+
+       for x, y := range "foo" {
+               println(s.x + s.t.a + s.t.b + x + int(y)) // @freevars fv2 "print.*y."
+       }
+
+       f(x) // @freevars fv3 "f.x."
+
+loop: // @freevars fv-def-label "loop:"
+       for {
+               break loop // @freevars fv-ref-label "break loop"
+       }
+}