@ ce159ec40272fb3caed2436702b1426f1550e47d | history
package eval
import (
"testing"
"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)
}
}