-
-
Notifications
You must be signed in to change notification settings - Fork 346
/
RBAbstractRefactoringTest.class.st
230 lines (187 loc) · 6.56 KB
/
RBAbstractRefactoringTest.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
Class {
#name : 'RBAbstractRefactoringTest',
#superclass : 'RBAbstractEnvTestCase',
#instVars : [
'rbClass'
],
#category : 'Refactoring-Transformations-Tests-Parametrized',
#package : 'Refactoring-Transformations-Tests',
#tag : 'Parametrized'
}
{ #category : 'helpers' }
RBAbstractRefactoringTest class >> unreferencedClass [
"Answer a <Class> which should not have any references"
| env |
env := (RBNamespace onEnvironment: (RBPackageEnvironment packageName: 'Refactoring-DataForTesting')).
^ env classNamed: self unreferencedClassName
]
{ #category : 'helpers' }
RBAbstractRefactoringTest class >> unreferencedClassName [
"Answer a <Symbol> representing a <Class> which should not have any references"
^ #[82 66 67 108 97 115 115 87 105 116 104 111 117 116 83 101 108 102 67 108 97 115 115 82 101 102 101 114 101 110 99 101 84 101 115 116] asString asSymbol
]
{ #category : 'accessing' }
RBAbstractRefactoringTest >> constructor [
]
{ #category : 'helpers' }
RBAbstractRefactoringTest >> createRefactoringWithArguments: aParameterCollection [
^ rbClass
perform: self constructor
withArguments: aParameterCollection
]
{ #category : 'helpers' }
RBAbstractRefactoringTest >> createRefactoringWithModel: aRBNamespace andArguments: aParameterCollection [
^ rbClass
perform: #model: , self constructor
withArguments: { aRBNamespace } , aParameterCollection
]
{ #category : 'parsing' }
RBAbstractRefactoringTest >> executeRefactoring: aRefactoring [
aRefactoring generateChanges
]
{ #category : 'parsing' }
RBAbstractRefactoringTest >> executeRefactorings: aRefactoringColl [
aRefactoringColl do: [ :ref | ref generateChanges]
]
{ #category : 'tests' }
RBAbstractRefactoringTest >> methodSignatureStringForSymbol: aSymbol withArgumentString: aString [
"The method is written this way to make sure that we can rename test input (methods) and do not break the tests."
^ aSymbol asString, aString, Character cr asString
]
{ #category : 'tests' }
RBAbstractRefactoringTest >> methodSignatureStringForUnarySymbol: aSymbol [
"The method is written this way to make sure that we can rename test input (methods) and do not break the tests."
^ aSymbol asString, Character cr asString
]
{ #category : 'helpers' }
RBAbstractRefactoringTest >> objectClassVariable [
^ Character classVariables first name
]
{ #category : 'parsing' }
RBAbstractRefactoringTest >> parseExpression: aString [
^ self parserClass parseExpression: aString
]
{ #category : 'parsing' }
RBAbstractRefactoringTest >> parseMethod: aString [
^ self parserClass parseMethod: aString
]
{ #category : 'parsing' }
RBAbstractRefactoringTest >> parserClass [
^ RBParser
]
{ #category : 'accessing' }
RBAbstractRefactoringTest >> rbClass: anObject [
rbClass := anObject
]
{ #category : 'running' }
RBAbstractRefactoringTest >> setUp [
super setUp.
model := self defaultNamespaceClass new
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupExtractionClassFor: aRefactoring toReturn: aClass [
| options |
options := aRefactoring options copy.
options at: #extractionClass
put: [:ref | aClass].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupImplementorToInlineFor: aRefactoring toReturn: anObject [
| options |
options := aRefactoring options copy.
options at: #implementorToInline put: [:ref :imps | anObject].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupInlineExpressionFor: aRefactoring toReturn: aBoolean [
| options |
options := aRefactoring options copy.
options at: #inlineExpression put: [:ref :string | aBoolean].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupMethodNameFor: aRefactoring toReturn: aSelector [
| options |
options := aRefactoring options copy.
options at: #methodName
put:
[:aMethodName :ref |
aMethodName
selector: aSelector;
yourself].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupMethodNameFor: aRefactoring toReturn: aSelector withArguments: stringCollection [
| options |
options := aRefactoring options copy.
options at: #methodName
put:
[ :aMethodName :ref |
aMethodName
selector: aSelector;
arguments: stringCollection;
yourself].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupSearchInAllHierarchyFor: aRefactoring toReturn: aBoolean [
| options |
options := aRefactoring options copy.
options at: #searchInWholeHierarchy put: [ :ref :cls | aBoolean ].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupSelfArgumentNameFor: aRefactoring toReturn: aString [
| options |
options := aRefactoring options copy.
options at: #selfArgumentName put: [:ref | aString].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupVariableToMoveToFor: aRefactoring toReturn: aString [
| options |
options := aRefactoring options copy.
options at: #selectVariableToMoveTo put: [:ref :class :selector | aString].
aRefactoring options: options
]
{ #category : 'set up' }
RBAbstractRefactoringTest >> setupVariableTypesFor: aRefactoring toReturn: anObject [
| options |
options := aRefactoring options copy.
options at: #variableTypes put: [:ref :ignore1 :ignore2 | anObject].
aRefactoring options: options
]
{ #category : 'actions' }
RBAbstractRefactoringTest >> shouldntWarn: aRefactoring [
self
shouldnt: [ self executeRefactoring: aRefactoring ]
raise: RBRefactoringWarning
]
{ #category : 'tests' }
RBAbstractRefactoringTest >> testConditions [
| condition newCondition |
condition := RBCondition new
block: [false]
errorString: 'false'.
condition errorMacro: '<1?true:false>'.
self deny: condition check.
self assert: condition errorString equals: 'false'.
self assert: condition not check.
self deny: (condition not & condition) check.
self assert: (condition & condition) not check.
self assert: (condition | condition not) check.
self deny: (newCondition := condition | condition) check.
self assert: newCondition errorString equals: 'false AND false'.
self assert: (condition not | condition not) check.
self deny: (newCondition := condition & condition) check.
self assert: newCondition errorString equals: 'false'.
self assert: (condition not & condition not) check.
self assert: (condition & condition) errorString equals: 'false OR false'
]
{ #category : 'helpers' }
RBAbstractRefactoringTest >> unreferencedClassName [
"Answer a <Symbol> representing a <Class> which should not have any references"
^ self class unreferencedClassName
]