From e286bd4baba7687f9caf8dff3fbec67d1e39e376 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Wed, 14 Aug 2024 17:05:59 +0100 Subject: [PATCH] chore: Add test for rangefunc (#117) --- .../testdata/snapshots/input/initial/go.mod | 2 +- .../snapshots/input/initial/rangefunc.go | 12 ++++++++++ .../snapshots/output/initial/rangefunc.go | 23 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 internal/testdata/snapshots/input/initial/rangefunc.go create mode 100755 internal/testdata/snapshots/output/initial/rangefunc.go diff --git a/internal/testdata/snapshots/input/initial/go.mod b/internal/testdata/snapshots/input/initial/go.mod index 124fa43..d95578f 100644 --- a/internal/testdata/snapshots/input/initial/go.mod +++ b/internal/testdata/snapshots/input/initial/go.mod @@ -1,3 +1,3 @@ module sg/initial -go 1.19 +go 1.23 diff --git a/internal/testdata/snapshots/input/initial/rangefunc.go b/internal/testdata/snapshots/input/initial/rangefunc.go new file mode 100644 index 0000000..2efd59a --- /dev/null +++ b/internal/testdata/snapshots/input/initial/rangefunc.go @@ -0,0 +1,12 @@ +package initial + +import ( + "slices" +) + +func f(xs []int) int { + for _, x := range slices.All(xs) { + return x + } + return -1 +} diff --git a/internal/testdata/snapshots/output/initial/rangefunc.go b/internal/testdata/snapshots/output/initial/rangefunc.go new file mode 100755 index 0000000..dc8f8c7 --- /dev/null +++ b/internal/testdata/snapshots/output/initial/rangefunc.go @@ -0,0 +1,23 @@ + package initial +// ^^^^^^^ reference 0.1.test `sg/initial`/ + + import ( + "slices" +// ^^^^^^ reference github.com/golang/go/src go1.22 slices/ + ) + + func f(xs []int) int { +// ^ definition 0.1.test `sg/initial`/f(). +// documentation ```go +// ^^ definition local 0 + for _, x := range slices.All(xs) { +// ^ definition local 1 +// ^^^^^^ reference github.com/golang/go/src go1.22 slices/ +// ^^^ reference github.com/golang/go/src go1.22 slices/All(). +// ^^ reference local 0 + return x +// ^ reference local 1 + } + return -1 + } +