-
Notifications
You must be signed in to change notification settings - Fork 2
/
mui_test.go
89 lines (76 loc) · 2.63 KB
/
mui_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package mui
import (
"fmt"
"testing"
)
func TestParser(t *testing.T) {
fmt.Print("Testing MUI parser...\n\n")
var parserTests []*UnitTest
parserTests = append(parserTests, &UnitTest{
name: "Simple node",
filename: "tests/node.mui",
description: "Simplest node example, with content",
testingFunction: parseNode,
})
parserTests = append(parserTests, &UnitTest{
name: "Simple node space",
filename: "tests/node_space.mui",
description: "Simplest node example, with content, whitespace, tab and newline",
testingFunction: parseNodeSpace,
})
parserTests = append(parserTests, &UnitTest{
name: "Props",
filename: "tests/prop.mui",
description: "Node with content, whitespace and props",
testingFunction: parseProp,
})
parserTests = append(parserTests, &UnitTest{
name: "Multiple props",
filename: "tests/multiprop.mui",
description: "Node with content, whitespace and props",
testingFunction: parseMultiProp,
})
parserTests = append(parserTests, &UnitTest{
name: "Multiple props and spaces",
filename: "tests/multiprop_space.mui",
description: "Node with content, whitespace and props separated by space",
testingFunction: parseMultiPropSpace,
})
parserTests = append(parserTests, &UnitTest{
name: "Single child",
filename: "tests/children.mui",
description: "Node with no content, whitespace and a single child",
testingFunction: parseChildren,
})
parserTests = append(parserTests, &UnitTest{
name: "Same level children",
filename: "tests/same_level_children.mui",
description: "Node with no content, whitespace and children",
testingFunction: parseSameLevelChildren,
})
parserTests = append(parserTests, &UnitTest{
name: "Missing paranthesis",
filename: "tests/missing_parenthesis.mui",
description: "The parser should return an error",
testingFunction: parseMissingParenthesis,
})
parserTests = append(parserTests, &UnitTest{
name: "Missing paranthesis after content",
filename: "tests/missing_parenthesis_content.mui",
description: "The parser should return an error",
testingFunction: parseMissingParenthesisContent,
})
parserTests = append(parserTests, &UnitTest{
name: "Just an identifier",
filename: "tests/just_identifier.mui",
description: "Just a single floating identifier",
testingFunction: parseJustAnIdentifier,
})
for _, test := range parserTests {
if err := test.Run(); err != nil {
test.Fail(err, t)
} else {
test.Pass()
}
}
}