diff options
Diffstat (limited to 'lib/test/test.go')
| -rw-r--r-- | lib/test/test.go | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/lib/test/test.go b/lib/test/test.go index 07f9bc20..5a85f58a 100644 --- a/lib/test/test.go +++ b/lib/test/test.go @@ -8,42 +8,12 @@ package test import ( "bytes" "fmt" - "runtime" "git.sr.ht/~shulhan/pakakeh.go/lib/reflect" "git.sr.ht/~shulhan/pakakeh.go/lib/text" "git.sr.ht/~shulhan/pakakeh.go/lib/text/diff" ) -func printStackTrace(w Writer, trace []byte) { - var ( - lines int - start int - end int - x int - b byte - ok bool - ) - - for x, b = range trace { - if b == '\n' { - lines++ - if lines == 3 { - start = x + 1 - } - if lines == 5 { - end = x + 1 - break - } - } - } - - _, ok = w.(*BufferWriter) - if !ok { - w.Log("\n!!! ERR " + string(trace[start:end])) - } -} - // Assert compare two interfaces: exp and got for equality. // If both parameters are not equal, the function will call print and try to // describe the position (type and value) where value are not matched and call @@ -87,12 +57,10 @@ func printStackTrace(w Writer, trace []byte) { // LIMITATION: this method does not support recursive pointer, for example a // node that point to parent and parent that point back to node again. func Assert(w Writer, name string, exp, got interface{}) { - var ( - logp = `Assert` + w.Helper() - err error - trace []byte - ) + var logp = `Assert` + var err error err = reflect.DoEqual(exp, got) if err == nil { @@ -103,10 +71,6 @@ func Assert(w Writer, name string, exp, got interface{}) { return } - trace = make([]byte, 1024) - runtime.Stack(trace, false) - printStackTrace(w, trace) - if len(name) == 0 { w.Fatalf(`!!! %s: %s`, logp, err) } else { |
