@@ -167,30 +167,30 @@ func TestTrimGOPATH(t *testing.T) {
167
167
}
168
168
}
169
169
170
- func TestStacktrace (t * testing.T ) {
170
+ func TestStackTrace (t * testing.T ) {
171
171
tests := []struct {
172
172
err error
173
173
want []string
174
174
}{{
175
175
New ("ooh" ), []string {
176
- "github.com/pkg/errors.TestStacktrace \n " +
176
+ "github.com/pkg/errors.TestStackTrace \n " +
177
177
"\t .+/github.com/pkg/errors/stack_test.go:175" ,
178
178
},
179
179
}, {
180
180
Wrap (New ("ooh" ), "ahh" ), []string {
181
- "github.com/pkg/errors.TestStacktrace \n " +
181
+ "github.com/pkg/errors.TestStackTrace \n " +
182
182
"\t .+/github.com/pkg/errors/stack_test.go:180" , // this is the stack of Wrap, not New
183
183
},
184
184
}, {
185
185
Cause (Wrap (New ("ooh" ), "ahh" )), []string {
186
- "github.com/pkg/errors.TestStacktrace \n " +
186
+ "github.com/pkg/errors.TestStackTrace \n " +
187
187
"\t .+/github.com/pkg/errors/stack_test.go:185" , // this is the stack of New
188
188
},
189
189
}, {
190
190
func () error { return New ("ooh" ) }(), []string {
191
- `github.com/pkg/errors.(func·005|TestStacktrace .func1)` +
191
+ `github.com/pkg/errors.(func·005|TestStackTrace .func1)` +
192
192
"\n \t .+/github.com/pkg/errors/stack_test.go:190" , // this is the stack of New
193
- "github.com/pkg/errors.TestStacktrace \n " +
193
+ "github.com/pkg/errors.TestStackTrace \n " +
194
194
"\t .+/github.com/pkg/errors/stack_test.go:190" , // this is the stack of New's caller
195
195
},
196
196
}, {
@@ -199,40 +199,40 @@ func TestStacktrace(t *testing.T) {
199
199
return Errorf ("hello %s" , fmt .Sprintf ("world" ))
200
200
}()
201
201
}()), []string {
202
- `github.com/pkg/errors.(func·006|TestStacktrace .func2.1)` +
202
+ `github.com/pkg/errors.(func·006|TestStackTrace .func2.1)` +
203
203
"\n \t .+/github.com/pkg/errors/stack_test.go:199" , // this is the stack of Errorf
204
- `github.com/pkg/errors.(func·007|TestStacktrace .func2)` +
204
+ `github.com/pkg/errors.(func·007|TestStackTrace .func2)` +
205
205
"\n \t .+/github.com/pkg/errors/stack_test.go:200" , // this is the stack of Errorf's caller
206
- "github.com/pkg/errors.TestStacktrace \n " +
206
+ "github.com/pkg/errors.TestStackTrace \n " +
207
207
"\t .+/github.com/pkg/errors/stack_test.go:201" , // this is the stack of Errorf's caller's caller
208
208
},
209
209
}}
210
210
for _ , tt := range tests {
211
211
x , ok := tt .err .(interface {
212
- Stacktrace () Stacktrace
212
+ StackTrace () StackTrace
213
213
})
214
214
if ! ok {
215
- t .Errorf ("expected %#v to implement Stacktrace () Stacktrace " , tt .err )
215
+ t .Errorf ("expected %#v to implement StackTrace () StackTrace " , tt .err )
216
216
continue
217
217
}
218
- st := x .Stacktrace ()
218
+ st := x .StackTrace ()
219
219
for j , want := range tt .want {
220
220
testFormatRegexp (t , st [j ], "%+v" , want )
221
221
}
222
222
}
223
223
}
224
224
225
- func stacktrace () Stacktrace {
225
+ func stacktrace () StackTrace {
226
226
const depth = 8
227
227
var pcs [depth ]uintptr
228
228
n := runtime .Callers (1 , pcs [:])
229
229
var st stack = pcs [0 :n ]
230
- return st .Stacktrace ()
230
+ return st .StackTrace ()
231
231
}
232
232
233
- func TestStacktraceFormat (t * testing.T ) {
233
+ func TestStackTraceFormat (t * testing.T ) {
234
234
tests := []struct {
235
- Stacktrace
235
+ StackTrace
236
236
format string
237
237
want string
238
238
}{{
@@ -252,19 +252,19 @@ func TestStacktraceFormat(t *testing.T) {
252
252
"%#v" ,
253
253
`\[\]errors.Frame\(nil\)` ,
254
254
}, {
255
- make (Stacktrace , 0 ),
255
+ make (StackTrace , 0 ),
256
256
"%s" ,
257
257
`\[\]` ,
258
258
}, {
259
- make (Stacktrace , 0 ),
259
+ make (StackTrace , 0 ),
260
260
"%v" ,
261
261
`\[\]` ,
262
262
}, {
263
- make (Stacktrace , 0 ),
263
+ make (StackTrace , 0 ),
264
264
"%+v" ,
265
265
"" ,
266
266
}, {
267
- make (Stacktrace , 0 ),
267
+ make (StackTrace , 0 ),
268
268
"%#v" ,
269
269
`\[\]errors.Frame{}` ,
270
270
}, {
@@ -281,7 +281,7 @@ func TestStacktraceFormat(t *testing.T) {
281
281
"\n " +
282
282
"github.com/pkg/errors.stacktrace\n " +
283
283
"\t .+/github.com/pkg/errors/stack_test.go:228\n " +
284
- "github.com/pkg/errors.TestStacktraceFormat \n " +
284
+ "github.com/pkg/errors.TestStackTraceFormat \n " +
285
285
"\t .+/github.com/pkg/errors/stack_test.go:279" ,
286
286
}, {
287
287
stacktrace ()[:2 ],
@@ -290,6 +290,6 @@ func TestStacktraceFormat(t *testing.T) {
290
290
}}
291
291
292
292
for _ , tt := range tests {
293
- testFormatRegexp (t , tt .Stacktrace , tt .format , tt .want )
293
+ testFormatRegexp (t , tt .StackTrace , tt .format , tt .want )
294
294
}
295
295
}
0 commit comments