exprcoretest

package
v0.0.0-...-fb7d6bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package exprcoretest defines utilities for testing exprcore programs.

Clients can call LoadAssertModule to load a module that defines several functions useful for testing. See assert.star for its definition.

The assert.error function, which reports errors to the current Go testing.T, requires that clients call SetTest(thread, t) before use.

Index

Constants

This section is empty.

Variables

View Source
var DataFile = func(pkgdir, filename string) string {
	return filepath.Join("..", pkgdir, filename)

	testSrcdir := os.Getenv("TEST_SRCDIR")
	testWorkspace := os.Getenv("TEST_WORKSPACE")
	if testSrcdir != "" && testWorkspace != "" {
		return filepath.Join(testSrcdir, "net_exprcore_go", pkgdir, filename)
	}

	return filepath.Join(build.Default.GOPATH, "src/github.com/lab47/exprcore", pkgdir, filename)
}

DataFile returns the effective filename of the specified test data resource. The function abstracts differences between 'go build', under which a test runs in its package directory, and Blaze, under which a test runs in the root of the tree.

Functions

func LoadAssertModule

func LoadAssertModule() (exprcore.StringDict, error)

LoadAssertModule loads the assert module. It is concurrency-safe and idempotent.

func SetReporter

func SetReporter(thread *exprcore.Thread, r Reporter)

SetReporter associates an error reporter (such as a testing.T in a Go test) with the exprcore thread so that exprcore programs may report errors to it.

Types

type Reporter

type Reporter interface {
	Error(args ...interface{})
}

A Reporter is a value to which errors may be reported. It is satisfied by *testing.T.

func GetReporter

func GetReporter(thread *exprcore.Thread) Reporter

GetReporter returns the exprcore thread's error reporter. It must be preceded by a call to SetReporter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL