Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package testing

import (
	
	
	
	
	
)

type InternalExample struct {
	Name      string
	F         func()
	Output    string
	Unordered bool
}
RunExamples is an internal function but exported because it is cross-package; it is part of the implementation of the "go test" command.
func ( func(,  string) (bool, error),  []InternalExample) ( bool) {
	_,  = runExamples(, )
	return 
}

func ( func(,  string) (bool, error),  []InternalExample) (,  bool) {
	 = true

	var  InternalExample

	for _,  = range  {
		,  := (*match, .Name)
		if  != nil {
			fmt.Fprintf(os.Stderr, "testing: invalid regexp for -test.run: %s\n", )
			os.Exit(1)
		}
		if ! {
			continue
		}
		 = true
		if !runExample() {
			 = false
		}
	}

	return , 
}

func ( string) string {
	 := strings.Split(, "\n")
	sort.Strings()
	return strings.Join(, "\n")
}
processRunResult computes a summary and status of the result of running an example test. stdout is the captured output from stdout of the test. recovered is the result of invoking recover after running the test, in case it panicked. If stdout doesn't match the expected output or if recovered is non-nil, it'll print the cause of failure to stdout. If the test is chatty/verbose, it'll print a success message to stdout. If recovered is non-nil, it'll panic with that value. If the test panicked with nil, or invoked runtime.Goexit, it'll be made to fail and panic with errNilPanicOrGoexit
func ( *InternalExample) ( string,  time.Duration,  bool,  interface{}) ( bool) {
	 = true
	 := fmtDuration()
	var  string
	 := strings.TrimSpace()
	 := strings.TrimSpace(.Output)
	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("--- FAIL: %s (%s)\n%s", .Name, , )
		 = false
	} else if *chatty {
		fmt.Printf("--- PASS: %s (%s)\n", .Name, )
	}

Propagate the previously recovered result, by panicking.
		panic()
	}
	if ! &&  == nil {
		panic(errNilPanicOrGoexit)
	}

	return