testutil_test.go 479 B

1234567891011121314151617181920212223242526272829
  1. package parser
  2. import (
  3. "fmt"
  4. "path/filepath"
  5. "runtime"
  6. "testing"
  7. )
  8. // Quick and dirty replacement for terst
  9. func tt(t *testing.T, f func()) {
  10. defer func() {
  11. if x := recover(); x != nil {
  12. _, file, line, _ := runtime.Caller(4)
  13. t.Errorf("Error at %s:%d: %v", filepath.Base(file), line, x)
  14. }
  15. }()
  16. f()
  17. }
  18. func is(a, b interface{}) {
  19. as := fmt.Sprintf("%v", a)
  20. bs := fmt.Sprintf("%v", b)
  21. if as != bs {
  22. panic(fmt.Errorf("%+v(%T) != %+v(%T)", a, a, b, b))
  23. }
  24. }