2499
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libcomp' }"
|
|
13 |
|
|
14 |
TestCase subclass:#ByteCodeCompilerWithBreakpointSupportTests
|
|
15 |
instanceVariableNames:'breakpoints method'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-Compiler-Debugging'
|
|
19 |
!
|
|
20 |
|
|
21 |
!ByteCodeCompilerWithBreakpointSupportTests class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
! !
|
|
36 |
|
|
37 |
!ByteCodeCompilerWithBreakpointSupportTests methodsFor:'accessing'!
|
|
38 |
|
|
39 |
breakpoints
|
|
40 |
^ breakpoints
|
|
41 |
! !
|
|
42 |
|
|
43 |
!ByteCodeCompilerWithBreakpointSupportTests methodsFor:'running'!
|
|
44 |
|
|
45 |
tearDown
|
|
46 |
|
|
47 |
self class removeSelector: #foo.
|
|
48 |
breakpoints := nil.
|
|
49 |
|
|
50 |
"Created: / 16-06-2011 / 14:58:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
51 |
"Modified: / 17-06-2011 / 09:00:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
52 |
! !
|
|
53 |
|
|
54 |
!ByteCodeCompilerWithBreakpointSupportTests methodsFor:'tests'!
|
|
55 |
|
|
56 |
test_01
|
|
57 |
|
|
58 |
|source|
|
|
59 |
|
|
60 |
source := 'foo ^ #foo'.
|
|
61 |
|
|
62 |
breakpoints := Array with:(Breakpoint new position:4).
|
|
63 |
|
|
64 |
self compile:source.
|
|
65 |
|
|
66 |
self should:[ self foo ] raise:HaltInterrupt.
|
|
67 |
|
|
68 |
"Created: / 16-06-2011 / 14:17:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
69 |
"Modified: / 17-06-2011 / 09:03:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2538
|
70 |
"Modified: / 05-07-2011 / 21:08:33 / cg"
|
2499
|
71 |
!
|
|
72 |
|
|
73 |
test_02
|
|
74 |
|
|
75 |
| source |
|
|
76 |
|
|
77 |
source := 'foo | a | a := 1. ^ a + 1'.
|
|
78 |
|
|
79 |
breakpoints := Array with: (Breakpoint new position:19).
|
|
80 |
|
|
81 |
self compile:source.
|
|
82 |
|
|
83 |
self should:[self foo] raise: HaltInterrupt.
|
|
84 |
|
|
85 |
"Created: / 16-06-2011 / 15:23:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
86 |
"Modified: / 17-06-2011 / 09:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
87 |
!
|
|
88 |
|
|
89 |
test_03a
|
|
90 |
|
|
91 |
| source |
|
|
92 |
|
|
93 |
source := 'foo ^ true ifTrue:[ #true ] ifFalse:[ #false ]' .
|
|
94 |
"12345678901234567890123456789012345678901234567890"
|
|
95 |
|
|
96 |
breakpoints := Array with: (Breakpoint new position:20).
|
|
97 |
|
|
98 |
self compile:source.
|
|
99 |
|
|
100 |
self should:[self foo] raise: HaltInterrupt.
|
|
101 |
|
|
102 |
"Created: / 17-06-2011 / 09:05:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
103 |
!
|
|
104 |
|
|
105 |
test_03b
|
|
106 |
|
2538
|
107 |
| source ret |
|
2499
|
108 |
|
|
109 |
source := 'foo ^ true ifTrue:[ #true ] ifFalse:[ #false ]' .
|
|
110 |
"12345678901234567890123456789012345678901234567890"
|
2538
|
111 |
" 1 2 3 4"
|
2499
|
112 |
|
|
113 |
breakpoints := Array with: (Breakpoint new position:28).
|
|
114 |
|
|
115 |
self compile:source.
|
2538
|
116 |
"/ method inspect.
|
2499
|
117 |
|
|
118 |
self shouldnt:[self foo] raise: HaltInterrupt.
|
|
119 |
|
2538
|
120 |
HaltInterrupt ignoreIn:[
|
|
121 |
ret := self foo.
|
|
122 |
].
|
|
123 |
self assert:(ret == #true)
|
|
124 |
|
2499
|
125 |
"Created: / 17-06-2011 / 09:09:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2538
|
126 |
"Modified: / 05-07-2011 / 22:54:08 / cg"
|
|
127 |
!
|
|
128 |
|
|
129 |
test_03c
|
|
130 |
|
|
131 |
| source ret |
|
|
132 |
|
|
133 |
source := 'foo ^ false ifTrue:[ #true ] ifFalse:[ #false ]' .
|
|
134 |
"12345678901234567890123456789012345678901234567890"
|
|
135 |
" 1 2 3 4"
|
|
136 |
|
|
137 |
breakpoints := Array with: (Breakpoint new position:28).
|
|
138 |
|
|
139 |
self compile:source.
|
|
140 |
"/ method inspect.
|
|
141 |
|
|
142 |
self shouldnt:[self foo] raise: HaltInterrupt.
|
|
143 |
|
|
144 |
HaltInterrupt ignoreIn:[
|
|
145 |
ret := self foo.
|
|
146 |
].
|
|
147 |
self assert:(ret == #false)
|
|
148 |
|
|
149 |
"Created: / 17-06-2011 / 09:09:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
150 |
"Created: / 05-07-2011 / 22:54:54 / cg"
|
2499
|
151 |
!
|
|
152 |
|
|
153 |
test_04
|
|
154 |
|
|
155 |
| source block |
|
|
156 |
|
|
157 |
source := 'foo ^ [ #true ]' .
|
|
158 |
"12345678901234567890123456789012345678901234567890"
|
|
159 |
|
|
160 |
breakpoints := Array with: (Breakpoint new position:8).
|
|
161 |
|
|
162 |
self compile:source.
|
|
163 |
|
|
164 |
self shouldnt:[block := self foo] raise: HaltInterrupt.
|
|
165 |
self should:[block value] raise: HaltInterrupt.
|
|
166 |
|
|
167 |
"Created: / 17-06-2011 / 09:10:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
168 |
!
|
|
169 |
|
|
170 |
test_05
|
|
171 |
|
|
172 |
| source got result |
|
|
173 |
|
|
174 |
source := 'foo | a | a := 100. ^a between: a-a and: a+a' .
|
|
175 |
"12345678901234567890123456789012345678901234567890"
|
2538
|
176 |
" 1 2 3 4"
|
2499
|
177 |
|
|
178 |
breakpoints := Array with: (Breakpoint new position:32).
|
|
179 |
|
|
180 |
self compile:source.
|
2538
|
181 |
"/ method inspect.
|
2499
|
182 |
|
|
183 |
got := false.
|
|
184 |
[ result := self foo ]
|
|
185 |
on: HaltInterrupt do:
|
|
186 |
[:halt|
|
|
187 |
got := true.
|
|
188 |
halt proceed].
|
|
189 |
|
|
190 |
self assert: got.
|
|
191 |
self assert: result
|
|
192 |
|
|
193 |
"Created: / 17-06-2011 / 09:14:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2538
|
194 |
"Modified: / 05-07-2011 / 22:20:25 / cg"
|
2499
|
195 |
!
|
|
196 |
|
|
197 |
test_06
|
|
198 |
|
|
199 |
| source nbreaks result |
|
|
200 |
|
|
201 |
source := 'foo |a| 1 to: 10 do:[:x| a := x * x ]. ^a ' .
|
|
202 |
"12345678901234567890123456789012345678901234567890"
|
|
203 |
|
|
204 |
breakpoints := Array with: (Breakpoint new position:30).
|
|
205 |
|
|
206 |
self compile:source.
|
2538
|
207 |
"/ method inspect.
|
2499
|
208 |
|
|
209 |
nbreaks := 0.
|
|
210 |
[ result := self foo ]
|
|
211 |
on: HaltInterrupt do:
|
|
212 |
[:halt|
|
|
213 |
nbreaks := nbreaks + 1.
|
|
214 |
halt proceed].
|
|
215 |
|
|
216 |
self assert: nbreaks == 10.
|
|
217 |
self assert: result == 100
|
|
218 |
|
|
219 |
"Created: / 17-06-2011 / 11:56:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2538
|
220 |
"Modified: / 05-07-2011 / 22:40:31 / cg"
|
2499
|
221 |
! !
|
|
222 |
|
|
223 |
!ByteCodeCompilerWithBreakpointSupportTests methodsFor:'utils'!
|
|
224 |
|
|
225 |
compile:source
|
|
226 |
Class withoutUpdatingChangesDo:[
|
|
227 |
method :=
|
|
228 |
ByteCodeCompilerWithBreakpointSupport
|
|
229 |
compile:source
|
|
230 |
forClass:self class
|
|
231 |
notifying:self
|
|
232 |
].
|
2538
|
233 |
^ method
|
2499
|
234 |
|
|
235 |
"Modified: / 17-06-2011 / 09:15:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2538
|
236 |
"Modified (format): / 05-07-2011 / 21:36:29 / cg"
|
2499
|
237 |
! !
|
|
238 |
|
|
239 |
!ByteCodeCompilerWithBreakpointSupportTests class methodsFor:'documentation'!
|
|
240 |
|
|
241 |
version_CVS
|
2538
|
242 |
^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompilerWithBreakpointSupportTests.st,v 1.2 2011-07-05 21:25:22 cg Exp $'
|
2499
|
243 |
!
|
|
244 |
|
|
245 |
version_SVN
|
2538
|
246 |
^ '§ Id §'
|
2499
|
247 |
! !
|