github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/testing/empty.go (about) 1 package testing 2 3 import ( 4 "context" 5 6 "github.com/MontFerret/ferret/pkg/runtime/core" 7 "github.com/MontFerret/ferret/pkg/runtime/values" 8 "github.com/MontFerret/ferret/pkg/stdlib/collections" 9 "github.com/MontFerret/ferret/pkg/stdlib/testing/base" 10 ) 11 12 // EMPTY asserts that the target does not contain any values. 13 // @param {Measurable | Binary | Object | Any[] | String} actual - Value to test. 14 // @param {String} [message] - Message to display on error. 15 var Empty = base.Assertion{ 16 DefaultMessage: func(_ []core.Value) string { 17 return "be empty" 18 }, 19 MinArgs: 1, 20 MaxArgs: 2, 21 Fn: func(ctx context.Context, args []core.Value) (bool, error) { 22 size, err := collections.Length(ctx, args[0]) 23 24 if err != nil { 25 return false, err 26 } 27 28 return values.ToInt(size) == 0, nil 29 }, 30 }