mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
remove uses of ... from tree, add one test
R=r CC=golang-dev https://golang.org/cl/1662041
This commit is contained in:
parent
44a17e9df7
commit
6672b40c09
9 changed files with 54 additions and 47 deletions
|
|
@ -6,6 +6,7 @@ package reflect_test
|
|||
|
||||
import (
|
||||
"container/vector"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
. "reflect"
|
||||
|
|
@ -139,10 +140,10 @@ var typeTests = []pair{
|
|||
},
|
||||
pair{struct {
|
||||
x struct {
|
||||
f func(args ...)
|
||||
f func(args ...int)
|
||||
}
|
||||
}{},
|
||||
"struct { f func(...) }",
|
||||
"struct { f func(...int) }",
|
||||
},
|
||||
pair{struct {
|
||||
x (interface {
|
||||
|
|
@ -1221,3 +1222,26 @@ func TestImportPath(t *testing.T) {
|
|||
t.Errorf("Typeof(vector.Vector{}).PkgPath() = %q, want \"container/vector\"", path)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDotDotDot(t *testing.T) {
|
||||
// Test example from FuncType.DotDotDot documentation.
|
||||
var f func(x int, y ...float)
|
||||
typ := Typeof(f).(*FuncType)
|
||||
if typ.NumIn() == 2 && typ.In(0) == Typeof(int(0)) {
|
||||
sl, ok := typ.In(1).(*SliceType)
|
||||
if ok {
|
||||
if sl.Elem() == Typeof(float(0)) {
|
||||
// ok
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Failed
|
||||
t.Errorf("want NumIn() = 2, In(0) = int, In(1) = []float")
|
||||
s := fmt.Sprintf("have NumIn() = %d", typ.NumIn())
|
||||
for i := 0; i < typ.NumIn(); i++ {
|
||||
s += fmt.Sprintf(", In(%d) = %s", i, typ.In(i))
|
||||
}
|
||||
t.Error(s)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue