exprcel.dev/expr/tests/simple Index | Files

package simple

import "cel.dev/expr/tests/simple"

Package simple runs end-to-end CEL conformance tests against ConformanceService servers. The "simple" tests run the Parse / Check (optional) / Eval pipeline and compare the result against an expected value, error, or unknown from the Eval phase. To validate the intermediate results from the Parse or Check phases, use a different test driver.

Each phase can be sent to a different ConformanceService server. Thus a partial implementation can be tested by using other implementations for the missing phases. This also validates the interoperativity.

Example test data:

name: "basic"
description: "Basic tests that all implementations should pass."
section {
  name: "self_eval"
  description: "Simple self-evaluating forms."
  test {
    name: "self_eval_zero"
    expr: "0"
    value: { int64_value: 0 }
  }
}
section {
  name: "arithmetic"
  description: "Numeric arithmetic checks."
  test {
    name: "one plus one"
    description: "Uses implicit match against 'true'."
    expr: "1 + 1 == 2"
  }
}

Index

Functions

func Match

func Match(t *spb.SimpleTest, actual *exprpb.ExprValue) error

Match checks the expectation in the result matcher against the actual result of evaluation. Returns nil if the expectation matches the actual, otherwise returns an error describing the difference. Calling this function implies that the interpretation succeeded in the parse and check phases. See MatchValue() for the normalization applied to values for matching.

func MatchValue

func MatchValue(tag string, expected *exprpb.Value, actual *exprpb.Value) error

MatchValue returns whether the actual value is equal to the expected value, modulo the following normalization:

  1. All floating-point NaN values are equal.
  2. Map comparisons ignore order.

func ValidateTest

func ValidateTest(t *spb.SimpleTest) error

ValidateTest checks whether a simple test has the required fields.

Source Files

simple.go

Version
v0.3.0
Published
Aug 20, 2019
Platform
linux/amd64
Imports
6 packages
Last checked
2 hours ago

Tools for package owners.