author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 29 May 2013 02:01:58 +0200 | |
changeset 819 | 9be4aefd595c |
parent 29 | b38afa133bfa |
child 1030 | f0e99547dd4b |
child 1121 | c5661215109c |
permissions | -rw-r--r-- |
29 | 1 |
"{ Package: 'stx:goodies/monticello/test' }" |
2 |
||
3 |
MCTestCase subclass:#MCStWriterTest |
|
4 |
instanceVariableNames:'stream writer' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
819
9be4aefd595c
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
7 |
category:'SCM-Monticello-Tests' |
29 | 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 |
Parser 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 |
Parser 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 |
setUp |
|
156 |
stream _ RWBinaryOrTextStream on: String new. |
|
157 |
writer _ MCStWriter on: stream. |
|
158 |
! |
|
159 |
||
160 |
testClassDefinitionA |
|
161 |
writer visitClassDefinition: (self mockClassA asClassDefinition). |
|
162 |
self assertContentsOf: stream match: self expectedClassDefinitionA. |
|
163 |
stream reset. |
|
164 |
2 timesRepeat: [self assertChunkIsWellFormed: stream nextChunk] |
|
165 |
! |
|
166 |
||
167 |
testClassDefinitionB |
|
168 |
writer visitClassDefinition: (self mockClassB asClassDefinition). |
|
169 |
self assertContentsOf: stream match: self expectedClassDefinitionB. |
|
170 |
||
171 |
! |
|
172 |
||
173 |
testClassMethodDefinition |
|
174 |
writer visitMethodDefinition: (MethodReference class: self mockClassA class selector: #one) asMethodDefinition. |
|
175 |
self assertContentsOf: stream match: self expectedClassMethodDefinition. |
|
176 |
stream reset. |
|
177 |
self assert: stream nextChunk isAllSeparators. |
|
178 |
self assertChunkIsWellFormed: stream nextChunk. |
|
179 |
self assertMethodChunkIsWellFormed: stream nextChunk. |
|
180 |
self assert: stream nextChunk isAllSeparators |
|
181 |
! |
|
182 |
||
183 |
testInitializerDefinition |
|
184 |
|chunk lastChunk| |
|
185 |
writer writeSnapshot: self mockSnapshot. |
|
186 |
stream reset. |
|
187 |
[stream atEnd] whileFalse: |
|
188 |
[chunk _ stream nextChunk. |
|
189 |
chunk isAllSeparators ifFalse: [lastChunk _ chunk]]. |
|
190 |
self assertContentsOf: lastChunk readStream match: self expectedInitializerA |
|
191 |
! |
|
192 |
||
193 |
testMethodDefinition |
|
194 |
writer visitMethodDefinition: (MethodReference class: self mockClassA selector: #one) asMethodDefinition. |
|
195 |
self assertContentsOf: stream match: self expectedMethodDefinition. |
|
196 |
stream reset. |
|
197 |
self assert: stream nextChunk isAllSeparators. |
|
198 |
self assertChunkIsWellFormed: stream nextChunk. |
|
199 |
self assertMethodChunkIsWellFormed: stream nextChunk. |
|
200 |
self assert: stream nextChunk isAllSeparators |
|
201 |
! |
|
202 |
||
203 |
testMethodDefinitionWithBangs |
|
204 |
writer visitMethodDefinition: (MethodReference |
|
205 |
class: self class |
|
206 |
selector: #methodWithBangs) asMethodDefinition. |
|
207 |
self assertContentsOf: stream match: self expectedMethodDefinitionWithBangs. |
|
208 |
stream reset. |
|
209 |
self assert: stream nextChunk isAllSeparators. |
|
210 |
self assertChunkIsWellFormed: stream nextChunk. |
|
211 |
self assertMethodChunkIsWellFormed: stream nextChunk. |
|
212 |
self assert: stream nextChunk isAllSeparators |
|
213 |
! |
|
214 |
||
215 |
testOrganizationDefinition |
|
216 |
| definition | |
|
217 |
definition _ MCOrganizationDefinition categories: |
|
218 |
(self mockPackage packageInfo systemCategories). |
|
219 |
writer visitOrganizationDefinition: definition. |
|
220 |
self assertContentsOf: stream match: self expectedOrganizationDefinition. |
|
221 |
self assertAllChunksAreWellFormed. |
|
222 |
! ! |
|
223 |
||
224 |
!MCStWriterTest class methodsFor:'documentation'! |
|
225 |
||
226 |
version |
|
819
9be4aefd595c
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
227 |
^ '$Header: /cvs/stx/stx/goodies/monticello/test/MCStWriterTest.st,v 1.2 2013-05-29 00:01:58 vrany Exp $' |
29 | 228 |
! ! |
819
9be4aefd595c
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
229 |