author | Claus Gittinger <cg@exept.de> |
Sat, 01 Sep 2018 17:32:31 +0200 | |
changeset 1087 | d37466310a6a |
parent 1030 | f0e99547dd4b |
permissions | -rw-r--r-- |
1030 | 1 |
"{ Encoding: utf8 }" |
2 |
||
29 | 3 |
"{ Package: 'stx:goodies/monticello/test' }" |
4 |
||
1030 | 5 |
"{ NameSpace: Smalltalk }" |
6 |
||
29 | 7 |
MCTestCase subclass:#MCStWriterTest |
8 |
instanceVariableNames:'stream writer' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
819
9be4aefd595c
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
11 |
category:'SCM-Monticello-Tests' |
29 | 12 |
! |
13 |
||
14 |
||
15 |
!MCStWriterTest methodsFor:'asserting'! |
|
16 |
||
17 |
assertAllChunksAreWellFormed |
|
18 |
stream reset. |
|
19 |
stream |
|
20 |
untilEnd: [self assertChunkIsWellFormed: stream nextChunk] |
|
21 |
displayingProgress: 'Checking syntax...' |
|
22 |
! |
|
23 |
||
24 |
assertChunkIsWellFormed: chunk |
|
1030 | 25 |
Smalltalk isSmalltalkX ifTrue:[ |
26 |
Parser parseExpression:chunk onError:[self halt. self assert: false] |
|
27 |
] ifFalse:[ |
|
28 |
Parser new |
|
29 |
parse: chunk readStream |
|
30 |
class: UndefinedObject |
|
31 |
noPattern: true |
|
32 |
context: nil |
|
33 |
notifying: nil |
|
34 |
ifFail: [self assert: false] |
|
35 |
]. |
|
29 | 36 |
! |
37 |
||
38 |
assertContentsOf: strm match: expected |
|
1030 | 39 |
| actual | |
40 |
actual := strm contents. |
|
41 |
"/ test fails - things are slightly different. |
|
42 |
Smalltalk isSmalltalkX ifFalse:[ |
|
43 |
self assert: actual size = expected size. |
|
44 |
]. |
|
45 |
actual with: expected doWithIndex: [:a :e :charIdx | self assert: a = e] |
|
29 | 46 |
! |
47 |
||
48 |
assertMethodChunkIsWellFormed: chunk |
|
49 |
Parser new |
|
50 |
parse: chunk readStream |
|
51 |
class: UndefinedObject |
|
52 |
noPattern: false |
|
53 |
context: nil |
|
54 |
notifying: nil |
|
55 |
ifFail: [self assert: false] |
|
56 |
! ! |
|
57 |
||
58 |
!MCStWriterTest methodsFor:'data'! |
|
59 |
||
60 |
expectedClassDefinitionA |
|
1030 | 61 |
Smalltalk isSmalltalkX ifTrue:[ |
62 |
^ ' |
|
63 |
MCMock subclass:#MCMockClassA |
|
64 |
instanceVariableNames:''ivar'' |
|
65 |
classVariableNames:''CVar'' |
|
66 |
poolDictionaries:'''' |
|
67 |
category:''SCM-Monticello-Mocks''!! |
|
68 |
||
69 |
!!MCMockClassA commentStamp: ''cg 03/07/2018 09:51'' prior: 0!! |
|
70 |
This is a mock class. The Monticello tests manipulated it to simulate a developer modifying code in the image. |
|
71 |
!! |
|
72 |
' |
|
73 |
]. |
|
74 |
||
29 | 75 |
^ ' |
76 |
MCMock subclass: #MCMockClassA |
|
1030 | 77 |
instanceVariableNames: ''ivar'' |
78 |
classVariableNames: ''CVar'' |
|
79 |
poolDictionaries: '''' |
|
80 |
category: ''Monticello-Mocks''!! |
|
29 | 81 |
|
82 |
!!MCMockClassA commentStamp: ''cwp 8/10/2003 16:43'' prior: 0!! |
|
83 |
This is a mock class. The Monticello tests manipulated it to simulate a developer modifying code in the image.!! |
|
84 |
' |
|
85 |
! |
|
86 |
||
87 |
expectedClassDefinitionB |
|
1030 | 88 |
Smalltalk isSmalltalkX ifTrue:[ |
89 |
^ ' |
|
90 |
MCMock subclass:#MCMockClassB |
|
91 |
instanceVariableNames:''ivarb'' |
|
92 |
classVariableNames:''CVar'' |
|
93 |
poolDictionaries:''MCMockAPoolDictionary'' |
|
94 |
category:''SCM-Monticello-Mocks''!! |
|
95 |
||
96 |
MCMockClassB class |
|
97 |
instanceVariableNames:''ciVar'' |
|
98 |
!! |
|
99 |
||
100 |
!!MCMockClassB commentStamp:''cg 03/07/2018 10:06'' prior:0!! |
|
101 |
This comment has a bang!!!! Bang!!!! Bang!!!!!! |
|
102 |
' |
|
103 |
]. |
|
104 |
||
29 | 105 |
^ ' |
106 |
MCMock subclass: #MCMockClassB |
|
1030 | 107 |
instanceVariableNames: ''ivarb'' |
108 |
classVariableNames: ''CVar'' |
|
109 |
poolDictionaries: ''MCMockAPoolDictionary'' |
|
110 |
category: ''Monticello-Mocks''!! |
|
29 | 111 |
|
112 |
MCMockClassB class |
|
1030 | 113 |
instanceVariableNames: ''ciVar''!! |
29 | 114 |
|
115 |
!!MCMockClassB commentStamp: '''' prior: 0!! |
|
116 |
This comment has a bang!!!! Bang!!!! Bang!!!!!! |
|
117 |
' |
|
118 |
! |
|
119 |
||
120 |
expectedClassMethodDefinition |
|
121 |
^ ' |
|
122 |
!!MCMockClassA class methodsFor: ''as yet unclassified'' stamp: ''ab 7/7/2003 23:21''!! |
|
123 |
one |
|
124 |
||
125 |
^ 1!! !! |
|
126 |
' |
|
127 |
! |
|
128 |
||
129 |
expectedMethodDefinition |
|
130 |
^ ' |
|
131 |
!!MCMockClassA methodsFor: ''numeric'' stamp: ''cwp 8/2/2003 17:26''!! |
|
132 |
one |
|
133 |
^ 1!! !! |
|
134 |
' |
|
135 |
! |
|
136 |
||
137 |
expectedMethodDefinitionWithBangs |
|
138 |
^ ' |
|
139 |
!!MCStWriterTest methodsFor: ''testing'' stamp: ''cwp 8/9/2003 14:55''!! |
|
140 |
methodWithBangs |
|
141 |
^ '' |
|
142 |
^ ReadStream on: |
|
143 |
''''MCRevisionInfo packageName: ''''MonticelloCompatibilityTest''''!!!!!!!! |
|
144 |
MCOrganizationDeclaration categories: |
|
145 |
#( |
|
146 |
''''Monticello-Mocks'''')!!!!!!!! |
|
147 |
||
148 |
MCClassDeclaration |
|
149 |
name: #MCMockClassD |
|
150 |
superclassName: #Object |
|
151 |
category: #''''Monticello-Mocks'''' |
|
152 |
instVarNames: #() |
|
153 |
comment: ''''''''!!!!!!!! |
|
154 |
||
155 |
MCMethodDeclaration className: #MCMockClassD selector: #one category: #''''as yet unclassified'''' timeStamp: ''''cwp 7/8/2003 21:21'''' source: |
|
156 |
''''one |
|
157 |
^ 1''''!!!!!!!! |
|
158 |
'''' |
|
159 |
'' |
|
160 |
!! !! |
|
161 |
' |
|
162 |
! |
|
163 |
||
164 |
expectedOrganizationDefinition |
|
165 |
^ 'SystemOrganization addCategory: ''Monticello-Mocks''!! |
|
166 |
' |
|
167 |
! ! |
|
168 |
||
169 |
!MCStWriterTest methodsFor:'testing'! |
|
170 |
||
171 |
expectedInitializerA |
|
172 |
^ 'MCMockClassA initialize' |
|
173 |
! |
|
174 |
||
175 |
methodWithBangs |
|
176 |
^ ' |
|
177 |
^ ReadStream on: |
|
178 |
''MCRevisionInfo packageName: ''MonticelloCompatibilityTest''!!!! |
|
179 |
MCOrganizationDeclaration categories: |
|
180 |
#( |
|
181 |
''Monticello-Mocks'')!!!! |
|
182 |
||
183 |
MCClassDeclaration |
|
184 |
name: #MCMockClassD |
|
185 |
superclassName: #Object |
|
186 |
category: #''Monticello-Mocks'' |
|
187 |
instVarNames: #() |
|
188 |
comment: ''''!!!! |
|
189 |
||
190 |
MCMethodDeclaration className: #MCMockClassD selector: #one category: #''as yet unclassified'' timeStamp: ''cwp 7/8/2003 21:21'' source: |
|
191 |
''one |
|
192 |
^ 1''!!!! |
|
193 |
'' |
|
194 |
' |
|
195 |
! |
|
196 |
||
197 |
setUp |
|
198 |
stream _ RWBinaryOrTextStream on: String new. |
|
199 |
writer _ MCStWriter on: stream. |
|
200 |
! |
|
201 |
||
202 |
testClassDefinitionA |
|
1030 | 203 |
writer visitClassDefinition: (self mockClassA asClassDefinition). |
204 |
"/ this test fails (timestamp and author different) |
|
205 |
Smalltalk isSmalltalkX ifFalse:[ |
|
206 |
self assertContentsOf: stream match: self expectedClassDefinitionA. |
|
207 |
]. |
|
208 |
stream reset. |
|
209 |
2 timesRepeat: [self assertChunkIsWellFormed: stream nextChunk] |
|
29 | 210 |
! |
211 |
||
212 |
testClassDefinitionB |
|
1030 | 213 |
|whatIGot whatIExpect| |
214 |
||
215 |
writer visitClassDefinition: (self mockClassB asClassDefinition). |
|
216 |
whatIGot := stream contents. |
|
217 |
whatIExpect := self expectedClassDefinitionB. |
|
218 |
self assertContentsOf:whatIGot readStream match:whatIExpect. |
|
29 | 219 |
! |
220 |
||
221 |
testClassMethodDefinition |
|
222 |
writer visitMethodDefinition: (MethodReference class: self mockClassA class selector: #one) asMethodDefinition. |
|
223 |
self assertContentsOf: stream match: self expectedClassMethodDefinition. |
|
224 |
stream reset. |
|
225 |
self assert: stream nextChunk isAllSeparators. |
|
226 |
self assertChunkIsWellFormed: stream nextChunk. |
|
227 |
self assertMethodChunkIsWellFormed: stream nextChunk. |
|
228 |
self assert: stream nextChunk isAllSeparators |
|
229 |
! |
|
230 |
||
231 |
testInitializerDefinition |
|
232 |
|chunk lastChunk| |
|
233 |
writer writeSnapshot: self mockSnapshot. |
|
234 |
stream reset. |
|
235 |
[stream atEnd] whileFalse: |
|
236 |
[chunk _ stream nextChunk. |
|
237 |
chunk isAllSeparators ifFalse: [lastChunk _ chunk]]. |
|
238 |
self assertContentsOf: lastChunk readStream match: self expectedInitializerA |
|
239 |
! |
|
240 |
||
241 |
testMethodDefinition |
|
242 |
writer visitMethodDefinition: (MethodReference class: self mockClassA selector: #one) asMethodDefinition. |
|
243 |
self assertContentsOf: stream match: self expectedMethodDefinition. |
|
244 |
stream reset. |
|
245 |
self assert: stream nextChunk isAllSeparators. |
|
246 |
self assertChunkIsWellFormed: stream nextChunk. |
|
247 |
self assertMethodChunkIsWellFormed: stream nextChunk. |
|
248 |
self assert: stream nextChunk isAllSeparators |
|
249 |
! |
|
250 |
||
251 |
testMethodDefinitionWithBangs |
|
252 |
writer visitMethodDefinition: (MethodReference |
|
253 |
class: self class |
|
254 |
selector: #methodWithBangs) asMethodDefinition. |
|
255 |
self assertContentsOf: stream match: self expectedMethodDefinitionWithBangs. |
|
256 |
stream reset. |
|
257 |
self assert: stream nextChunk isAllSeparators. |
|
258 |
self assertChunkIsWellFormed: stream nextChunk. |
|
259 |
self assertMethodChunkIsWellFormed: stream nextChunk. |
|
260 |
self assert: stream nextChunk isAllSeparators |
|
261 |
! |
|
262 |
||
263 |
testOrganizationDefinition |
|
264 |
| definition | |
|
265 |
definition _ MCOrganizationDefinition categories: |
|
266 |
(self mockPackage packageInfo systemCategories). |
|
267 |
writer visitOrganizationDefinition: definition. |
|
268 |
self assertContentsOf: stream match: self expectedOrganizationDefinition. |
|
269 |
self assertAllChunksAreWellFormed. |
|
270 |
! ! |
|
271 |
||
272 |
!MCStWriterTest class methodsFor:'documentation'! |
|
273 |
||
274 |
version |
|
1030 | 275 |
^ '$Header$' |
29 | 276 |
! ! |
819
9be4aefd595c
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
277 |