-
Notifications
You must be signed in to change notification settings - Fork 0
/
dolessfn_test.go
47 lines (42 loc) · 996 Bytes
/
dolessfn_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package lisp_test
import (
"context"
_ "embed"
"log"
"testing"
"github.com/jig/lisp"
"github.com/jig/lisp/env"
"github.com/jig/lisp/lib/core/nscore"
"github.com/jig/lisp/types"
)
//go:embed dolessfn_test.lisp
var dolessfn_test string
func TestDoLessFunction(t *testing.T) {
ns := env.NewEnv()
for _, library := range []struct {
name string
load func(ns types.EnvType) error
}{
{"core mal", nscore.Load},
// {"core mal with input", nscore.LoadInput},
// {"command line args", nscore.LoadCmdLineArgs},
// {"concurrent", nsconcurrent.Load},
// {"core mal extended", nscoreextended.Load},
// {"assert", nsassert.Load},
} {
if err := library.load(ns); err != nil {
log.Fatalf("Library Load Error: %v\n", err)
}
}
ast, err := lisp.READ(dolessfn_test, nil, nil)
if err != nil {
t.Fatal(err)
}
res, err := lisp.EVAL(context.Background(), ast, ns)
if err != nil {
t.Fatal(err)
}
if !res.(bool) {
t.Fatalf(`res.(int) != 4 (res.(int) == %d)`, res)
}
}