summaryrefslogtreecommitdiffstats
path: root/src/cmd/api/testdata
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:16:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 13:16:40 +0000
commit47ab3d4a42e9ab51c465c4322d2ec233f6324e6b (patch)
treea61a0ffd83f4a3def4b36e5c8e99630c559aa723 /src/cmd/api/testdata
parentInitial commit. (diff)
downloadgolang-1.18-47ab3d4a42e9ab51c465c4322d2ec233f6324e6b.tar.xz
golang-1.18-47ab3d4a42e9ab51c465c4322d2ec233f6324e6b.zip
Adding upstream version 1.18.10.upstream/1.18.10upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/cmd/api/testdata')
-rw-r--r--src/cmd/api/testdata/src/issue21181/dep/p.go5
-rw-r--r--src/cmd/api/testdata/src/issue21181/dep/p_amd64.go1
-rw-r--r--src/cmd/api/testdata/src/issue21181/indirect/p.go5
-rw-r--r--src/cmd/api/testdata/src/issue21181/p/p.go9
-rw-r--r--src/cmd/api/testdata/src/issue21181/p/p_amd64.go7
-rw-r--r--src/cmd/api/testdata/src/issue21181/p/p_generic.go12
-rw-r--r--src/cmd/api/testdata/src/issue29837/p/README1
-rw-r--r--src/cmd/api/testdata/src/pkg/p1/golden.txt96
-rw-r--r--src/cmd/api/testdata/src/pkg/p1/p1.go212
-rw-r--r--src/cmd/api/testdata/src/pkg/p2/golden.txt5
-rw-r--r--src/cmd/api/testdata/src/pkg/p2/p2.go9
-rw-r--r--src/cmd/api/testdata/src/pkg/p3/golden.txt3
-rw-r--r--src/cmd/api/testdata/src/pkg/p3/p3.go6
-rw-r--r--src/cmd/api/testdata/src/pkg/p4/golden.txt5
-rw-r--r--src/cmd/api/testdata/src/pkg/p4/p4.go26
15 files changed, 402 insertions, 0 deletions
diff --git a/src/cmd/api/testdata/src/issue21181/dep/p.go b/src/cmd/api/testdata/src/issue21181/dep/p.go
new file mode 100644
index 0000000..2d8e0c4
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/dep/p.go
@@ -0,0 +1,5 @@
+package dep
+
+type Interface interface {
+ N([]byte)
+}
diff --git a/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go b/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
new file mode 100644
index 0000000..8a2343a
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
@@ -0,0 +1 @@
+package dep
diff --git a/src/cmd/api/testdata/src/issue21181/indirect/p.go b/src/cmd/api/testdata/src/issue21181/indirect/p.go
new file mode 100644
index 0000000..e37cf3f
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/indirect/p.go
@@ -0,0 +1,5 @@
+package indirect
+
+import "dep"
+
+func F(dep.Interface) {}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p.go b/src/cmd/api/testdata/src/issue21181/p/p.go
new file mode 100644
index 0000000..a704160
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p.go
@@ -0,0 +1,9 @@
+package p
+
+import (
+ "dep"
+)
+
+type algo struct {
+ indrt func(dep.Interface)
+}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p_amd64.go b/src/cmd/api/testdata/src/issue21181/p/p_amd64.go
new file mode 100644
index 0000000..02b4cbf
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p_amd64.go
@@ -0,0 +1,7 @@
+package p
+
+import "indirect"
+
+var in = []algo{
+ {indirect.F},
+}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p_generic.go b/src/cmd/api/testdata/src/issue21181/p/p_generic.go
new file mode 100644
index 0000000..ad6df20
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p_generic.go
@@ -0,0 +1,12 @@
+//go:build !amd64
+// +build !amd64
+
+package p
+
+import (
+ "indirect"
+)
+
+var in = []algo{
+ {indirect.F},
+}
diff --git a/src/cmd/api/testdata/src/issue29837/p/README b/src/cmd/api/testdata/src/issue29837/p/README
new file mode 100644
index 0000000..770bc0f
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue29837/p/README
@@ -0,0 +1 @@
+Empty directory for test, see https://golang.org/issues/29837. \ No newline at end of file
diff --git a/src/cmd/api/testdata/src/pkg/p1/golden.txt b/src/cmd/api/testdata/src/pkg/p1/golden.txt
new file mode 100644
index 0000000..0378a56
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p1/golden.txt
@@ -0,0 +1,96 @@
+pkg p1, const A = 1
+pkg p1, const A ideal-int
+pkg p1, const A64 = 1
+pkg p1, const A64 int64
+pkg p1, const AIsLowerA = 11
+pkg p1, const AIsLowerA ideal-int
+pkg p1, const B0 = 2
+pkg p1, const B0 ideal-int
+pkg p1, const ConstChase2 = 11
+pkg p1, const ConstChase2 ideal-int
+pkg p1, const ConversionConst = 5
+pkg p1, const ConversionConst MyInt
+pkg p1, const FloatConst = 1.5 // 3/2
+pkg p1, const FloatConst ideal-float
+pkg p1, const StrConst = "foo"
+pkg p1, const StrConst ideal-string
+pkg p1, func Bar(int8, int16, int64)
+pkg p1, func Bar1(int8, int16, int64) uint64
+pkg p1, func Bar2(int8, int16, int64) (uint8, uint64)
+pkg p1, func BarE() Error
+pkg p1, func Now() Time
+pkg p1, func PlainFunc(int, int, string) (*B, error)
+pkg p1, func TakesFunc(func(int) int)
+pkg p1, method (*B) JustOnB()
+pkg p1, method (*B) OnBothTandBPtr()
+pkg p1, method (*Embedded) OnEmbedded()
+pkg p1, method (*S2) SMethod(int8, int16, int64)
+pkg p1, method (*T) JustOnT()
+pkg p1, method (*T) OnBothTandBPtr()
+pkg p1, method (B) OnBothTandBVal()
+pkg p1, method (S) StructValueMethod()
+pkg p1, method (S) StructValueMethodNamedRecv()
+pkg p1, method (S2) StructValueMethod()
+pkg p1, method (S2) StructValueMethodNamedRecv()
+pkg p1, method (T) OnBothTandBVal()
+pkg p1, method (TPtrExported) OnEmbedded()
+pkg p1, method (TPtrUnexported) OnBothTandBPtr()
+pkg p1, method (TPtrUnexported) OnBothTandBVal()
+pkg p1, type B struct
+pkg p1, type ByteStruct struct
+pkg p1, type ByteStruct struct, B uint8
+pkg p1, type ByteStruct struct, R int32
+pkg p1, type Codec struct
+pkg p1, type Codec struct, Func func(int, int) int
+pkg p1, type EmbedSelector struct
+pkg p1, type EmbedSelector struct, embedded Time
+pkg p1, type EmbedURLPtr struct
+pkg p1, type EmbedURLPtr struct, embedded *URL
+pkg p1, type Embedded struct
+pkg p1, type Error interface { Error, Temporary }
+pkg p1, type Error interface, Error() string
+pkg p1, type Error interface, Temporary() bool
+pkg p1, type FuncType func(int, int, string) (*B, error)
+pkg p1, type I interface, Get(string) int64
+pkg p1, type I interface, GetNamed(string) int64
+pkg p1, type I interface, Name() string
+pkg p1, type I interface, PackageTwoMeth()
+pkg p1, type I interface, Set(string, int64)
+pkg p1, type I interface, unexported methods
+pkg p1, type MyInt int
+pkg p1, type Namer interface { Name }
+pkg p1, type Namer interface, Name() string
+pkg p1, type Private interface, X()
+pkg p1, type Private interface, unexported methods
+pkg p1, type Public interface { X, Y }
+pkg p1, type Public interface, X()
+pkg p1, type Public interface, Y()
+pkg p1, type S struct
+pkg p1, type S struct, Public *int
+pkg p1, type S struct, PublicTime Time
+pkg p1, type S2 struct
+pkg p1, type S2 struct, Extra bool
+pkg p1, type S2 struct, embedded S
+pkg p1, type SI struct
+pkg p1, type SI struct, I int
+pkg p1, type T struct
+pkg p1, type TPtrExported struct
+pkg p1, type TPtrExported struct, embedded *Embedded
+pkg p1, type TPtrUnexported struct
+pkg p1, type Time struct
+pkg p1, type URL struct
+pkg p1, var Byte uint8
+pkg p1, var ByteConv []uint8
+pkg p1, var ByteFunc func(uint8) int32
+pkg p1, var ChecksumError error
+pkg p1, var SIPtr *SI
+pkg p1, var SIPtr2 *SI
+pkg p1, var SIVal SI
+pkg p1, var StrConv string
+pkg p1, var V string
+pkg p1, var V1 uint64
+pkg p1, var V2 p2.Twoer
+pkg p1, var VError Error
+pkg p1, var X I
+pkg p1, var X0 int64
+pkg p1, var Y int
diff --git a/src/cmd/api/testdata/src/pkg/p1/p1.go b/src/cmd/api/testdata/src/pkg/p1/p1.go
new file mode 100644
index 0000000..81826d7
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p1/p1.go
@@ -0,0 +1,212 @@
+package p1
+
+import (
+ ptwo "p2"
+)
+
+const (
+ ConstChase2 = constChase // forward declaration to unexported ident
+ constChase = AIsLowerA // forward declaration to exported ident
+
+ A = 1
+ a = 11
+ A64 int64 = 1
+
+ AIsLowerA = a // previously declared
+)
+
+const (
+ ConversionConst = MyInt(5)
+)
+
+// Variables from function calls.
+var (
+ V = ptwo.F()
+ VError = BarE()
+ V1 = Bar1(1, 2, 3)
+ V2 = ptwo.G()
+)
+
+// Variables with conversions:
+var (
+ StrConv = string("foo")
+ ByteConv = []byte("foo")
+)
+
+var ChecksumError = ptwo.NewError("gzip checksum error")
+
+const B0 = 2
+const StrConst = "foo"
+const FloatConst = 1.5
+
+type myInt int
+
+type MyInt int
+
+type Time struct{}
+
+type S struct {
+ Public *int
+ private *int
+ PublicTime Time
+}
+
+type URL struct{}
+
+type EmbedURLPtr struct {
+ *URL
+}
+
+type S2 struct {
+ S
+ Extra bool
+}
+
+var X0 int64
+
+var (
+ Y int
+ X I
+)
+
+type Namer interface {
+ Name() string
+}
+
+type I interface {
+ Namer
+ ptwo.Twoer
+ Set(name string, balance int64)
+ Get(string) int64
+ GetNamed(string) (balance int64)
+ private()
+}
+
+type Public interface {
+ X()
+ Y()
+}
+
+type Private interface {
+ X()
+ y()
+}
+
+type Error interface {
+ error
+ Temporary() bool
+}
+
+func (myInt) privateTypeMethod() {}
+func (myInt) CapitalMethodUnexportedType() {}
+
+func (s *S2) SMethod(x int8, y int16, z int64) {}
+
+type s struct{}
+
+func (s) method()
+func (s) Method()
+
+func (S) StructValueMethod()
+func (ignored S) StructValueMethodNamedRecv()
+
+func (s *S2) unexported(x int8, y int16, z int64) {}
+
+func Bar(x int8, y int16, z int64) {}
+func Bar1(x int8, y int16, z int64) uint64 {}
+func Bar2(x int8, y int16, z int64) (uint8, uint64) {}
+func BarE() Error {}
+
+func unexported(x int8, y int16, z int64) {}
+
+func TakesFunc(f func(dontWantName int) int)
+
+type Codec struct {
+ Func func(x int, y int) (z int)
+}
+
+type SI struct {
+ I int
+}
+
+var SIVal = SI{}
+var SIPtr = &SI{}
+var SIPtr2 *SI
+
+type T struct {
+ common
+}
+
+type B struct {
+ common
+}
+
+type common struct {
+ i int
+}
+
+type TPtrUnexported struct {
+ *common
+}
+
+type TPtrExported struct {
+ *Embedded
+}
+
+type FuncType func(x, y int, s string) (b *B, err error)
+
+type Embedded struct{}
+
+func PlainFunc(x, y int, s string) (b *B, err error)
+
+func (*Embedded) OnEmbedded() {}
+
+func (*T) JustOnT() {}
+func (*B) JustOnB() {}
+func (*common) OnBothTandBPtr() {}
+func (common) OnBothTandBVal() {}
+
+type EmbedSelector struct {
+ Time
+}
+
+const (
+ foo = "foo"
+ foo2 string = "foo2"
+ truth = foo == "foo" || foo2 == "foo2"
+)
+
+func ellipsis(...string) {}
+
+func Now() Time {
+ var now Time
+ return now
+}
+
+var x = &S{
+ Public: nil,
+ private: nil,
+ PublicTime: Now(),
+}
+
+var parenExpr = (1 + 5)
+
+var funcLit = func() {}
+
+var m map[string]int
+
+var chanVar chan int
+
+var ifaceVar any = 5
+
+var assertVar = ifaceVar.(int)
+
+var indexVar = m["foo"]
+
+var Byte byte
+var ByteFunc func(byte) rune
+
+type ByteStruct struct {
+ B byte
+ R rune
+}
diff --git a/src/cmd/api/testdata/src/pkg/p2/golden.txt b/src/cmd/api/testdata/src/pkg/p2/golden.txt
new file mode 100644
index 0000000..4271620
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p2/golden.txt
@@ -0,0 +1,5 @@
+pkg p2, func F() string
+pkg p2, func G() Twoer
+pkg p2, func NewError(string) error
+pkg p2, type Twoer interface { PackageTwoMeth }
+pkg p2, type Twoer interface, PackageTwoMeth()
diff --git a/src/cmd/api/testdata/src/pkg/p2/p2.go b/src/cmd/api/testdata/src/pkg/p2/p2.go
new file mode 100644
index 0000000..6b107b5
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p2/p2.go
@@ -0,0 +1,9 @@
+package p2
+
+type Twoer interface {
+ PackageTwoMeth()
+}
+
+func F() string {}
+func G() Twoer {}
+func NewError(s string) error {}
diff --git a/src/cmd/api/testdata/src/pkg/p3/golden.txt b/src/cmd/api/testdata/src/pkg/p3/golden.txt
new file mode 100644
index 0000000..a7dcccd
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p3/golden.txt
@@ -0,0 +1,3 @@
+pkg p3, func BadHop(int, int, int) (bool, bool, *ThirdBase, *ThirdBase, error)
+pkg p3, method (*ThirdBase) GoodPlayer() (int, int, int)
+pkg p3, type ThirdBase struct
diff --git a/src/cmd/api/testdata/src/pkg/p3/p3.go b/src/cmd/api/testdata/src/pkg/p3/p3.go
new file mode 100644
index 0000000..1b2b1a4
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p3/p3.go
@@ -0,0 +1,6 @@
+package p3
+
+type ThirdBase struct{}
+
+func (tb *ThirdBase) GoodPlayer() (i, j, k int)
+func BadHop(i, j, k int) (l, m bool, n, o *ThirdBase, err error)
diff --git a/src/cmd/api/testdata/src/pkg/p4/golden.txt b/src/cmd/api/testdata/src/pkg/p4/golden.txt
new file mode 100644
index 0000000..7997ab4
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p4/golden.txt
@@ -0,0 +1,5 @@
+pkg p4, func NewPair[$0 interface{ M }, $1 interface{ ~int }]($0, $1) Pair
+pkg p4, method (Pair[$0, $1]) Second() $1
+pkg p4, method (Pair[$0, $1]) First() $0
+pkg p4, type Pair[$0 interface{ M }, $1 interface{ ~int }] struct
+pkg p4, func Clone[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0
diff --git a/src/cmd/api/testdata/src/pkg/p4/p4.go b/src/cmd/api/testdata/src/pkg/p4/p4.go
new file mode 100644
index 0000000..1f90e77
--- /dev/null
+++ b/src/cmd/api/testdata/src/pkg/p4/p4.go
@@ -0,0 +1,26 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p4
+
+type Pair[T1 interface{ M() }, T2 ~int] struct {
+ f1 T1
+ f2 T2
+}
+
+func NewPair[T1 interface{ M() }, T2 ~int](v1 T1, v2 T2) Pair[T1, T2] {
+ return Pair[T1, T2]{f1: v1, f2: v2}
+}
+
+func (p Pair[X1, _]) First() X1 {
+ return p.f1
+}
+
+func (p Pair[_, X2]) Second() X2 {
+ return p.f2
+}
+
+func Clone[S ~[]T, T any](s S) S {
+ return append(S(nil), s...)
+}