Documentation
¶
Index ¶
- Constants
- Variables
- func CmdExit(v eval.ExternalCmdExit) error
- func ErrorWithMessage(msg string) error
- func ErrorWithType(v error) error
- func OneOfErrors(errs ...error) error
- func Test(t *testing.T, tests ...TestCase)
- func TestWithSetup(t *testing.T, setup func(*eval.Evaler), tests ...TestCase)
- type Approximately
- type MatchingRegexp
- type Result
- type TestCase
- func (t TestCase) DoesNotCompile() TestCase
- func (t TestCase) DoesNothing() TestCase
- func (t TestCase) Prints(s string) TestCase
- func (t TestCase) PrintsStderrWith(s string) TestCase
- func (t TestCase) Puts(vs ...interface{}) TestCase
- func (t TestCase) Then(lines ...string) TestCase
- func (t TestCase) Throws(reason error, stacks ...string) TestCase
Constants ¶
const ApproximatelyThreshold = 1e-15
ApproximatelyThreshold defines the threshold for matching float64 values when using Approximately.
Variables ¶
var AnyError = anyError{}
AnyError is an error that can be passed to TestCase.Throws to match any non-nil error.
Functions ¶
func CmdExit ¶
func CmdExit(v eval.ExternalCmdExit) error
CmdExit returns an error that can be passed to TestCase.Throws to match an eval.ExternalCmdExit ignoring the Pid field.
func ErrorWithMessage ¶
ErrorWithMessage returns an error that can be passed to TestCase.Throws to match any error with the given message.
func ErrorWithType ¶
ErrorWithType returns an error that can be passed to the TestCase.Throws to match any error with the same type as the argument.
func OneOfErrors ¶
Types ¶
type Approximately ¶
type Approximately struct{ F float64 }
Approximately can be passed to TestCase.Puts to match a float64 within the threshold defined by ApproximatelyThreshold.
type MatchingRegexp ¶
type MatchingRegexp struct{ Pattern string }
MatchingRegexp can be passed to TestCase.Puts to match a any string that matches a regexp pattern. If the pattern is not a valid regexp, the test will panic.
type TestCase ¶
type TestCase struct {
// contains filtered or unexported fields
}
TestCase is a test case for Test.
func That ¶
That returns a new Test with the specified source code. Multiple arguments are joined with newlines. To specify multiple pieces of code that are executed separately, use the Then method to append code pieces.
func (TestCase) DoesNotCompile ¶
DoesNotCompile returns an altered TestCase that requires the source code to fail compilation.
func (TestCase) DoesNothing ¶
DoesNothing returns t unchanged. It is used to mark that a piece of code should simply does nothing. In particular, it shouldn't have any output and does not error.
func (TestCase) Prints ¶
Prints returns an altered TestCase that requires the source code to produce the specified output in the byte pipe when evaluated.
func (TestCase) PrintsStderrWith ¶
PrintsStderrWith returns an altered TestCase that requires the stderr output to contain the given text.
func (TestCase) Puts ¶
Puts returns an altered TestCase that requires the source code to produce the specified values in the value channel when evaluated.
func (TestCase) Then ¶
Then returns a new Test that executes the given code in addition. Multiple arguments are joined with newlines.
func (TestCase) Throws ¶
Throws returns an altered TestCase that requires the source code to throw an exception with the given reason. The reason supports special matcher values constructed by functions like ErrorWithMessage.
If at least one stacktrace string is given, the exception must also have a stacktrace matching the given source fragments, frame by frame (innermost frame first). If no stacktrace string is given, the stack trace of the exception is not checked.