assert

package
v0.0.0-...-693abe4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Nil = iota
	Boolean
	Number
	String
	Error
)

Value types

View Source
const AND = 57347
View Source
const (
	CUT = 100000
)

CUT code

View Source
const E = 57352
View Source
const EOF = 57360
View Source
const GT = 57357
View Source
const GTE = 57359
View Source
const LB = 57350
View Source
const LT = 57356
View Source
const LTE = 57358
View Source
const MATCH = 57361
View Source
const NE = 57353
View Source
const NOT = 57349
View Source
const NRE = 57355
View Source
const OR = 57348
View Source
const RB = 57351
View Source
const RE = 57354
View Source
const VALUE = 57346

Variables

This section is empty.

Functions

func Equal

func Equal(code1, code2 string) bool

Equal check if the two assert expression is equal, (mainly ignore the white space charactors)

func Execute

func Execute(code string, reader KV) (bool, error)

Execute directly run the code with the reader

func ExecuteMap

func ExecuteMap(code string, data map[string]interface{}) (bool, error)

ExecuteMap is a convenient function to execute code with data

func MustExecute

func MustExecute(code string, reader KV) bool

MustExecute is same with Execute, but panic if has error

func MustExecuteMap

func MustExecuteMap(code string, data map[string]interface{}) bool

MustExecuteMap is same with ExecuteMap, but panic if has error

Types

type Assert

type Assert struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

Assert 代表一个表达式

func New

func New(code string) (*Assert, error)

New 编译代码生成表达式

func (*Assert) Error

func (l *Assert) Error(s string)

Error 为 yacc 所用

func (*Assert) Execute

func (l *Assert) Execute(kv KV) (bool, error)

Execute 使用参数中给定的变量, 执行表达式并返回结果 执行过程中出现任何错误都会返回 error, 比如字符串与数字比较等等

func (*Assert) Lex

func (l *Assert) Lex(lval *yySymType) int

Lex 为 yacc 使用

type KV

type KV interface {
	Get(key string) interface{}
}

func NewKV

func NewKV(data map[string]interface{}) KV

NewKV is inner default KV

type Value

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

Value represents a variable in expression

func NewValue

func NewValue(name string, v interface{}) Value

NewValue create a new value

func (Value) Add

func (v Value) Add(v2 Value) Value

func (Value) And

func (v Value) And(v2 Value) Value

func (Value) Boolean

func (v Value) Boolean() bool

func (Value) Div

func (v Value) Div(v2 Value) Value

func (Value) E

func (v Value) E(v2 Value) Value

func (Value) Error

func (v Value) Error() error

func (Value) Float

func (v Value) Float() (float64, error)

func (Value) GT

func (v Value) GT(v2 Value) Value

func (Value) GTE

func (v Value) GTE(v2 Value) Value

func (Value) LT

func (v Value) LT(v2 Value) Value

func (Value) LTE

func (v Value) LTE(v2 Value) Value

func (Value) MATCH

func (v Value) MATCH(v2 Value) Value

func (Value) Mod

func (v Value) Mod(v2 Value) Value

func (Value) Multi

func (v Value) Multi(v2 Value) Value

func (Value) NE

func (v Value) NE(v2 Value) Value

func (Value) NRE

func (v Value) NRE(v2 Value) Value

func (Value) Not

func (v Value) Not() Value

func (Value) Or

func (v Value) Or(v2 Value) Value

func (Value) RE

func (v Value) RE(v2 Value) Value

func (Value) String

func (v Value) String() string

func (Value) Sub

func (v Value) Sub(v2 Value) Value

Jump to

Keyboard shortcuts

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