elvish: github.com/elves/elvish/pkg/eval/evaltest Index | Files

package evaltest

import "github.com/elves/elvish/pkg/eval/evaltest"

Index

Package Files

evaltest.go matchers.go

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.

func CmdExit Uses

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 Uses

func ErrorWithMessage(msg string) error

ErrorWithMessage returns an error that can be passed to TestCase.Throws to match any error with the given message.

func ErrorWithType Uses

func ErrorWithType(v error) error

ErrorWithType returns an error that can be passed to the TestCase.Throws to match any error with the same type as the argument.

func Test Uses

func Test(t *testing.T, tests ...TestCase)

Test runs test cases. For each test case, a new Evaler is created with NewEvaler.

func TestWithSetup Uses

func TestWithSetup(t *testing.T, setup func(*eval.Evaler), tests ...TestCase)

TestWithSetup runs test cases. For each test case, a new Evaler is created with NewEvaler and passed to the setup function.

type Approximately Uses

type Approximately struct{ F float64 }

Approximately can be passed to TestCase.Puts to match a float64 within the threshold defined by ApproximatelyThreshold.

type Result Uses

type Result struct {
    ValueOut  []interface{}
    BytesOut  []byte
    StderrOut []byte

    CompilationError error
    Exception        error
}

func EvalAndCollect Uses

func EvalAndCollect(t *testing.T, ev *eval.Evaler, texts []string) Result

type TestCase Uses

type TestCase struct {
    // contains filtered or unexported fields
}

TestCase is a test case for Test.

func That Uses

func That(lines ...string) TestCase

That returns a new Test with the specified source code. Multiple arguments are joined with newlines.

func (TestCase) DoesNotCompile Uses

func (t TestCase) DoesNotCompile() TestCase

DoesNotCompile returns an altered TestCase that requires the source code to fail compilation.

func (TestCase) DoesNothing Uses

func (t TestCase) DoesNothing() TestCase

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 Uses

func (t TestCase) Prints(s string) TestCase

Prints returns an altered TestCase that requires the source code to produce the specified output in the byte pipe when evaluated.

func (TestCase) PrintsStderrWith Uses

func (t TestCase) PrintsStderrWith(s string) TestCase

PrintsStderr returns an altered TestCase that requires the stderr output to contain the given text.

func (TestCase) Puts Uses

func (t TestCase) Puts(vs ...interface{}) TestCase

Puts returns an altered TestCase that requires the source code to produce the specified values in the value channel when evaluated.

func (TestCase) Throws Uses

func (t TestCase) Throws(reason error, stacks ...string) TestCase

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.

Package evaltest imports 11 packages (graph). Updated 2020-09-28. Refresh now. Tools for package owners.