-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathast_test.go
More file actions
47 lines (43 loc) · 835 Bytes
/
ast_test.go
File metadata and controls
47 lines (43 loc) · 835 Bytes
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 condition
import (
"testing"
)
func TestAST(t *testing.T) {
expected := `FUNCTION<functionB>
\_ ARRAY
|__ LITERAL<number::555>
|__ LITERAL<number::66.6>
|__ LITERAL<null>
|__ LITERAL<string::value1>
|__ FUNCTION<functionC>
| \_ FUNCTION<functionD>
| \_ ARRAY
| |__ LITERAL<string::value>
| \_ LITERAL<number::55>
|__ LITERAL<bool::false>
\_ FUNCTION<functionA>
\_ LITERAL<string::input>
`
root, err := Parse(`
{
"functionB":
[
555,
66.6,
null,
"value1",
{"functionC": {"functionD": ["value", 55] } },
false,
{"functionA": "input"}
]
}
`)
if err != nil {
t.Errorf("%s\n", err.Error())
} else {
res := Stringify(root)
if res != expected {
t.Errorf("Expected: \n%s\n\nGot: \n%s\n\n", expected, res)
}
}
}