author | Claus Gittinger <cg@exept.de> |
Fri, 24 Feb 2017 16:54:59 +0100 | |
changeset 17444 | 4506360ae3c8 |
parent 14422 | 40f9ff83b8aa |
child 15566 | 184cea584be5 |
permissions | -rw-r--r-- |
10012 | 1 |
" |
10046 | 2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
10012 | 4 |
|
10046 | 5 |
Permission is hereby granted, free of charge, to any person |
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
10012 | 25 |
" |
26 |
"{ Package: 'stx:libtool' }" |
|
27 |
||
13802 | 28 |
TestCase subclass:#CodeGeneratorTests |
10012 | 29 |
instanceVariableNames:'cg' |
30 |
classVariableNames:'' |
|
31 |
poolDictionaries:'' |
|
32 |
category:'Interface-Browsers' |
|
33 |
! |
|
34 |
||
35 |
!CodeGeneratorTests class methodsFor:'documentation'! |
|
36 |
||
37 |
copyright |
|
38 |
" |
|
10046 | 39 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, Czech Technical University in Prague |
40 |
Copyright (c) 2009-2010 eXept Software AG |
|
41 |
||
42 |
Permission is hereby granted, free of charge, to any person |
|
43 |
obtaining a copy of this software and associated documentation |
|
44 |
files (the 'Software'), to deal in the Software without |
|
45 |
restriction, including without limitation the rights to use, |
|
46 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
47 |
copies of the Software, and to permit persons to whom the |
|
48 |
Software is furnished to do so, subject to the following |
|
49 |
conditions: |
|
10012 | 50 |
|
10046 | 51 |
The above copyright notice and this permission notice shall be |
52 |
included in all copies or substantial portions of the Software. |
|
53 |
||
54 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
55 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
56 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
57 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
58 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
59 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
60 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
61 |
OTHER DEALINGS IN THE SOFTWARE. |
|
10012 | 62 |
" |
63 |
! ! |
|
64 |
||
65 |
!CodeGeneratorTests methodsFor:'initialization & release'! |
|
66 |
||
67 |
setUp |
|
68 |
||
69 |
cg := CodeGenerator new |
|
70 |
||
71 |
"Created: / 07-07-2009 / 09:26:20 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
72 |
! |
|
73 |
||
74 |
tearDown |
|
75 |
||
76 |
| mocks | |
|
77 |
mocks := Set new. |
|
78 |
self class selectorsDo: |
|
79 |
[:selector| |
|
80 |
(selector startsWith: 'mock') |
|
81 |
ifTrue:[mocks add: selector]]. |
|
82 |
mocks do: |
|
83 |
[:selector| |
|
84 |
self class removeSelector: selector]. |
|
85 |
||
86 |
"Modified: / 07-07-2009 / 09:34:22 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
87 |
! ! |
|
88 |
||
89 |
!CodeGeneratorTests methodsFor:'mocks - do not remove'! |
|
90 |
||
91 |
mmock_03 |
|
92 |
||
93 |
^3 |
|
94 |
||
95 |
"Created: / 07-07-2009 / 19:21:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
96 |
! |
|
97 |
||
98 |
mmock_03: x |
|
99 |
||
100 |
^x |
|
101 |
||
102 |
"Created: / 07-07-2009 / 19:55:10 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
103 |
! ! |
|
104 |
||
105 |
!CodeGeneratorTests methodsFor:'tests'! |
|
106 |
||
107 |
test_01 |
|
108 |
||
109 |
cg |
|
110 |
class: self class; |
|
111 |
replace: '`@e' with: '1'; |
|
112 |
source: 'mock_01 ^ `@e'; |
|
113 |
compile. |
|
114 |
||
115 |
self assert: (self respondsTo: #mock_01). |
|
116 |
self assert: (self mock_01 = 1). |
|
117 |
||
118 |
"Created: / 07-07-2009 / 09:29:56 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
119 |
! |
|
120 |
||
121 |
test_02 |
|
122 |
||
123 |
cg |
|
124 |
class: self class; |
|
125 |
replace: '`@selector' with: #mock_02; |
|
126 |
source: '`@selector ^ 2'; |
|
127 |
compile. |
|
128 |
||
129 |
self assert: (self respondsTo: #mock_02). |
|
130 |
self assert: (self mock_02 = 2). |
|
131 |
||
132 |
"Created: / 07-07-2009 / 19:07:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
133 |
! |
|
134 |
||
135 |
test_02b |
|
136 |
||
137 |
cg |
|
138 |
class: self class; |
|
139 |
replace: '`@selector:' with: #mock_02:; |
|
140 |
source: '`@selector: arg ^ arg'; |
|
141 |
compile. |
|
142 |
||
143 |
self assert: (self respondsTo: #mock_02:). |
|
144 |
self assert: (self mock_02: 20) = 20. |
|
145 |
||
146 |
"Created: / 07-07-2009 / 19:54:03 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
test_03 |
|
150 |
||
151 |
cg |
|
152 |
class: self class; |
|
153 |
replace: '`@selector' with: 'mmock_03'; |
|
154 |
source: 'mock_03 ^ self `@selector'; |
|
155 |
compile. |
|
156 |
||
157 |
self assert: (self respondsTo: #mock_03). |
|
158 |
self assert: (self mock_03 = 3). |
|
159 |
||
160 |
"Created: / 07-07-2009 / 19:22:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
161 |
! |
|
162 |
||
163 |
test_03b |
|
164 |
||
165 |
cg |
|
166 |
class: self class; |
|
167 |
replace: '`@selector:' with: #mmock_03:; |
|
168 |
source: 'mock_03b ^ self `@selector: 30'; |
|
169 |
compile. |
|
170 |
||
171 |
self assert: (self respondsTo: #mock_03b). |
|
172 |
self assert: (self mock_03b = 30). |
|
173 |
||
174 |
"Created: / 07-07-2009 / 19:54:35 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
14281 | 175 |
! |
176 |
||
177 |
test_04a |
|
178 |
||
179 |
cg |
|
180 |
class: self class; |
|
181 |
source: '`@selector ^ 4'; |
|
182 |
replace: '`@selector' with: #mock_04a; |
|
183 |
compile. |
|
184 |
||
185 |
self assert: (self respondsTo: #mock_04a). |
|
186 |
self assert: (self mock_04a = 4). |
|
187 |
||
188 |
"Created: / 24-04-2014 / 11:13:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
189 |
! |
|
190 |
||
191 |
test_04b |
|
192 |
||
193 |
cg |
|
194 |
class: self class; |
|
195 |
source: '`@selpart1 anArg `@selpart2 anArg2 ^ anArg + anArg2'; |
|
196 |
replace: '`@selpart1' with: #mock_04:; |
|
197 |
replace: '`@selpart2' with: #b:; |
|
198 |
compile. |
|
199 |
||
200 |
self assert: (self respondsTo: #mock_04:b:). |
|
201 |
self assert: ((self mock_04:123 b: 123) = (123+123)). |
|
202 |
||
203 |
"Created: / 24-04-2014 / 11:15:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
204 |
! |
|
205 |
||
206 |
test_05 |
|
207 |
||
208 |
cg |
|
209 |
class: self class; |
|
210 |
source: 'mock_05 |
|
211 |
"comment" |
|
212 |
||
213 |
^ 10'; |
|
214 |
compile. |
|
215 |
||
216 |
self assert: (self respondsTo: #mock_05). |
|
217 |
self assert: (self perform: #mock_05) == 10. |
|
14422
40f9ff83b8aa
Fix to preserve comment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14281
diff
changeset
|
218 |
self assert: ((self class >> #mock_05) source includesString: 'comment') |
14281 | 219 |
|
220 |
"Created: / 24-04-2014 / 11:28:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
14422
40f9ff83b8aa
Fix to preserve comment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14281
diff
changeset
|
221 |
"Modified: / 24-05-2014 / 01:02:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10012 | 222 |
! ! |
223 |
||
224 |
!CodeGeneratorTests class methodsFor:'documentation'! |
|
225 |
||
226 |
version_CVS |
|
14422
40f9ff83b8aa
Fix to preserve comment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14281
diff
changeset
|
227 |
^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTests.st,v 1.5 2014-05-24 00:10:50 vrany Exp $' |
10012 | 228 |
! |
229 |
||
230 |
version_SVN |
|
14422
40f9ff83b8aa
Fix to preserve comment.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
14281
diff
changeset
|
231 |
^ '$Id: CodeGeneratorTests.st,v 1.5 2014-05-24 00:10:50 vrany Exp $' |
10012 | 232 |
! ! |
13802 | 233 |