github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/testing/lib.go (about)

     1  package testing
     2  
     3  import (
     4  	"github.com/MontFerret/ferret/pkg/runtime/core"
     5  	"github.com/MontFerret/ferret/pkg/stdlib/testing/base"
     6  )
     7  
     8  // @namespace T
     9  func RegisterLib(ns core.Namespace) error {
    10  	t := ns.Namespace("T")
    11  
    12  	if err := registerNOT(t); err != nil {
    13  		return err
    14  	}
    15  
    16  	return t.RegisterFunctions(
    17  		core.NewFunctionsFromMap(map[string]core.Function{
    18  			"EMPTY":    base.NewPositiveAssertion(Empty),
    19  			"EQ":       base.NewPositiveAssertion(Equal),
    20  			"FAIL":     base.NewPositiveAssertion(Fail),
    21  			"FALSE":    base.NewPositiveAssertion(False),
    22  			"GT":       base.NewPositiveAssertion(Gt),
    23  			"GTE":      base.NewPositiveAssertion(Gte),
    24  			"INCLUDE":  base.NewPositiveAssertion(Include),
    25  			"LEN":      base.NewPositiveAssertion(Len),
    26  			"MATCH":    base.NewPositiveAssertion(Match),
    27  			"LT":       base.NewPositiveAssertion(Lt),
    28  			"LTE":      base.NewPositiveAssertion(Lte),
    29  			"NONE":     base.NewPositiveAssertion(None),
    30  			"TRUE":     base.NewPositiveAssertion(True),
    31  			"STRING":   base.NewPositiveAssertion(String),
    32  			"INT":      base.NewPositiveAssertion(Int),
    33  			"FLOAT":    base.NewPositiveAssertion(Float),
    34  			"DATETIME": base.NewPositiveAssertion(DateTime),
    35  			"ARRAY":    base.NewPositiveAssertion(Array),
    36  			"OBJECT":   base.NewPositiveAssertion(Object),
    37  			"BINARY":   base.NewPositiveAssertion(Binary),
    38  		}),
    39  	)
    40  }
    41  
    42  func registerNOT(ns core.Namespace) error {
    43  	t := ns.Namespace("NOT")
    44  
    45  	return t.RegisterFunctions(
    46  		core.NewFunctionsFromMap(map[string]core.Function{
    47  			"EMPTY":    base.NewNegativeAssertion(Empty),
    48  			"EQ":       base.NewNegativeAssertion(Equal),
    49  			"FALSE":    base.NewNegativeAssertion(False),
    50  			"GT":       base.NewNegativeAssertion(Gt),
    51  			"GTE":      base.NewNegativeAssertion(Gte),
    52  			"INCLUDE":  base.NewNegativeAssertion(Include),
    53  			"LEN":      base.NewNegativeAssertion(Len),
    54  			"MATCH":    base.NewNegativeAssertion(Match),
    55  			"LT":       base.NewNegativeAssertion(Lt),
    56  			"LTE":      base.NewNegativeAssertion(Lte),
    57  			"NONE":     base.NewNegativeAssertion(None),
    58  			"TRUE":     base.NewNegativeAssertion(True),
    59  			"STRING":   base.NewNegativeAssertion(String),
    60  			"INT":      base.NewNegativeAssertion(Int),
    61  			"FLOAT":    base.NewNegativeAssertion(Float),
    62  			"DATETIME": base.NewNegativeAssertion(DateTime),
    63  			"ARRAY":    base.NewNegativeAssertion(Array),
    64  			"OBJECT":   base.NewNegativeAssertion(Object),
    65  			"BINARY":   base.NewNegativeAssertion(Binary),
    66  		}),
    67  	)
    68  }