-
Notifications
You must be signed in to change notification settings - Fork 21
/
binding_test.go
51 lines (40 loc) · 1.32 KB
/
binding_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
48
49
50
51
package tree_sitter_ocaml_test
import (
"context"
"testing"
tree_sitter "github.com/smacker/go-tree-sitter"
tree_sitter_ocaml "github.com/tree-sitter/tree-sitter-ocaml"
)
func TestOCamlGrammar(t *testing.T) {
language := tree_sitter.NewLanguage(tree_sitter_ocaml.OCaml())
if language == nil {
t.Errorf("Error loading OCaml grammar")
}
sourceCode := []byte("module M = struct let x = 0 end")
node, err := tree_sitter.ParseCtx(context.Background(), sourceCode, language)
if err != nil || node.HasError() {
t.Errorf("Error parsing OCaml")
}
}
func TestOCamlInterfaceGrammar(t *testing.T) {
language := tree_sitter.NewLanguage(tree_sitter_ocaml.OCamlInterface())
if language == nil {
t.Errorf("Error loading OCamlInterface grammar")
}
sourceCode := []byte("module M : sig val x : int end")
node, err := tree_sitter.ParseCtx(context.Background(), sourceCode, language)
if err != nil || node.HasError() {
t.Errorf("Error parsing OCamlInterface")
}
}
func TestOCamlTypeGrammar(t *testing.T) {
language := tree_sitter.NewLanguage(tree_sitter_ocaml.OCamlType())
if language == nil {
t.Errorf("Error loading OCamlType grammar")
}
sourceCode := []byte("int list")
node, err := tree_sitter.ParseCtx(context.Background(), sourceCode, language)
if err != nil || node.HasError() {
t.Errorf("Error parsing OCamlType")
}
}