]> Cypherpunks repositories - gostls13.git/commitdiff
all: remove some unused parameters in test code
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 25 Apr 2017 09:58:12 +0000 (10:58 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 25 Apr 2017 14:38:10 +0000 (14:38 +0000)
Mostly unnecessary *testing.T arguments.

Found with github.com/mvdan/unparam.

Change-Id: Ifb955cb88f2ce8784ee4172f4f94d860fa36ae9a
Reviewed-on: https://go-review.googlesource.com/41691
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
12 files changed:
src/encoding/gob/codec_test.go
src/go/parser/error_test.go
src/go/types/typestring_test.go
src/image/image_test.go
src/net/http/cgi/host_test.go
src/net/http/cgi/plan9_test.go
src/net/http/cgi/posix_test.go
src/path/filepath/path_test.go
src/runtime/proc_test.go
src/sync/waitgroup_test.go
src/text/template/parse/lex_test.go
src/time/sleep_test.go

index c1020595902c4cd66c5c6628029140c0c8e803ef..387d58229c0ecfcaefe2f7dabb47bfb1f3fde617 100644 (file)
@@ -320,7 +320,7 @@ func TestScalarEncInstructions(t *testing.T) {
        }
 }
 
-func execDec(typ string, instr *decInstr, state *decoderState, t *testing.T, value reflect.Value) {
+func execDec(instr *decInstr, state *decoderState, t *testing.T, value reflect.Value) {
        defer testError(t)
        v := int(state.decodeUint())
        if v+state.fieldnum != 6 {
@@ -347,7 +347,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data bool
                instr := &decInstr{decBool, 6, nil, ovfl}
                state := newDecodeStateFromData(boolResult)
-               execDec("bool", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != true {
                        t.Errorf("bool a = %v not true", data)
                }
@@ -357,7 +357,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data int
                instr := &decInstr{decOpTable[reflect.Int], 6, nil, ovfl}
                state := newDecodeStateFromData(signedResult)
-               execDec("int", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("int a = %v not 17", data)
                }
@@ -368,7 +368,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data uint
                instr := &decInstr{decOpTable[reflect.Uint], 6, nil, ovfl}
                state := newDecodeStateFromData(unsignedResult)
-               execDec("uint", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("uint a = %v not 17", data)
                }
@@ -379,7 +379,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data int8
                instr := &decInstr{decInt8, 6, nil, ovfl}
                state := newDecodeStateFromData(signedResult)
-               execDec("int8", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("int8 a = %v not 17", data)
                }
@@ -390,7 +390,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data uint8
                instr := &decInstr{decUint8, 6, nil, ovfl}
                state := newDecodeStateFromData(unsignedResult)
-               execDec("uint8", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("uint8 a = %v not 17", data)
                }
@@ -401,7 +401,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data int16
                instr := &decInstr{decInt16, 6, nil, ovfl}
                state := newDecodeStateFromData(signedResult)
-               execDec("int16", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("int16 a = %v not 17", data)
                }
@@ -412,7 +412,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data uint16
                instr := &decInstr{decUint16, 6, nil, ovfl}
                state := newDecodeStateFromData(unsignedResult)
-               execDec("uint16", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("uint16 a = %v not 17", data)
                }
@@ -423,7 +423,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data int32
                instr := &decInstr{decInt32, 6, nil, ovfl}
                state := newDecodeStateFromData(signedResult)
-               execDec("int32", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("int32 a = %v not 17", data)
                }
@@ -434,7 +434,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data uint32
                instr := &decInstr{decUint32, 6, nil, ovfl}
                state := newDecodeStateFromData(unsignedResult)
-               execDec("uint32", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("uint32 a = %v not 17", data)
                }
@@ -445,7 +445,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data uintptr
                instr := &decInstr{decOpTable[reflect.Uintptr], 6, nil, ovfl}
                state := newDecodeStateFromData(unsignedResult)
-               execDec("uintptr", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("uintptr a = %v not 17", data)
                }
@@ -456,7 +456,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data int64
                instr := &decInstr{decInt64, 6, nil, ovfl}
                state := newDecodeStateFromData(signedResult)
-               execDec("int64", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("int64 a = %v not 17", data)
                }
@@ -467,7 +467,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data uint64
                instr := &decInstr{decUint64, 6, nil, ovfl}
                state := newDecodeStateFromData(unsignedResult)
-               execDec("uint64", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("uint64 a = %v not 17", data)
                }
@@ -478,7 +478,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data float32
                instr := &decInstr{decFloat32, 6, nil, ovfl}
                state := newDecodeStateFromData(floatResult)
-               execDec("float32", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("float32 a = %v not 17", data)
                }
@@ -489,7 +489,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data float64
                instr := &decInstr{decFloat64, 6, nil, ovfl}
                state := newDecodeStateFromData(floatResult)
-               execDec("float64", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17 {
                        t.Errorf("float64 a = %v not 17", data)
                }
@@ -500,7 +500,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data complex64
                instr := &decInstr{decOpTable[reflect.Complex64], 6, nil, ovfl}
                state := newDecodeStateFromData(complexResult)
-               execDec("complex", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17+19i {
                        t.Errorf("complex a = %v not 17+19i", data)
                }
@@ -511,7 +511,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data complex128
                instr := &decInstr{decOpTable[reflect.Complex128], 6, nil, ovfl}
                state := newDecodeStateFromData(complexResult)
-               execDec("complex", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != 17+19i {
                        t.Errorf("complex a = %v not 17+19i", data)
                }
@@ -522,7 +522,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data []byte
                instr := &decInstr{decUint8Slice, 6, nil, ovfl}
                state := newDecodeStateFromData(bytesResult)
-               execDec("bytes", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if string(data) != "hello" {
                        t.Errorf(`bytes a = %q not "hello"`, string(data))
                }
@@ -533,7 +533,7 @@ func TestScalarDecInstructions(t *testing.T) {
                var data string
                instr := &decInstr{decString, 6, nil, ovfl}
                state := newDecodeStateFromData(bytesResult)
-               execDec("bytes", instr, state, t, reflect.ValueOf(&data))
+               execDec(instr, state, t, reflect.ValueOf(&data))
                if data != "hello" {
                        t.Errorf(`bytes a = %q not "hello"`, data)
                }
index 1a08d5a6b1181f8e66f2bef1bb061e5b536b5a9a..ef91e1ea60ead8744cafdb94f4bf7304fad687ee 100644 (file)
@@ -66,7 +66,7 @@ var errRx = regexp.MustCompile(`^/\* *ERROR *(HERE)? *"([^"]*)" *\*/$`)
 // expectedErrors collects the regular expressions of ERROR comments found
 // in files and returns them as a map of error positions to error messages.
 //
-func expectedErrors(t *testing.T, fset *token.FileSet, filename string, src []byte) map[token.Pos]string {
+func expectedErrors(fset *token.FileSet, filename string, src []byte) map[token.Pos]string {
        errors := make(map[token.Pos]string)
 
        var s scanner.Scanner
@@ -161,7 +161,7 @@ func checkErrors(t *testing.T, filename string, input interface{}) {
 
        // we are expecting the following errors
        // (collect these after parsing a file so that it is found in the file set)
-       expected := expectedErrors(t, fset, filename, src)
+       expected := expectedErrors(fset, filename, src)
 
        // verify errors returned by the parser
        compareErrors(t, fset, expected, found)
index 6365df5fe2f1287b6515e68f0bbee36bb4eaf0c4..b794ea813d2761dccb200bd1f213dc2bbf5b9072 100644 (file)
@@ -17,7 +17,7 @@ import (
 
 const filename = "<src>"
 
-func makePkg(t *testing.T, src string) (*Package, error) {
+func makePkg(src string) (*Package, error) {
        fset := token.NewFileSet()
        file, err := parser.ParseFile(fset, filename, src, parser.DeclarationErrors)
        if err != nil {
@@ -126,7 +126,7 @@ func TestTypeString(t *testing.T) {
 
        for _, test := range tests {
                src := `package p; import "io"; type _ io.Writer; type T ` + test.src
-               pkg, err := makePkg(t, src)
+               pkg, err := makePkg(src)
                if err != nil {
                        t.Errorf("%s: %s", src, err)
                        continue
index 799c1a7a11d5f1b98a71fd009ebe33551656c624..08ba61ea0c70403b7fe5c58a22b5e116297857a2 100644 (file)
@@ -16,7 +16,7 @@ type image interface {
        SubImage(Rectangle) Image
 }
 
-func cmp(t *testing.T, cm color.Model, c0, c1 color.Color) bool {
+func cmp(cm color.Model, c0, c1 color.Color) bool {
        r0, g0, b0, a0 := cm.Convert(c0).RGBA()
        r1, g1, b1, a1 := cm.Convert(c1).RGBA()
        return r0 == r1 && g0 == g1 && b0 == b1 && a0 == a1
@@ -42,12 +42,12 @@ func TestImage(t *testing.T) {
                        t.Errorf("%T: want bounds %v, got %v", m, Rect(0, 0, 10, 10), m.Bounds())
                        continue
                }
-               if !cmp(t, m.ColorModel(), Transparent, m.At(6, 3)) {
+               if !cmp(m.ColorModel(), Transparent, m.At(6, 3)) {
                        t.Errorf("%T: at (6, 3), want a zero color, got %v", m, m.At(6, 3))
                        continue
                }
                m.Set(6, 3, Opaque)
-               if !cmp(t, m.ColorModel(), Opaque, m.At(6, 3)) {
+               if !cmp(m.ColorModel(), Opaque, m.At(6, 3)) {
                        t.Errorf("%T: at (6, 3), want a non-zero color, got %v", m, m.At(6, 3))
                        continue
                }
@@ -60,16 +60,16 @@ func TestImage(t *testing.T) {
                        t.Errorf("%T: sub-image want bounds %v, got %v", m, Rect(3, 2, 9, 8), m.Bounds())
                        continue
                }
-               if !cmp(t, m.ColorModel(), Opaque, m.At(6, 3)) {
+               if !cmp(m.ColorModel(), Opaque, m.At(6, 3)) {
                        t.Errorf("%T: sub-image at (6, 3), want a non-zero color, got %v", m, m.At(6, 3))
                        continue
                }
-               if !cmp(t, m.ColorModel(), Transparent, m.At(3, 3)) {
+               if !cmp(m.ColorModel(), Transparent, m.At(3, 3)) {
                        t.Errorf("%T: sub-image at (3, 3), want a zero color, got %v", m, m.At(3, 3))
                        continue
                }
                m.Set(3, 3, Opaque)
-               if !cmp(t, m.ColorModel(), Opaque, m.At(3, 3)) {
+               if !cmp(m.ColorModel(), Opaque, m.At(3, 3)) {
                        t.Errorf("%T: sub-image at (3, 3), want a non-zero color, got %v", m, m.At(3, 3))
                        continue
                }
index 11213349a71b1be9a672e8be48a55812290258e9..15c169dbc1c867e878eb25a8a1f5e36d63505d41 100644 (file)
@@ -409,7 +409,7 @@ func TestCopyError(t *testing.T) {
        }
 
        childRunning := func() bool {
-               return isProcessRunning(t, pid)
+               return isProcessRunning(pid)
        }
 
        if !childRunning() {
index c8235831b07139791b2c4174f9d8a6a4823bf5a0..2c29ef8025865bf32e395a53c54349d9d5ddf49e 100644 (file)
@@ -12,7 +12,7 @@ import (
        "testing"
 )
 
-func isProcessRunning(t *testing.T, pid int) bool {
+func isProcessRunning(pid int) bool {
        _, err := os.Stat("/proc/" + strconv.Itoa(pid))
        return err == nil
 }
index 5ff9e7d5eb7957901865d54dd3f45f5ec4e4da6b..9396ce036afdcf06fe1ce772fb0979fbee380908 100644 (file)
@@ -9,10 +9,9 @@ package cgi
 import (
        "os"
        "syscall"
-       "testing"
 )
 
-func isProcessRunning(t *testing.T, pid int) bool {
+func isProcessRunning(pid int) bool {
        p, err := os.FindProcess(pid)
        if err != nil {
                return false
index 0c21d213f7f7bbc6c10cd56f610f3cad03819ee8..d2a78f5bee48bba658724363e805195406e5378a 100644 (file)
@@ -388,7 +388,7 @@ func checkMarks(t *testing.T, report bool) {
 // Assumes that each node name is unique. Good enough for a test.
 // If clear is true, any incoming error is cleared before return. The errors
 // are always accumulated, though.
-func mark(path string, info os.FileInfo, err error, errors *[]error, clear bool) error {
+func mark(info os.FileInfo, err error, errors *[]error, clear bool) error {
        if err != nil {
                *errors = append(*errors, err)
                if clear {
@@ -437,7 +437,7 @@ func TestWalk(t *testing.T) {
        errors := make([]error, 0, 10)
        clear := true
        markFn := func(path string, info os.FileInfo, err error) error {
-               return mark(path, info, err, &errors, clear)
+               return mark(info, err, &errors, clear)
        }
        // Expect no errors.
        err := filepath.Walk(tree.name, markFn)
index 22e4dca771c6c0d1f109919000a2285ceaa8bf08..e7c0f3333eefb5be4e359c942a4f8ee9bcf57b05 100644 (file)
@@ -53,14 +53,14 @@ func TestStopTheWorldDeadlock(t *testing.T) {
 }
 
 func TestYieldProgress(t *testing.T) {
-       testYieldProgress(t, false)
+       testYieldProgress(false)
 }
 
 func TestYieldLockedProgress(t *testing.T) {
-       testYieldProgress(t, true)
+       testYieldProgress(true)
 }
 
-func testYieldProgress(t *testing.T, locked bool) {
+func testYieldProgress(locked bool) {
        c := make(chan bool)
        cack := make(chan bool)
        go func() {
index c7c391ba230f8884fa2ee104933d3e40daff9883..e3e30966457bf7f1f09e9c772d538821c633ed9d 100644 (file)
@@ -18,11 +18,11 @@ func testWaitGroup(t *testing.T, wg1 *WaitGroup, wg2 *WaitGroup) {
        wg2.Add(n)
        exited := make(chan bool, n)
        for i := 0; i != n; i++ {
-               go func(i int) {
+               go func() {
                        wg1.Done()
                        wg2.Wait()
                        exited <- true
-               }(i)
+               }()
        }
        wg1.Wait()
        for i := 0; i != n; i++ {
index d655d788b3b0e6cb17596610d6d0a60def8aff91..2c73bb623aebeac676b21cb8ebf9a2424b577429 100644 (file)
@@ -498,7 +498,7 @@ func TestShutdown(t *testing.T) {
        // We need to duplicate template.Parse here to hold on to the lexer.
        const text = "erroneous{{define}}{{else}}1234"
        lexer := lex("foo", text, "{{", "}}")
-       _, err := New("root").parseLexer(lexer, text)
+       _, err := New("root").parseLexer(lexer)
        if err == nil {
                t.Fatalf("expected error")
        }
@@ -511,7 +511,7 @@ func TestShutdown(t *testing.T) {
 
 // parseLexer is a local version of parse that lets us pass in the lexer instead of building it.
 // We expect an error, so the tree set and funcs list are explicitly nil.
-func (t *Tree) parseLexer(lex *lexer, text string) (tree *Tree, err error) {
+func (t *Tree) parseLexer(lex *lexer) (tree *Tree, err error) {
        defer t.recover(&err)
        t.ParseName = t.Name
        t.startParse(nil, lex, map[string]*Tree{})
index dd0a820dd6e3fe4ee344ecbaa6bf4a26c3f361a3..9b4a3ccc12398920733c3cf7a8471f7e2ce3038a 100644 (file)
@@ -227,7 +227,7 @@ func TestAfterQueuing(t *testing.T) {
        err := errors.New("!=nil")
        for i := 0; i < attempts && err != nil; i++ {
                delta := Duration(20+i*50) * Millisecond
-               if err = testAfterQueuing(t, delta); err != nil {
+               if err = testAfterQueuing(delta); err != nil {
                        t.Logf("attempt %v failed: %v", i, err)
                }
        }
@@ -247,7 +247,7 @@ func await(slot int, result chan<- afterResult, ac <-chan Time) {
        result <- afterResult{slot, <-ac}
 }
 
-func testAfterQueuing(t *testing.T, delta Duration) error {
+func testAfterQueuing(delta Duration) error {
        // make the result channel buffered because we don't want
        // to depend on channel queueing semantics that might
        // possibly change in the future.