]> Cypherpunks repositories - gostls13.git/commitdiff
testing/quick: align tests with reflect.Kind.
authorMatt T. Proud <matt.proud@gmail.com>
Sun, 12 Apr 2015 17:50:52 +0000 (19:50 +0200)
committerRuss Cox <rsc@golang.org>
Sun, 26 Apr 2015 02:40:40 +0000 (02:40 +0000)
This commit is largely cosmetic in the sense that it is the remnants
of a change proposal I had prepared for testing/quick, until I
discovered that 3e9ed27 already implemented the feature I was looking
for: quick.Value() for reflect.Kind Array.  What you see is a merger
and manual cleanup; the cosmetic cleanups are as follows:

(1.) Keeping the TestCheckEqual and its associated input functions
in the same order as type kinds defined in reflect.Kind.  Since
3e9ed27 was committed, the test case began to diverge from the
constant's ordering.

(2.) The `Intptr` derivatives existed to exercise quick.Value with
reflect.Kind's `Ptr` constant.  All `Intptr` (unrelated to `uintptr`)
in the test have been migrated to ensure the parallelism of the
listings and to convey that `Intptr` is not special.

(3.) Correct a misspelling (transposition) of "alias", whereby it is
named as "Alais".

Change-Id: I441450db16b8bb1272c52b0abcda3794dcd0599d
Reviewed-on: https://go-review.googlesource.com/8804
Reviewed-by: Russ Cox <rsc@golang.org>
src/testing/quick/quick_test.go

index ca340fe76d6d98dfad071450e6bc5e7af5e90d5b..1b973027d5277dbb952b53b82eb457e5fb88584e 100644 (file)
@@ -10,6 +10,12 @@ import (
        "testing"
 )
 
+func fArray(a [4]byte) [4]byte { return a }
+
+type TestArrayAlias [4]byte
+
+func fArrayAlias(a TestArrayAlias) TestArrayAlias { return a }
+
 func fBool(a bool) bool { return a }
 
 type TestBoolAlias bool
@@ -76,6 +82,15 @@ type TestMapAlias map[int]int
 
 func fMapAlias(a TestMapAlias) TestMapAlias { return a }
 
+func fPtr(a *int) *int {
+       b := *a
+       return &b
+}
+
+type TestPtrAlias *int
+
+func fPtrAlias(a TestPtrAlias) TestPtrAlias { return a }
+
 func fSlice(a []byte) []byte { return a }
 
 type TestSliceAlias []byte
@@ -135,21 +150,6 @@ type TestUintptrAlias uintptr
 
 func fUintptrAlias(a TestUintptrAlias) TestUintptrAlias { return a }
 
-func fIntptr(a *int) *int {
-       b := *a
-       return &b
-}
-
-type TestIntptrAlias *int
-
-func fIntptrAlias(a TestIntptrAlias) TestIntptrAlias { return a }
-
-func fArray(a [4]byte) [4]byte { return a }
-
-type TestArrayAlias [4]byte
-
-func fArrayAlias(a TestArrayAlias) TestArrayAlias { return a }
-
 func reportError(property string, err error, t *testing.T) {
        if err != nil {
                t.Errorf("%s: %s", property, err)
@@ -157,6 +157,8 @@ func reportError(property string, err error, t *testing.T) {
 }
 
 func TestCheckEqual(t *testing.T) {
+       reportError("fArray", CheckEqual(fArray, fArray, nil), t)
+       reportError("fArrayAlias", CheckEqual(fArrayAlias, fArrayAlias, nil), t)
        reportError("fBool", CheckEqual(fBool, fBool, nil), t)
        reportError("fBoolAlias", CheckEqual(fBoolAlias, fBoolAlias, nil), t)
        reportError("fFloat32", CheckEqual(fFloat32, fFloat32, nil), t)
@@ -181,6 +183,8 @@ func TestCheckEqual(t *testing.T) {
        reportError("fInt32Alias", CheckEqual(fInt32Alias, fInt32Alias, nil), t)
        reportError("fMap", CheckEqual(fMap, fMap, nil), t)
        reportError("fMapAlias", CheckEqual(fMapAlias, fMapAlias, nil), t)
+       reportError("fPtr", CheckEqual(fPtr, fPtr, nil), t)
+       reportError("fPtrAlias", CheckEqual(fPtrAlias, fPtrAlias, nil), t)
        reportError("fSlice", CheckEqual(fSlice, fSlice, nil), t)
        reportError("fSliceAlias", CheckEqual(fSliceAlias, fSliceAlias, nil), t)
        reportError("fString", CheckEqual(fString, fString, nil), t)
@@ -199,10 +203,6 @@ func TestCheckEqual(t *testing.T) {
        reportError("fUintAlias", CheckEqual(fUintAlias, fUintAlias, nil), t)
        reportError("fUintptr", CheckEqual(fUintptr, fUintptr, nil), t)
        reportError("fUintptrAlias", CheckEqual(fUintptrAlias, fUintptrAlias, nil), t)
-       reportError("fIntptr", CheckEqual(fIntptr, fIntptr, nil), t)
-       reportError("fIntptrAlias", CheckEqual(fIntptrAlias, fIntptrAlias, nil), t)
-       reportError("fArray", CheckEqual(fArray, fArray, nil), t)
-       reportError("fArrayAlais", CheckEqual(fArrayAlias, fArrayAlias, nil), t)
 }
 
 // This tests that ArbitraryValue is working by checking that all the arbitrary