-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
57 lines (46 loc) · 1.19 KB
/
parser_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
52
53
54
55
56
57
package jaess
import (
"os"
"fmt"
"bufio"
"testing"
)
func TestBasicParse(raw_t *testing.T) {
t := NewTestWrapper(raw_t)
// t.Trace = true
_RunParserTest("basic-parse", t)
}
func TestParseExportConstants(raw_t *testing.T) {
t := NewTestWrapper(raw_t)
// t.Trace = true
_RunParserTest("exported-constants", t)
}
func TestParseNegatives(raw_t *testing.T) {
t := NewTestWrapper(raw_t)
// t.Trace = true
_RunParserTest("negatives", t)
}
func TestArrays(raw_t *testing.T) {
t := NewTestWrapper(raw_t)
// t.Trace = true
_RunParserTest("arrays", t)
}
func TestParseShapeObjects(raw_t *testing.T) {
t := NewTestWrapper(raw_t)
// t.Trace = true
_RunParserTest("shape-objects", t)
}
func _RunParserTest(fixture_name string, t *TestWrapper) {
test_input, err := os.Open(fmt.Sprintf("fixtures/%s.js", fixture_name))
test_source := bufio.NewReader(test_input)
t.AssertNoError(err)
ast, err := NewParser(test_source).Parse()
if !t.AssertNoError(err) {
return
}
astBuffer, err := FormattedAstBuffer(ast)
t.AssertNoError(err)
expected_ast := t.ReadFile(fmt.Sprintf("fixtures/%s-ast.json", fixture_name))
actual_ast := bufio.NewReader(astBuffer)
t.AssertEqualLines(expected_ast, actual_ast)
}