author | Claus Gittinger <cg@exept.de> |
Tue, 08 May 2018 19:54:33 +0200 | |
changeset 1042 | 3b8c88c55251 |
parent 1031 | ca47eba386e2 |
permissions | -rw-r--r-- |
1031 | 1 |
"{ Encoding: utf8 }" |
2 |
||
9 | 3 |
"{ Package: 'stx:goodies/monticello/test' }" |
4 |
||
1031 | 5 |
"{ NameSpace: Smalltalk }" |
6 |
||
9 | 7 |
TestCase subclass:#MCTestCase |
8 |
instanceVariableNames:'' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
815
dca22fdcd65e
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
158
diff
changeset
|
11 |
category:'SCM-Monticello-Tests' |
9 | 12 |
! |
13 |
||
14 |
||
15 |
!MCTestCase class methodsFor:'as yet unclassified'! |
|
16 |
||
17 |
isAbstract |
|
18 |
^ self = MCTestCase |
|
19 |
! |
|
20 |
||
21 |
resources |
|
22 |
^ Array with: MCSnapshotResource |
|
23 |
! ! |
|
24 |
||
25 |
!MCTestCase methodsFor:'asserting'! |
|
26 |
||
27 |
assertPackage: actual matches: expected |
|
28 |
self assert: actual = expected |
|
29 |
! |
|
30 |
||
31 |
assertSnapshot: actual matches: expected |
|
32 |
| diff | |
|
33 |
diff _ actual patchRelativeToBase: expected. |
|
34 |
self assert: diff isEmpty |
|
35 |
! |
|
36 |
||
37 |
assertVersion: actual matches: expected |
|
38 |
self assertPackage: actual package matches: expected package. |
|
39 |
self assertVersionInfo: actual info matches: expected info. |
|
40 |
self assertSnapshot: actual snapshot matches: expected snapshot. |
|
41 |
! |
|
42 |
||
43 |
assertVersionInfo: actual matches: expected |
|
44 |
self assert: actual name = expected name. |
|
45 |
self assert: actual message = expected message. |
|
46 |
self assert: actual ancestors size = expected ancestors size. |
|
47 |
actual ancestors with: expected ancestors do: [:a :e | self assertVersionInfo: a matches: e] |
|
48 |
||
49 |
! ! |
|
50 |
||
51 |
!MCTestCase methodsFor:'compiling'! |
|
52 |
||
53 |
change: aSelector toReturn: anObject |
|
54 |
self |
|
55 |
compileClass: self mockClassA |
|
56 |
source: aSelector, ' ^ ', anObject printString |
|
57 |
category: 'numeric' |
|
58 |
! |
|
59 |
||
60 |
compileClass: aClass source: source category: category |
|
158
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
61 |
Smalltalk isSmalltalkX ifTrue:[ |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
62 |
Class withoutUpdatingChangesDo:[ |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
63 |
aClass compile: source classified: category |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
64 |
]. |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
65 |
^ self. |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
66 |
]. |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
67 |
aClass compileInobtrusively: source classified: category |
9 | 68 |
! |
69 |
||
70 |
restoreMocks |
|
71 |
self mockSnapshot updatePackage: self mockPackage |
|
72 |
! ! |
|
73 |
||
74 |
!MCTestCase methodsFor:'mocks'! |
|
75 |
||
76 |
commentForClass: name |
|
77 |
^ 'This is a comment for ', name |
|
78 |
! |
|
79 |
||
80 |
commentStampForClass: name |
|
81 |
^ 'tester-', name, ' 1/1/2000 00:00' |
|
82 |
! |
|
83 |
||
84 |
mockCategoryName |
|
85 |
^ 'Monticello-Mocks' |
|
86 |
! |
|
87 |
||
88 |
mockClass: className super: superclassName |
|
89 |
^ MCClassDefinition |
|
90 |
name: className |
|
91 |
superclassName: superclassName |
|
92 |
category: self mockCategoryName |
|
93 |
instVarNames: #() |
|
94 |
classVarNames: #() |
|
95 |
poolDictionaryNames: #() |
|
96 |
classInstVarNames: #() |
|
97 |
type: #normal |
|
98 |
comment: (self commentForClass: className) |
|
99 |
commentStamp: (self commentStampForClass: className) |
|
100 |
! |
|
101 |
||
102 |
mockClassA |
|
103 |
^ Smalltalk at: #MCMockClassA |
|
104 |
! |
|
105 |
||
106 |
mockClassB |
|
107 |
^ Smalltalk at: #MCMockClassB |
|
108 |
! |
|
109 |
||
110 |
mockDependencies |
|
111 |
^ Array with: (MCVersionDependency package: self mockEmptyPackage info: (self mockVersionInfo: 'x')) |
|
112 |
! |
|
113 |
||
114 |
mockEmptyPackage |
|
115 |
^ MCPackage named: (MCEmptyPackageInfo new packageName) |
|
116 |
! |
|
117 |
||
118 |
mockExtensionMethodCategory |
|
119 |
^ MCMockPackageInfo new methodCategoryPrefix. |
|
120 |
! |
|
121 |
||
122 |
mockInstanceA |
|
123 |
^ self mockClassA new |
|
124 |
! |
|
125 |
||
126 |
mockMessageString |
|
127 |
^ 'A version generated for testing purposes.' |
|
128 |
! |
|
129 |
||
130 |
mockMethod: aSymbol class: className source: sourceString meta: aBoolean |
|
131 |
^ MCMethodDefinition |
|
132 |
className: className |
|
133 |
classIsMeta: aBoolean |
|
134 |
selector: aSymbol |
|
135 |
category: 'as yet unclassified' |
|
136 |
timeStamp: '' |
|
137 |
source: sourceString |
|
138 |
! |
|
139 |
||
140 |
mockOverrideMethodCategory |
|
141 |
^ self mockExtensionMethodCategory, '-override' |
|
142 |
! |
|
143 |
||
144 |
mockPackage |
|
145 |
^ MCSnapshotResource mockPackage |
|
146 |
! |
|
147 |
||
148 |
mockSnapshot |
|
149 |
^ MCSnapshotResource current snapshot |
|
150 |
! |
|
151 |
||
152 |
mockToken: aSymbol |
|
153 |
^ MCMockDefinition token: aSymbol |
|
154 |
! |
|
155 |
||
156 |
mockVersion |
|
157 |
^ MCVersion |
|
158 |
package: self mockPackage |
|
159 |
info: self mockVersionInfo |
|
160 |
snapshot: self mockSnapshot |
|
161 |
! |
|
162 |
||
163 |
mockVersionInfo |
|
164 |
^ self treeFrom: #(d ((b ((a))) (c))) |
|
165 |
! |
|
166 |
||
167 |
mockVersionInfo: tag |
|
1031 | 168 |
^ MCVersionInfo |
169 |
name: self mockVersionName, '-', tag asString |
|
170 |
id: UUID new |
|
171 |
message: self mockMessageString, '-', tag asString |
|
172 |
date: Date today |
|
173 |
time: Time now |
|
174 |
author: Author fullName "Utilities authorInitials" |
|
175 |
ancestors: #() |
|
9 | 176 |
! |
177 |
||
178 |
mockVersionInfoWithAncestor: aVersionInfo |
|
1031 | 179 |
^ MCVersionInfo |
180 |
name: aVersionInfo name, '-child' |
|
181 |
id: UUID new |
|
182 |
message: self mockMessageString |
|
183 |
date: Date today |
|
184 |
time: Time now |
|
185 |
author: Author fullName "Utilities authorInitials" |
|
186 |
ancestors: {aVersionInfo} |
|
9 | 187 |
! |
188 |
||
189 |
mockVersionName |
|
190 |
^ 'MonticelloTest-xxx.1' |
|
191 |
! |
|
192 |
||
193 |
mockVersionWithAncestor: aMCVersion |
|
194 |
^ MCVersion |
|
195 |
package: self mockPackage |
|
196 |
info: (self mockVersionInfoWithAncestor: aMCVersion info) |
|
197 |
snapshot: self mockSnapshot |
|
198 |
! |
|
199 |
||
200 |
mockVersionWithDependencies |
|
201 |
^ MCVersion |
|
202 |
package: self mockPackage |
|
203 |
info: self mockVersionInfo |
|
204 |
snapshot: self mockSnapshot |
|
205 |
dependencies: self mockDependencies |
|
206 |
! |
|
207 |
||
208 |
treeFrom: anArray |
|
209 |
| name id | |
|
210 |
name _ anArray first. |
|
211 |
id _ '00000000-0000-0000-0000-0000000000', (name asString size = 1 ifTrue: [name asString, '0'] ifFalse: [name asString]). |
|
212 |
^ MCVersionInfo |
|
213 |
name: name |
|
214 |
id: (UUID fromString: id) |
|
215 |
message: '' |
|
216 |
date: nil |
|
217 |
time: nil |
|
218 |
author: '' |
|
219 |
ancestors: (anArray size > 1 ifTrue: [(anArray second collect: [:ea | self treeFrom: ea])] ifFalse: [#()]) |
|
220 |
! ! |
|
221 |
||
222 |
!MCTestCase class methodsFor:'documentation'! |
|
223 |
||
224 |
version |
|
1031 | 225 |
^ '$Header$' |
158
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
226 |
! |
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
227 |
|
cd52180a6e57
changed: #compileClass:source:category:
Claus Gittinger <cg@exept.de>
parents:
9
diff
changeset
|
228 |
version_CVS |
1031 | 229 |
^ '$Header$' |
9 | 230 |
! ! |
815
dca22fdcd65e
Tests moved to category SCM-Monticello-Tests
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
158
diff
changeset
|
231 |