blob: dcf4e0903022b4cf2565873849b3aded6a7cf049 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
# -*- tcl -*-
#
# notify.test --
#
# This file tests several functions in the file, 'generic/tclNotify.c'.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 2003 by Kevin B. Kenny. All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: notify.test,v 1.1 2003/02/15 20:24:11 kennykb Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
testConstraint testevent [llength [info commands testevent]]
test notify-1.1 {Tcl_QueueEvent and delivery of a single event} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
vwait done
set delivered
} \
-result {one}
test notify-1.2 {Tcl_QueueEvent and delivery of events in order} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent queue three tail {lappend delivered three; expr 1}
vwait done
set delivered
} \
-result {one two three}
test notify-1.3 {Tcl_QueueEvent at head} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one head {lappend delivered one; expr 1}
vwait done
set delivered
} \
-result one
test notify-1.4 {Tcl_QueueEvent multiple events at head} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one head {lappend delivered one; expr 1}
testevent queue two head {lappend delivered two; expr 1}
testevent queue three head {lappend delivered three; expr 1}
vwait done
set delivered
} \
-result {three two one}
test notify-1.5 {Tcl_QueueEvent marker event into an empty queue} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
vwait done
set delivered
} \
-result one
test notify-1.6 {Tcl_QueueEvent first marker event in a nonempty queue} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
testevent queue three head {lappend delivered three; expr 1}
vwait done
set delivered
} \
-result {three two one}
test notify-1.7 {Tcl_QueueEvent second marker event} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
vwait done
set delivered
} \
-result {one two}
test notify-1.8 {Tcl_QueueEvent preexisting event following second marker} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent queue three mark {lappend delivered three; expr 1}
vwait done
set delivered
} \
-result {one three two}
test notify-2.1 {remove sole element, don't replace } \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent delete one
vwait done
set delivered
} \
-result {}
test notify-2.2 {remove and replace sole element} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent delete one
testevent queue two tail {lappend delivered two; expr 1}
vwait done
set delivered
} \
-result two
test notify-2.3 {remove first element} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent delete one
vwait done
set delivered
} \
-result {two}
test notify-2.4 {remove and replace first element} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent delete one
testevent queue three head {lappend delivered three; expr 1};
vwait done
set delivered
} \
-result {three two}
test notify-2.5 {remove last element} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent delete two
vwait done
set delivered
} \
-result {one}
test notify-2.6 {remove and replace last element} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent delete two
testevent queue three tail {lappend delivered three; expr 1};
vwait done
set delivered
} \
-result {one three}
test notify-2.7 {remove a middle element} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one tail {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent queue three tail {lappend delivered three; expr 1}
testevent delete two
vwait done
set delivered
} \
-result {one three}
test notify-2.8 {remove a marker event that's the sole event in the queue} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent delete one
vwait done
set delivered
} \
-result {}
test notify-2.9 {remove and replace a marker event that's the sole event} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent delete one
testevent queue two mark {lappend delivered two; expr 1}
vwait done
set delivered
} \
-result two
test notify-2.10 {remove marker event from head} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
testevent delete one
vwait done
set delivered
} \
-result two
test notify-2.11 {remove and replace marker event at head} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two tail {lappend delivered two; expr 1}
testevent delete one
testevent queue three mark {lappend delivered three; expr 1}
vwait done
set delivered
} \
-result {three two}
test notify-2.12 {remove marker event at tail} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
testevent delete two
vwait done
set delivered
} \
-result {one}
test notify-2.13 {remove and replace marker event at tail} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
testevent delete two
testevent queue three mark {lappend delivered three; expr 1}
vwait done
set delivered
} \
-result {one three}
test notify-2.14 {remove marker event from middle} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
testevent queue three mark {lappend delivered three; expr 1}
testevent delete two
vwait done
set delivered
} \
-result {one three}
test notify-2.15 {remove and replace marker event at middle} \
-constraints {testevent} \
-body {
set delivered {}
after 10 set done 1
testevent queue one mark {lappend delivered one; expr 1}
testevent queue two mark {lappend delivered two; expr 1}
testevent queue three tail {lappend delivered three; expr 1}
testevent delete two
testevent queue four mark {lappend delivered four; expr 1};
vwait done
set delivered
} \
-result {one four three}
# cleanup
::tcltest::cleanupTests
return
|