@ efc0e8ad4d88be48a5cdedd9b62e88420b8b6e5e | history
package eval
import (
"testing"
"nmyk.io/government/sexpr"
)
// Closures and builtins live in this package, so it must be able to define
// sexpr.Function implementations.
type stubFunc struct {
sexpr.FunctionBase
name string
}
func (f stubFunc) Builtin() bool { return true }
func (f stubFunc) Name() string { return f.name }
func TestEvalCanDefineFunctions(t *testing.T) {
var v sexpr.Value = stubFunc{name: "+"}
if _, ok := v.(sexpr.Function); !ok {
t.Fatal("stubFunc is not a sexpr.Function")
}
if got := sexpr.Print(v); got != "#<builtin +>" {
t.Errorf("Print = %s, want #<builtin +>", got)
}
}