History

Better T log member names

Gregory Petrosyan committed 6 years ago

Commit 4e9a2f21 parent 80b53ec2 files · +22 −22Browse files

Unified · Split

2 files
  1. engine.go +21 −21
  2. generator.go +1 −1
engine.go+21−21
@@ -195,7 +195,7 @@ func findBug(tb tb, seed uint64, prop func(*T)) (uint64, int, int, *testError) { · 194 unmodified lines
195}195}
196 196
197func checkOnce(t *T, prop func(*T)) (err *testError) {197func checkOnce(t *T, prop func(*T)) (err *testError) {
198 if t.log && t.tb != nil {198 if t.tbLog && t.tb != nil {
199 t.tb.Helper()199 t.tb.Helper()
200 }200 }
201 defer func() { err = panicToError(recover(), 3) }()201 defer func() { err = panicToError(recover(), 3) }()
@@ -301,8 +301,8 @@ type tb interface { · 99 unmodified lines
301 301
302type T struct {302type T struct {
303 tb // unnamed to force re-export of (*T).Helper()303 tb // unnamed to force re-export of (*T).Helper()
304 log bool304 tbLog bool
305 rapidLog *log.Logger305 rawLog *log.Logger
306 s bitStream306 s bitStream
307 draws int307 draws int
308 refDraws []value308 refDraws []value
@@ -310,10 +310,10 @@ type T struct { · 1 unmodified line
310 failed stopTest310 failed stopTest
311}311}
312 312
313func newT(tb tb, s bitStream, log_ bool, refDraws ...value) *T {313func newT(tb tb, s bitStream, tbLog bool, refDraws ...value) *T {
314 t := &T{314 t := &T{
315 tb: tb,315 tb: tb,
316 log: log_,316 tbLog: tbLog,
317 s: s,317 s: s,
318 refDraws: refDraws,318 refDraws: refDraws,
319 }319 }
@@ -324,7 +324,7 @@ func newT(tb tb, s bitStream, log_ bool, refDraws ...value) *T { · 4 unmodified lines
324 testName = tb.Name()324 testName = tb.Name()
325 }325 }
326 326
327 t.rapidLog = log.New(os.Stdout, fmt.Sprintf("[%v] ", testName), 0)327 t.rawLog = log.New(os.Stdout, fmt.Sprintf("[%v] ", testName), 0)
328 }328 }
329 329
330 return t330 return t
@@ -340,12 +340,12 @@ func (t *T) draw(g *Generator, label string) value { · 9 unmodified lines
340 }340 }
341 }341 }
342 342
343 if t.log || t.rapidLog != nil {343 if t.tbLog || t.rawLog != nil {
344 if label == "" {344 if label == "" {
345 label = fmt.Sprintf("#%v", t.draws)345 label = fmt.Sprintf("#%v", t.draws)
346 }346 }
347 347
348 if t.log && t.tb != nil {348 if t.tbLog && t.tb != nil {
349 t.tb.Helper()349 t.tb.Helper()
350 }350 }
351 t.Logf("[rapid] draw %v: %#v", label, v)351 t.Logf("[rapid] draw %v: %#v", label, v)
@@ -357,22 +357,22 @@ func (t *T) draw(g *Generator, label string) value { · 5 unmodified lines
357}357}
358 358
359func (t *T) shouldLog() bool {359func (t *T) shouldLog() bool {
360 return t.rapidLog != nil || (t.log && t.tb != nil)360 return t.rawLog != nil || (t.tbLog && t.tb != nil)
361}361}
362 362
363func (t *T) Logf(format string, args ...interface{}) {363func (t *T) Logf(format string, args ...interface{}) {
364 if t.rapidLog != nil {364 if t.rawLog != nil {
365 t.rapidLog.Printf(format, args...)365 t.rawLog.Printf(format, args...)
366 } else if t.log && t.tb != nil {366 } else if t.tbLog && t.tb != nil {
367 t.tb.Helper()367 t.tb.Helper()
368 t.tb.Logf(format, args...)368 t.tb.Logf(format, args...)
369 }369 }
370}370}
371 371
372func (t *T) Log(args ...interface{}) {372func (t *T) Log(args ...interface{}) {
373 if t.rapidLog != nil {373 if t.rawLog != nil {
374 t.rapidLog.Print(args...)374 t.rawLog.Print(args...)
375 } else if t.log && t.tb != nil {375 } else if t.tbLog && t.tb != nil {
376 t.tb.Helper()376 t.tb.Helper()
377 t.tb.Log(args...)377 t.tb.Log(args...)
378 }378 }
@@ -380,7 +380,7 @@ func (t *T) Log(args ...interface{}) { · 1 unmodified line
380 380
381// Skipf is equivalent to Logf followed by SkipNow.381// Skipf is equivalent to Logf followed by SkipNow.
382func (t *T) Skipf(format string, args ...interface{}) {382func (t *T) Skipf(format string, args ...interface{}) {
383 if t.log && t.tb != nil {383 if t.tbLog && t.tb != nil {
384 t.tb.Helper()384 t.tb.Helper()
385 }385 }
386 t.Logf(format, args...)386 t.Logf(format, args...)
@@ -389,7 +389,7 @@ func (t *T) Skipf(format string, args ...interface{}) { · 2 unmodified lines
389 389
390// Skip is equivalent to Log followed by SkipNow.390// Skip is equivalent to Log followed by SkipNow.
391func (t *T) Skip(args ...interface{}) {391func (t *T) Skip(args ...interface{}) {
392 if t.log && t.tb != nil {392 if t.tbLog && t.tb != nil {
393 t.tb.Helper()393 t.tb.Helper()
394 }394 }
395 t.Log(args...)395 t.Log(args...)
@@ -409,7 +409,7 @@ func (t *T) SkipNow() { · 13 unmodified lines
409 409
410// Errorf is equivalent to Logf followed by Fail.410// Errorf is equivalent to Logf followed by Fail.
411func (t *T) Errorf(format string, args ...interface{}) {411func (t *T) Errorf(format string, args ...interface{}) {
412 if t.log && t.tb != nil {412 if t.tbLog && t.tb != nil {
413 t.tb.Helper()413 t.tb.Helper()
414 }414 }
415 t.Logf(format, args...)415 t.Logf(format, args...)
@@ -418,7 +418,7 @@ func (t *T) Errorf(format string, args ...interface{}) { · 2 unmodified lines
418 418
419// Error is equivalent to Log followed by Fail.419// Error is equivalent to Log followed by Fail.
420func (t *T) Error(args ...interface{}) {420func (t *T) Error(args ...interface{}) {
421 if t.log && t.tb != nil {421 if t.tbLog && t.tb != nil {
422 t.tb.Helper()422 t.tb.Helper()
423 }423 }
424 t.Log(args...)424 t.Log(args...)
@@ -427,7 +427,7 @@ func (t *T) Error(args ...interface{}) { · 2 unmodified lines
427 427
428// Fatalf is equivalent to Logf followed by FailNow.428// Fatalf is equivalent to Logf followed by FailNow.
429func (t *T) Fatalf(format string, args ...interface{}) {429func (t *T) Fatalf(format string, args ...interface{}) {
430 if t.log && t.tb != nil {430 if t.tbLog && t.tb != nil {
431 t.tb.Helper()431 t.tb.Helper()
432 }432 }
433 t.Logf(format, args...)433 t.Logf(format, args...)
@@ -436,7 +436,7 @@ func (t *T) Fatalf(format string, args ...interface{}) { · 2 unmodified lines
436 436
437// Fatal is equivalent to Log followed by FailNow.437// Fatal is equivalent to Log followed by FailNow.
438func (t *T) Fatal(args ...interface{}) {438func (t *T) Fatal(args ...interface{}) {
439 if t.log && t.tb != nil {439 if t.tbLog && t.tb != nil {
440 t.tb.Helper()440 t.tb.Helper()
441 }441 }
442 t.Log(args...)442 t.Log(args...)
generator.go+1−1
@@ -42,7 +42,7 @@ func (g *Generator) type_() reflect.Type { · 41 unmodified lines
42}42}
43 43
44func (g *Generator) Draw(t *T, label string) interface{} {44func (g *Generator) Draw(t *T, label string) interface{} {
45 if t.log && t.tb != nil {45 if t.tbLog && t.tb != nil {
46 t.tb.Helper()46 t.tb.Helper()
47 }47 }
48 return t.draw(g, label)48 return t.draw(g, label)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t