Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TestData = []TestInfo{}/* 422 elements not displayed */
TestData contains the common set of tests that is used by various components of il.
Functions ¶
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 ¶
NewFakeBag creates a FakeBag and converts map[string]string to StringMap
func (*FakeBag) ReferencedList ¶
ReferencedList returns the sorted list of attributes that were referenced. Attribute references through string maps are encoded as mapname[keyname].
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 ¶
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 ¶
CheckReferenced will check to see if the set of referenced attributes is expected. If t.Referenced is nil then returns true.