-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathstatements_test_helpers.go
76 lines (62 loc) · 2.23 KB
/
statements_test_helpers.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
//+build !release
package ast
import (
"testing"
)
/*
BaseNode
*/
// IsClassStmt fails the test and returns nil by default
func (b *BaseNode) IsClassStmt(t *testing.T) *testableClassStatement {
t.Helper()
t.Fatalf(nodeFailureMsgFormat, "class statement", b)
return nil
}
// IsModuleStmt fails the test and returns nil by default
func (b *BaseNode) IsModuleStmt(t *testing.T) *testableModuleStatement {
t.Helper()
t.Fatalf(nodeFailureMsgFormat, "module statement", b)
return nil
}
// IsReturnStmt fails the test and returns nil by default
func (b *BaseNode) IsReturnStmt(t *testing.T) *testableReturnStatement {
t.Helper()
t.Fatalf(nodeFailureMsgFormat, "return statement", b)
return nil
}
// IsDefStmt fails the test and returns nil by default
func (b *BaseNode) IsDefStmt(t *testing.T) *testableDefStatement {
t.Helper()
t.Fatalf(nodeFailureMsgFormat, "method definition", b)
return nil
}
// IsWhileStmt fails the test and returns nil by default
func (b *BaseNode) IsWhileStmt(t *testing.T) (ws *testableWhileStatement) {
t.Helper()
t.Fatalf(nodeFailureMsgFormat, "while statement", b)
return nil
}
// IsClassStmt fails the test and returns nil by default
func (cs *ClassStatement) IsClassStmt(t *testing.T) *testableClassStatement {
return &testableClassStatement{t: t, ClassStatement: cs}
}
// IsModuleStmt returns a pointer of the module statement
func (ms *ModuleStatement) IsModuleStmt(t *testing.T) *testableModuleStatement {
return &testableModuleStatement{ModuleStatement: ms, t: t}
}
// IsDefStmt returns a pointer of the DefStatement
func (ds *DefStatement) IsDefStmt(t *testing.T) *testableDefStatement {
return &testableDefStatement{DefStatement: ds, t: t}
}
// IsReturnStmt returns a pointer of the ReturnStatement
func (rs *ReturnStatement) IsReturnStmt(t *testing.T) (trs *testableReturnStatement) {
return &testableReturnStatement{t: t, ReturnStatement: rs}
}
// IsExpression returns ExpressionStatement itself
func (ts *ExpressionStatement) IsExpression(t *testing.T) testableExpression {
return ts.Expression.(testableExpression)
}
// IsWhileStmt returns the pointer of current while statement
func (ws *WhileStatement) IsWhileStmt(t *testing.T) *testableWhileStatement {
return &testableWhileStatement{WhileStatement: ws, t: t}
}