310
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCTestCase subclass:#MCStWriterTest
|
|
4 |
instanceVariableNames:'stream writer'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Monticello-Tests'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCStWriterTest methodsFor:'asserting'!
|
|
12 |
|
|
13 |
assertAllChunksAreWellFormed
|
|
14 |
stream reset.
|
|
15 |
stream
|
|
16 |
untilEnd: [self assertChunkIsWellFormed: stream nextChunk]
|
|
17 |
displayingProgress: 'Checking syntax...'
|
|
18 |
!
|
|
19 |
|
|
20 |
assertChunkIsWellFormed: chunk
|
|
21 |
self class parserClass new
|
|
22 |
parse: chunk readStream
|
|
23 |
class: UndefinedObject
|
|
24 |
noPattern: true
|
|
25 |
context: nil
|
|
26 |
notifying: nil
|
|
27 |
ifFail: [self assert: false]
|
|
28 |
!
|
|
29 |
|
|
30 |
assertContentsOf: strm match: expected
|
|
31 |
| actual |
|
|
32 |
actual := strm contents.
|
|
33 |
self assert: actual size = expected size.
|
|
34 |
actual with: expected do: [:a :e | self assert: a = e]
|
|
35 |
!
|
|
36 |
|
|
37 |
assertMethodChunkIsWellFormed: chunk
|
|
38 |
self class parserClass new
|
|
39 |
parse: chunk readStream
|
|
40 |
class: UndefinedObject
|
|
41 |
noPattern: false
|
|
42 |
context: nil
|
|
43 |
notifying: nil
|
|
44 |
ifFail: [self assert: false]
|
|
45 |
! !
|
|
46 |
|
|
47 |
!MCStWriterTest methodsFor:'data'!
|
|
48 |
|
|
49 |
expectedClassDefinitionA
|
|
50 |
^ '
|
|
51 |
MCMock subclass: #MCMockClassA
|
|
52 |
instanceVariableNames: ''ivar''
|
|
53 |
classVariableNames: ''CVar''
|
|
54 |
poolDictionaries: ''''
|
|
55 |
category: ''Monticello-Mocks''!!
|
|
56 |
|
|
57 |
!!MCMockClassA commentStamp: ''cwp 8/10/2003 16:43'' prior: 0!!
|
|
58 |
This is a mock class. The Monticello tests manipulated it to simulate a developer modifying code in the image.!!
|
|
59 |
'
|
|
60 |
!
|
|
61 |
|
|
62 |
expectedClassDefinitionB
|
|
63 |
^ '
|
|
64 |
MCMock subclass: #MCMockClassB
|
|
65 |
instanceVariableNames: ''ivarb''
|
|
66 |
classVariableNames: ''CVar''
|
|
67 |
poolDictionaries: ''MCMockAPoolDictionary''
|
|
68 |
category: ''Monticello-Mocks''!!
|
|
69 |
|
|
70 |
MCMockClassB class
|
|
71 |
instanceVariableNames: ''ciVar''!!
|
|
72 |
|
|
73 |
!!MCMockClassB commentStamp: '''' prior: 0!!
|
|
74 |
This comment has a bang!!!! Bang!!!! Bang!!!!!!
|
|
75 |
'
|
|
76 |
!
|
|
77 |
|
|
78 |
expectedClassMethodDefinition
|
|
79 |
^ '
|
|
80 |
!!MCMockClassA class methodsFor: ''as yet unclassified'' stamp: ''ab 7/7/2003 23:21''!!
|
|
81 |
one
|
|
82 |
|
|
83 |
^ 1!! !!
|
|
84 |
'
|
|
85 |
!
|
|
86 |
|
|
87 |
expectedMethodDefinition
|
|
88 |
^ '
|
|
89 |
!!MCMockClassA methodsFor: ''numeric'' stamp: ''cwp 8/2/2003 17:26''!!
|
|
90 |
one
|
|
91 |
^ 1!! !!
|
|
92 |
'
|
|
93 |
!
|
|
94 |
|
|
95 |
expectedMethodDefinitionWithBangs
|
|
96 |
^ '
|
|
97 |
!!MCStWriterTest methodsFor: ''testing'' stamp: ''cwp 8/9/2003 14:55''!!
|
|
98 |
methodWithBangs
|
|
99 |
^ ''
|
|
100 |
^ ReadStream on:
|
|
101 |
''''MCRevisionInfo packageName: ''''MonticelloCompatibilityTest''''!!!!!!!!
|
|
102 |
MCOrganizationDeclaration categories:
|
|
103 |
#(
|
|
104 |
''''Monticello-Mocks'''')!!!!!!!!
|
|
105 |
|
|
106 |
MCClassDeclaration
|
|
107 |
name: #MCMockClassD
|
|
108 |
superclassName: #Object
|
|
109 |
category: #''''Monticello-Mocks''''
|
|
110 |
instVarNames: #()
|
|
111 |
comment: ''''''''!!!!!!!!
|
|
112 |
|
|
113 |
MCMethodDeclaration className: #MCMockClassD selector: #one category: #''''as yet unclassified'''' timeStamp: ''''cwp 7/8/2003 21:21'''' source:
|
|
114 |
''''one
|
|
115 |
^ 1''''!!!!!!!!
|
|
116 |
''''
|
|
117 |
''
|
|
118 |
!! !!
|
|
119 |
'
|
|
120 |
!
|
|
121 |
|
|
122 |
expectedOrganizationDefinition
|
|
123 |
^ 'SystemOrganization addCategory: ''Monticello-Mocks''!!
|
|
124 |
'
|
|
125 |
! !
|
|
126 |
|
|
127 |
!MCStWriterTest methodsFor:'testing'!
|
|
128 |
|
|
129 |
expectedInitializerA
|
|
130 |
^ 'MCMockClassA initialize'
|
|
131 |
!
|
|
132 |
|
|
133 |
methodWithBangs
|
|
134 |
^ '
|
|
135 |
^ ReadStream on:
|
|
136 |
''MCRevisionInfo packageName: ''MonticelloCompatibilityTest''!!!!
|
|
137 |
MCOrganizationDeclaration categories:
|
|
138 |
#(
|
|
139 |
''Monticello-Mocks'')!!!!
|
|
140 |
|
|
141 |
MCClassDeclaration
|
|
142 |
name: #MCMockClassD
|
|
143 |
superclassName: #Object
|
|
144 |
category: #''Monticello-Mocks''
|
|
145 |
instVarNames: #()
|
|
146 |
comment: ''''!!!!
|
|
147 |
|
|
148 |
MCMethodDeclaration className: #MCMockClassD selector: #one category: #''as yet unclassified'' timeStamp: ''cwp 7/8/2003 21:21'' source:
|
|
149 |
''one
|
|
150 |
^ 1''!!!!
|
|
151 |
''
|
|
152 |
'
|
|
153 |
|
|
154 |
!
|
|
155 |
|
|
156 |
setUp
|
|
157 |
stream := ReadWriteStream on:String new.
|
|
158 |
writer := MCStWriter on:stream.
|
|
159 |
!
|
|
160 |
|
|
161 |
testClassDefinitionA
|
|
162 |
writer visitClassDefinition: (self mockClassA asClassDefinition).
|
|
163 |
self assertContentsOf: stream match: self expectedClassDefinitionA.
|
|
164 |
stream reset.
|
|
165 |
2 timesRepeat: [self assertChunkIsWellFormed: stream nextChunk]
|
|
166 |
!
|
|
167 |
|
|
168 |
testClassDefinitionB
|
|
169 |
writer visitClassDefinition: (self mockClassB asClassDefinition).
|
|
170 |
self assertContentsOf: stream match: self expectedClassDefinitionB.
|
|
171 |
|
|
172 |
!
|
|
173 |
|
|
174 |
testClassMethodDefinition
|
|
175 |
writer visitMethodDefinition: (MethodReference class: self mockClassA class selector: #one) asMethodDefinition.
|
|
176 |
self assertContentsOf: stream match: self expectedClassMethodDefinition.
|
|
177 |
stream reset.
|
|
178 |
self assert: stream nextChunk isAllSeparators.
|
|
179 |
self assertChunkIsWellFormed: stream nextChunk.
|
|
180 |
self assertMethodChunkIsWellFormed: stream nextChunk.
|
|
181 |
self assert: stream nextChunk isAllSeparators
|
|
182 |
!
|
|
183 |
|
|
184 |
testInitializerDefinition
|
|
185 |
|chunk lastChunk|
|
|
186 |
writer writeSnapshot: self mockSnapshot.
|
|
187 |
stream reset.
|
|
188 |
[stream atEnd] whileFalse:
|
|
189 |
[chunk := stream nextChunk.
|
|
190 |
chunk isAllSeparators ifFalse: [lastChunk := chunk]].
|
|
191 |
self assertContentsOf: lastChunk readStream match: self expectedInitializerA
|
|
192 |
!
|
|
193 |
|
|
194 |
testMethodDefinition
|
|
195 |
writer visitMethodDefinition: (MethodReference class: self mockClassA selector: #one) asMethodDefinition.
|
|
196 |
self assertContentsOf: stream match: self expectedMethodDefinition.
|
|
197 |
stream reset.
|
|
198 |
self assert: stream nextChunk isAllSeparators.
|
|
199 |
self assertChunkIsWellFormed: stream nextChunk.
|
|
200 |
self assertMethodChunkIsWellFormed: stream nextChunk.
|
|
201 |
self assert: stream nextChunk isAllSeparators
|
|
202 |
!
|
|
203 |
|
|
204 |
testMethodDefinitionWithBangs
|
|
205 |
writer visitMethodDefinition: (MethodReference
|
|
206 |
class: self class
|
|
207 |
selector: #methodWithBangs) asMethodDefinition.
|
|
208 |
self assertContentsOf: stream match: self expectedMethodDefinitionWithBangs.
|
|
209 |
stream reset.
|
|
210 |
self assert: stream nextChunk isAllSeparators.
|
|
211 |
self assertChunkIsWellFormed: stream nextChunk.
|
|
212 |
self assertMethodChunkIsWellFormed: stream nextChunk.
|
|
213 |
self assert: stream nextChunk isAllSeparators
|
|
214 |
!
|
|
215 |
|
|
216 |
testOrganizationDefinition
|
|
217 |
| definition |
|
|
218 |
definition := MCOrganizationDefinition categories:
|
|
219 |
(self mockPackage packageInfo systemCategories).
|
|
220 |
writer visitOrganizationDefinition: definition.
|
|
221 |
self assertContentsOf: stream match: self expectedOrganizationDefinition.
|
|
222 |
self assertAllChunksAreWellFormed.
|
|
223 |
! !
|
|
224 |
|
|
225 |
!MCStWriterTest class methodsFor:'documentation'!
|
|
226 |
|
|
227 |
version
|
|
228 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStWriterTest.st,v 1.1 2011-08-20 12:22:16 cg Exp $'
|
|
229 |
!
|
|
230 |
|
|
231 |
version_CVS
|
|
232 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCStWriterTest.st,v 1.1 2011-08-20 12:22:16 cg Exp $'
|
|
233 |
!
|
|
234 |
|
|
235 |
version_SVN
|
|
236 |
^ '§Id: MCStWriterTest.st 7 2010-09-12 07:18:55Z vranyj1 §'
|
|
237 |
! !
|