package registry_test

import (
	"flow/registry"
	"testing"

	. "flow/internal/check"
)

func TestRegistryGet(t *testing.T) {
	expect := Expect(t)

	r := registry.New()
	r.Register("vecadd", dummy1)

	fn, err := r.Get("vecadd")

	expect.NotErr(err)
	expect.Diff(nil, fn)

}

func TestRegistry(t *testing.T) {
	expect := Expect(t)

	r := registry.New()
	r.Register("vecadd", dummy1)

	e, err := r.Entry("vecadd")
	expect.NotErr(err)

	d := e.Description

	expect.Eq(2, len(d.Inputs))
	expect.Eq(d.Output, "[]float32")

	t.Log(d)

}
func TestDescriptions(t *testing.T) {
	expect := Expect(t)

	r := registry.New()
	r.Register("vecadd", dummy1)
	r.Register("vecstr", dummy2)

	d, err := r.Descriptions()
	expect.NotErr(err)
	expect.Eq(2, len(d))

	t.Log(d)

}

func dummy1([]float32, []float32) []float32 {
	return []float32{1, 3, 3, 7}
}
func dummy2([]float32) string {
	return ""
}
