Skip to content

Commit

Permalink
small tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Dec 1, 2014
1 parent 8206762 commit 863c00a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
29 changes: 16 additions & 13 deletions is.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ type I interface {
PanicWith(m string, fn func())
}

// New creates a new I capable of making
// assertions.
func New(t T) I {
return &i{t: t}
}

// Relaxed creates a new I capable of making
// assertions, but will not fail immediately
// allowing all assertions to run.
func Relaxed(t T) I {
return &i{t: t, relaxed: true}
}

// T represents the an interface for reporting
// failures.
// testing.T satisfied this interface.
Expand Down Expand Up @@ -176,19 +189,6 @@ func (i *i) PanicWith(m string, fn func()) {
}
}

// New creates a new I capable of making
// assertions.
func New(t T) I {
return &i{t: t}
}

// Relaxed creates a new I capable of making
// assertions, but will not fail immediately
// allowing all assertions to run.
func Relaxed(t T) I {
return &i{t: t, relaxed: true}
}

// isNil gets whether the object is nil or not.
func isNil(object interface{}) bool {
if object == nil {
Expand All @@ -205,6 +205,9 @@ func isNil(object interface{}) bool {
// areEqual gets whether a equals b or not.
func areEqual(a, b interface{}) bool {
if isNil(a) || isNil(b) {
if isNil(a) && isNil(b) {
return true
}
return a == b
}
if reflect.DeepEqual(a, b) {
Expand Down
8 changes: 8 additions & 0 deletions is_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ func TestIs(t *testing.T) {
Fails: []string{"expected panic"},
},
// is.Equal
{
N: "Equal(msi,msi) nil maps",
F: func(is I) {
var m1 map[string]interface{}
var m2 map[string]interface{}
is.Equal(m1, m2)
},
},
{
N: "Equal(1,1)",
F: func(is I) {
Expand Down

0 comments on commit 863c00a

Please sign in to comment.