66//
77// The following failing test:
88//
9- // func Test(t *testing.T) {
10- // is := is.New(t)
11- // a, b := 1, 2
12- // is.Equal(a, b) // expect to be the same
13- // }
9+ // func Test(t *testing.T) {
10+ // is := is.New(t)
11+ // a, b := 1, 2
12+ // is.Equal(a, b) // expect to be the same
13+ // }
1414//
1515// Will output:
1616//
17- // your_test.go:123: 1 != 2 // expect to be the same
17+ // your_test.go:123: 1 != 2 // expect to be the same
1818//
1919// Usage
2020//
3333// body := readBody(r)
3434// is.True(strings.Contains(body, "Hi there"))
3535//
36- // }
36+ // }
3737package is
3838
3939import (
@@ -107,7 +107,7 @@ func (is *I) logf(format string, args ...interface{}) {
107107
108108// Fail immediately fails the test.
109109//
110- // func Test(t *testing.T) {
110+ // func Test(t *testing.T) {
111111// is := is.New(t)
112112// is.Fail() // TODO: write this test
113113// }
@@ -121,15 +121,15 @@ func (is *I) Fail() {
121121// True asserts that the expression is true. The expression
122122// code itself will be reported if the assertion fails.
123123//
124- // func Test(t *testing.T) {
124+ // func Test(t *testing.T) {
125125// is := is.New(t)
126126// val := method()
127127// is.True(val != nil) // val should never be nil
128128// }
129129//
130130// Will output:
131131//
132- // your_test.go:123: not true: val != nil
132+ // your_test.go:123: not true: val != nil
133133func (is * I ) True (expression bool ) {
134134 if ! expression {
135135 is .log ("not true: $ARGS" )
@@ -138,15 +138,15 @@ func (is *I) True(expression bool) {
138138
139139// Equal asserts that a and b are equal.
140140//
141- // func Test(t *testing.T) {
141+ // func Test(t *testing.T) {
142142// is := is.New(t)
143143// a := greet("Mat")
144144// is.Equal(a, "Hi Mat") // greeting
145- // }
145+ // }
146146//
147147// Will output:
148148//
149- // your_test.go:123: Hey Mat != Hi Mat // greeting
149+ // your_test.go:123: Hey Mat != Hi Mat // greeting
150150func (is * I ) Equal (a , b interface {}) {
151151 if ! areEqual (a , b ) {
152152 if isNil (a ) || isNil (b ) {
@@ -173,13 +173,13 @@ func (is *I) Equal(a, b interface{}) {
173173// It allows you to write subtests using a fimilar
174174// pattern:
175175//
176- // func Test(t *testing.T) {
176+ // func Test(t *testing.T) {
177177// is := is.New(t)
178- // t.Run("sub", func(t *testing.T) {
179- // is := is.New(t)
180- // // TODO: test
181- // })
182- // }
178+ // t.Run("sub", func(t *testing.T) {
179+ // is := is.New(t)
180+ // // TODO: test
181+ // })
182+ // }
183183func (is * I ) New (t * testing.T ) * I {
184184 return New (t )
185185}
@@ -188,13 +188,13 @@ func (is *I) New(t *testing.T) *I {
188188// method. It allows you to write subtests using a fimilar
189189// pattern:
190190//
191- // func Test(t *testing.T) {
191+ // func Test(t *testing.T) {
192192// is := is.New(t)
193- // t.Run("sub", func(t *testing.T) {
194- // is := is.New(t)
195- // // TODO: test
196- // })
197- // }
193+ // t.Run("sub", func(t *testing.T) {
194+ // is := is.New(t)
195+ // // TODO: test
196+ // })
197+ // }
198198func (is * I ) NewRelaxed (t * testing.T ) * I {
199199 return NewRelaxed (t )
200200}
@@ -208,7 +208,7 @@ func (is *I) valWithType(v interface{}) string {
208208
209209// NoErr asserts that err is nil.
210210//
211- // func Test(t *testing.T) {
211+ // func Test(t *testing.T) {
212212// is := is.New(t)
213213// val, err := getVal()
214214// is.NoErr(err) // getVal error
@@ -217,7 +217,7 @@ func (is *I) valWithType(v interface{}) string {
217217//
218218// Will output:
219219//
220- // your_test.go:123: err: not found // getVal error
220+ // your_test.go:123: err: not found // getVal error
221221func (is * I ) NoErr (err error ) {
222222 if err != nil {
223223 is .logf ("err: %s" , err .Error ())
@@ -246,17 +246,14 @@ func areEqual(a, b interface{}) bool {
246246 if ! isNil (a ) && isNil (b ) {
247247 return false
248248 }
249- return a == b
249+ return true
250250 }
251251 if reflect .DeepEqual (a , b ) {
252252 return true
253253 }
254254 aValue := reflect .ValueOf (a )
255255 bValue := reflect .ValueOf (b )
256- if aValue == bValue {
257- return true
258- }
259- return false
256+ return aValue == bValue
260257}
261258
262259func callerinfo () (path string , line int , ok bool ) {
@@ -318,7 +315,7 @@ func loadArguments(path string, line int) (string, bool) {
318315 text = text [braceI + 1 :]
319316 cs := bufio .NewScanner (strings .NewReader (text ))
320317 cs .Split (bufio .ScanBytes )
321- i := 0
318+ j := 0
322319 c := 1
323320 for cs .Scan () {
324321 switch cs .Text () {
@@ -330,9 +327,9 @@ func loadArguments(path string, line int) (string, bool) {
330327 if c == 0 {
331328 break
332329 }
333- i ++
330+ j ++
334331 }
335- text = text [:i ]
332+ text = text [:j ]
336333 return text , true
337334 }
338335 i ++
0 commit comments