Skip to content

Commit

Permalink
Fixes the have/want names in Equal.
Browse files Browse the repository at this point in the history
In some cases have/want got swapped which made this hard to read. This
fixes that so they are consistent. It also removes a couple of left over
debugging statements and adds testing for golang 1.6 and 1.7 to travis.
  • Loading branch information
liquidgecka committed Sep 23, 2016
1 parent 2d09120 commit 9a8065a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
31 changes: 13 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,28 @@ matrix:
fast_finish: true
include:
- go: 1.1
env: SRC=""
- go: 1.2
env: SRC=""
- go: 1.3
env: SRC=""
- go: 1.4
env: SRC="golang.org/x/tools/cmd"
- go: 1.5
env: SRC="golang.org/x/tools/cmd"
- go: 1.6
- go: 1.7
env: FMT_AND_VET=1
- go: tip
env: SRC="golang.org/x/tools/cmd"

before_script:
- test -z "$SRC" || go get "$SRC/cover"
- test -z "$SRC" || go install "$SRC/cover"
- test -z "$SRC" || go get "$SRC/vet"
- test -z "$SRC" || go install "$SRC/vet"
- test -z "$SRC" || go get github.com/mattn/goveralls
- test -z "$SRC" || go install github.com/mattn/goveralls
- test -z "$SRC" || sudo -E $(which go) install -a -race std
- test "$FMT_AND_VET" != 1 || go get "golang.org/x/tools/cmd/cover"
- test "$FMT_AND_VET" != 1 || go install "golang.org/x/tools/cmd/cover"
- test "$FMT_AND_VET" != 1 || go get github.com/mattn/goveralls
- test "$FMT_AND_VET" != 1 || go install github.com/mattn/goveralls
- test "$FMT_AND_VET" != 1 || sudo -E $(which go) install -a -race std

script:
- test -z "$(gofmt -l . | tee /dev/stderr)"
- go vet .
- test "$FMT_AND_VET" != 1 || test -z "$(gofmt -l . | tee /dev/stderr)"
- test "$FMT_AND_VET" != 1 || go vet .
- go test -v
- test -z "$SRC" || go test -covermode=count -coverprofile=/tmp/coverage.out
- test -z "$SRC" || go test -v -race .
- test "$FMT_AND_VET" != 1 || go test -covermode=count -coverprofile=/tmp/coverage.out
- test "$FMT_AND_VET" != 1 || go test -v -race .

after_script:
- $HOME/gopath/bin/goveralls -coverprofile=/tmp/coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
- test "$FMT_AND_VET" != 1 || $HOME/gopath/bin/goveralls -coverprofile=/tmp/coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN
18 changes: 9 additions & 9 deletions equal.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (t *T) deepEqual(
} else if !want.IsNil() && have.IsNil() {
diffs = append(diffs, fmt.Sprintf("%s: not equal.", desc))
diffs = append(diffs, " have: nil")
diffs = append(diffs, fmt.Sprintf(" wantB: %#v", want.Interface()))
diffs = append(diffs, fmt.Sprintf(" want: %#v", want.Interface()))
return true
}
return false
Expand All @@ -208,7 +208,7 @@ func (t *T) deepEqual(
for i := 0; i < want.Len(); i++ {
newdiffs := t.deepEqual(
fmt.Sprintf("%s[%d]", desc, i),
want.Index(i), have.Index(i), ignores, visited)
have.Index(i), want.Index(i), ignores, visited)
diffs = append(diffs, newdiffs...)
}
}
Expand All @@ -233,7 +233,7 @@ func (t *T) deepEqual(
case reflect.Interface:
if !checkNil() {
newdiffs := t.deepEqual(
desc, want.Elem(), have.Elem(), ignores, visited)
desc, have.Elem(), want.Elem(), ignores, visited)
diffs = append(diffs, newdiffs...)
}

Expand All @@ -252,7 +252,7 @@ func (t *T) deepEqual(
}
newdiffs := t.deepEqual(
fmt.Sprintf("%s[%q] ", desc, k),
want.MapIndex(k), have.MapIndex(k), ignores, visited)
have.MapIndex(k), want.MapIndex(k), ignores, visited)
diffs = append(diffs, newdiffs...)
}
for _, k := range have.MapKeys() {
Expand All @@ -269,15 +269,15 @@ func (t *T) deepEqual(

case reflect.Ptr:
newdiffs := t.deepEqual(
desc, want.Elem(), have.Elem(), ignores, visited)
desc, have.Elem(), want.Elem(), ignores, visited)
diffs = append(diffs, newdiffs...)

case reflect.Slice:
if !checkNil() && !checkLen() {
for i := 0; i < want.Len(); i++ {
newdiffs := t.deepEqual(
fmt.Sprintf("%s[%d]", desc, i),
want.Index(i), have.Index(i), ignores, visited)
have.Index(i), want.Index(i), ignores, visited)
diffs = append(diffs, newdiffs...)
}
}
Expand Down Expand Up @@ -313,12 +313,12 @@ func (t *T) deepEqual(
// first object given to us is a struct.
if desc == "" {
newdiffs := t.deepEqual(
name, want.Field(i), have.Field(i), ignores, visited)
name, have.Field(i), want.Field(i), ignores, visited)
diffs = append(diffs, newdiffs...)
} else {
newdiffs := t.deepEqual(
fmt.Sprintf("%s.%s", desc, name),
want.Field(i), have.Field(i), ignores, visited)
have.Field(i), want.Field(i), ignores, visited)
diffs = append(diffs, newdiffs...)
}
}
Expand Down Expand Up @@ -347,7 +347,7 @@ func (t *T) deepEqual(
return []string{
fmt.Sprintf("%s: not equal.", desc),
fmt.Sprintf(" have: %#v", havePtr),
fmt.Sprintf(" wantY: %#v", wantPtr),
fmt.Sprintf(" want: %#v", wantPtr),
}
}

Expand Down

0 comments on commit 9a8065a

Please sign in to comment.