1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-14 11:23:02 +02:00
ferret/e2e/runner/lib.go

30 lines
578 B
Go
Raw Normal View History

2018-10-14 21:38:14 +02:00
package runner
import (
"context"
"fmt"
2018-10-14 21:38:14 +02:00
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
func Assertions() map[string]core.Function {
return map[string]core.Function{
"EXPECT": expect,
}
}
func expect(_ context.Context, args ...core.Value) (core.Value, error) {
err := core.ValidateArgs(args, 2, 2)
if err != nil {
return values.None, err
}
if args[0].Compare(args[1]) == 0 {
return values.EmptyString, nil
}
2018-11-22 05:45:00 +02:00
return values.NewString(fmt.Sprintf(`expected "%s", but got "%s"`, args[0], args[1])), nil
2018-10-14 21:38:14 +02:00
}