-
-
Notifications
You must be signed in to change notification settings - Fork 354
/
CDBehaviorParserTest.class.st
122 lines (89 loc) · 3.08 KB
/
CDBehaviorParserTest.class.st
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Class {
#name : #CDBehaviorParserTest,
#superclass : #TestCase,
#instVars : [
'classDefinition'
],
#category : #'ClassParser-Tests'
}
{ #category : #testing }
CDBehaviorParserTest class >> isAbstract [
^ self == CDBehaviorParserTest
]
{ #category : #helpers }
CDBehaviorParserTest >> classDefinitionString [
self subclassResponsibility
]
{ #category : #helpers }
CDBehaviorParserTest >> className [
^ 'TheClass'
]
{ #category : #helpers }
CDBehaviorParserTest >> firstInstanceVariableName [
^ 'first'
]
{ #category : #helpers }
CDBehaviorParserTest >> nodeFor: aString [
^ classDefinition bestNodeFor: (self selectionOf: aString)
]
{ #category : #helpers }
CDBehaviorParserTest >> secondInstanceVariableName [
^ 'second'
]
{ #category : #helpers }
CDBehaviorParserTest >> selectionOf: aText [
| start |
start := self classDefinitionString findString: aText.
^ start to: start
]
{ #category : #running }
CDBehaviorParserTest >> setUp [
super setUp.
classDefinition := CDClassDefinitionParser parse: self classDefinitionString.
]
{ #category : #tests }
CDBehaviorParserTest >> testBestNodeForClassNameSelectionShouldBeClassNameNode [
| selectedNode selection |
selection := self selectionOf: self className.
selectedNode := classDefinition bestNodeFor: selection.
self assert: selectedNode equals: classDefinition classNameNode
]
{ #category : #tests }
CDBehaviorParserTest >> testBestNodeForInstanceVariableSelectionShouldBeSlotNode [
| selectedNode selection |
selection := self selectionOf: self firstInstanceVariableName.
selectedNode := classDefinition bestNodeFor: selection.
self assert: selectedNode equals: classDefinition slotNodes first
]
{ #category : #tests }
CDBehaviorParserTest >> testBestNodeForSecondInstanceVariableSelectionShouldBeSecondSlotNode [
| selectedNode selection |
selection := self selectionOf: self secondInstanceVariableName.
selectedNode := classDefinition bestNodeFor: selection.
self assert: selectedNode equals: classDefinition slotNodes second
]
{ #category : #tests }
CDBehaviorParserTest >> testClassDefFromLegacyStringHasClassName [
self assert: classDefinition className equals: self className
]
{ #category : #tests }
CDBehaviorParserTest >> testClassDefFromLegacyStringHasSlots [
self assert: classDefinition slotNodes first name equals: self firstInstanceVariableName.
self assert: classDefinition slotNodes second name equals: self secondInstanceVariableName.
]
{ #category : #tests }
CDBehaviorParserTest >> testClassNameNodeHaveParentReference [
| nameNode |
nameNode := classDefinition classNameNode.
self assert: nameNode parent identicalTo: classDefinition.
self assert: nameNode classDefinitionNode identicalTo: classDefinition.
self assert: (classDefinition children includes: nameNode)
]
{ #category : #tests }
CDBehaviorParserTest >> testSlotNodesHaveParentReference [
| slotNode |
slotNode := classDefinition slotNodes first.
self assert: slotNode parent identicalTo: classDefinition.
self assert: slotNode classDefinitionNode identicalTo: classDefinition.
self assert: (classDefinition children includes: slotNode)
]