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 |
|
10046
|
28 |
nil 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>"
|
|
175 |
! !
|
|
176 |
|
|
177 |
!CodeGeneratorTests class methodsFor:'documentation'!
|
|
178 |
|
|
179 |
version_CVS
|
10046
|
180 |
^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTests.st,v 1.2 2011-07-03 13:41:39 cg Exp $'
|
10012
|
181 |
!
|
|
182 |
|
|
183 |
version_SVN
|
|
184 |
^ '§Id: CodeGeneratorTests.st 7728 2011-05-05 23:02:13Z vranyj1 §'
|
|
185 |
! !
|