@ 37b1f5914992b1c2410e634b80cb352b72e7f793 | history
package government_test
import (
"os"
"path/filepath"
"testing"
"government/eval"
"government/internal/lisptest"
)
// TestLispFiles runs every testdata/*.gov.lisp file straight from source text.
// Step 5.4 switches this to compiling each file to .gov and running the
// result.
func TestLispFiles(t *testing.T) {
paths, err := filepath.Glob("testdata/*.gov.lisp")
if err != nil {
t.Fatal(err)
}
if len(paths) == 0 {
t.Fatal("no testdata/*.gov.lisp files found")
}
for _, path := range paths {
t.Run(filepath.Base(path), func(t *testing.T) {
src, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
f, err := lisptest.Parse(path, string(src))
if err != nil {
t.Fatal(err)
}
lisptest.Run(t, f, eval.NewTopLevel())
})
}
}