ilt

package
v0.0.0-...-48a44ca Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestData = []TestInfo{}/* 322 elements not displayed */

TestData contains the common set of tests that is used by various components of il.

Functions

func AreEqual

func AreEqual(e interface{}, a interface{}) bool

AreEqual checks for equality of given values. It handles comparison of []byte as a special case.

func NewStringMap

func NewStringMap(name string, entries map[string]string, parent *FakeBag) il.StringMap

NewStringMap creates an il.StringMap given map[string]string

Types

type FakeBag

type FakeBag struct {
	Attrs map[string]interface{}
	// contains filtered or unexported fields
}

FakeBag is a fake implementation of the Bag for testing purposes.

func NewFakeBag

func NewFakeBag(attrs map[string]interface{}) *FakeBag

NewFakeBag creates a FakeBag and converts map[string]string to StringMap

func (*FakeBag) Contains

func (b *FakeBag) Contains(key string) bool

Contains returns true if the key is present in the bag.

func (*FakeBag) Done

func (b *FakeBag) Done()

Done indicates the bag can be reclaimed.

func (*FakeBag) Get

func (b *FakeBag) Get(name string) (interface{}, bool)

Get returns an attribute value.

func (*FakeBag) Names

func (b *FakeBag) Names() []string

Names return the names of all the attributes known to this bag.

func (*FakeBag) ReferencedList

func (b *FakeBag) ReferencedList() []string

ReferencedList returns the sorted list of attributes that were referenced. Attribute references through string maps are encoded as mapname[keyname].

func (*FakeBag) String

func (b *FakeBag) String() string

String is needed to implement the Bag interface.

type TestInfo

type TestInfo struct {

	// E contains the expression that is being tested.
	E string

	// IL contains the textual IL representation of code.
	IL string

	// I contains the attribute bag used for testing.
	I map[string]interface{}

	// R contains the expected result of a successful evaluation.
	R interface{}

	// Referenced contains a list of attributes that should be referenced. If nil, attribute
	// tracking checks will be skipped.
	Referenced []string

	// Err contains the expected error message of a failed evaluation.
	Err string

	// AstErr contains the expected error message of a failed evaluation, during AST evaluation.
	AstErr string

	// CompileErr contains the expected error message for a failed compilation.
	CompileErr string

	// Fns field holds any additional function metadata that needs to be involved in the test.
	Fns []ast.FunctionMetadata

	// Externs holds any additional externs that should be used during evaluation.
	Externs map[string]interface{}

	// Type is the expected type of the expression upon successful compilation.
	Type descriptor.ValueType

	// SkipAst indicates that AST based evaluator should not be used for this test.
	SkipAst bool

	// Use this test as a benchmark as well.
	Bench bool
	// contains filtered or unexported fields
}

TestInfo is a structure that contains detailed test information. Depending on the test type, various fields of the TestInfo struct will be used for testing purposes. For example, compiler can use E and IL to test expression => IL conversion, interpreter can use IL and I, R&Err for evaluation tests and the evaluator can use expression and I, R&Err to test evaluation.

func (*TestInfo) CheckEvaluationResult

func (t *TestInfo) CheckEvaluationResult(r interface{}, err error) error

CheckEvaluationResult compares the given evaluation result and error against the one that is declared in test. Returns an error if there is a mismatch.

func (*TestInfo) CheckReferenced

func (t *TestInfo) CheckReferenced(bag *FakeBag) bool

CheckReferenced will check to see if the set of referenced attributes is expected. If t.Referenced is nil then returns true.

func (*TestInfo) Conf

Conf returns the global config to use for the test.

func (*TestInfo) TestName

func (t *TestInfo) TestName() string

TestName is the name to use for the test.

Jump to

Keyboard shortcuts

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