package testing
import (
)
type InternalExample struct {
Name string
F func()
Output string
Unordered bool
}
func ( func(, string) (bool, error), []InternalExample) ( bool) {
_, = runExamples(, )
return
}
func ( func(, string) (bool, error), []InternalExample) (, bool) {
= true
:= newMatcher(, *match, "-test.run", *skip)
var InternalExample
for _, = range {
, , := .fullName(nil, .Name)
if ! {
continue
}
= true
if !runExample() {
= false
}
}
return ,
}
func ( string) string {
:= strings.Split(, "\n")
slices.Sort()
return strings.Join(, "\n")
}
func ( *InternalExample) ( string, time.Duration, bool, any) ( bool) {
= true
:= fmtDuration()
var string
:= strings.TrimSpace()
:= strings.TrimSpace(.Output)
if runtime.GOOS == "windows" {
= strings.ReplaceAll(, "\r\n", "\n")
= strings.ReplaceAll(, "\r\n", "\n")
}
if .Unordered {
if sortLines() != sortLines() && == nil {
= fmt.Sprintf("got:\n%s\nwant (unordered):\n%s\n", , .Output)
}
} else {
if != && == nil {
= fmt.Sprintf("got:\n%s\nwant:\n%s\n", , )
}
}
if != "" || ! || != nil {
fmt.Printf("%s--- FAIL: %s (%s)\n%s", chatty.prefix(), .Name, , )
= false
} else if chatty.on {
fmt.Printf("%s--- PASS: %s (%s)\n", chatty.prefix(), .Name, )
}
if chatty.on && chatty.json {
fmt.Printf("%s=== NAME %s\n", chatty.prefix(), "")
}
if != nil {
panic()
} else if ! {
panic(errNilPanicOrGoexit)
}
return
}