blob: 80ac2307947dcf06daf7ca5f7af4c28ff55029da (
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
# Commands covered: treectrl's widget command notify
#
# This file contains a collection of tests for the notify widget command of
# the tktreectrl extension. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 2000 by Scriptics Corporation.
# Copyright (c) 2002 by Christian Krone.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# CVS: @(#) $Id: notify-old.test,v 1.2 2005/05/11 03:31:59 treectrl Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
namespace import ::tcltest::*
}
package require Tk
package require treectrl
test notify-0.1 {some needed preparations} -body {
treectrl .t
} -result {.t}
test notify-1.1 {notify: missing args} -body {
.t notify
} -returnCodes error -result {wrong # args: should be ".t notify command ?arg arg...?"}
test notify-1.2 {notify: unknown command} -body {
.t notify foo
} -returnCodes error -result {bad command "foo": must be *} -match glob
test notify-2.1 {notify eventnames: too much args} -body {
.t notify eventnames Open
} -returnCodes error -result {wrong # args: should be ".t notify eventnames"}
test notify-2.2 {notify eventnames: nothing own installed yet} -body {
lsort [.t notify eventnames]
} -result {ActiveItem Collapse Expand ItemDelete Scroll Selection}
test notify-2.3 {notify install: missing args} -body {
.t notify install
} -returnCodes error -result {wrong # args: should be ".t notify install pattern ?percentsCommand?"}
test notify-2.4 {notify install: bad pattern} -body {
.t notify install foo
} -returnCodes error -result {missing "<" in event pattern "foo"}
test notify-2.5 {notify install event: old-style missing args} -body {
.t notify install event
} -returnCodes error -result {wrong # args: should be ".t notify install event name ?percentsCommand?"}
test notify-2.6 {notify install event: old-style too much args} -body {
.t notify install event foo bar baz
} -returnCodes error -result {wrong # args: should be ".t notify install event name ?percentsCommand?"}
test notify-2.7 {notify install event} -body {
.t notify install event Greetings
.t notify install event GoodBye
} -result {}
test notify-2.8 {notify eventnames: list Greetings} -body {
lsort [.t notify eventnames]
} -result {ActiveItem Collapse Expand GoodBye Greetings ItemDelete Scroll Selection}
test notify-2.9 {notify detailnames: missing args} -body {
.t notify detailnames
} -returnCodes error -result {wrong # args: should be ".t notify detailnames eventName"}
test notify-2.10 {notify detailnames: too many args} -body {
.t notify detailnames foo bar
} -returnCodes error -result {wrong # args: should be ".t notify detailnames eventName"}
test notify-2.11 {notify detailnames: unknown event} -body {
.t notify detailnames Hello
} -returnCodes error -result {unknown event "Hello"}
test notify-2.12 {notify detailnames: no details yet} -body {
.t notify detailnames Greetings
} -result {}
test notify-2.13 {notify install detail: old-style missing args} -body {
.t notify install detail
} -returnCodes error -result {wrong # args: should be ".t notify install detail event detail ?percentsCommand?"}
test notify-2.14 {notify install detail: old-style unknown event} -body {
.t notify install detail Hello GoodBye
} -returnCodes error -result {unknown event "Hello"}
test notify-2.15 {notify install detail} -body {
.t notify install detail Greetings Wrote
.t notify install detail Greetings Sent
} -result {}
test notify-2.16 {notify detailnames} -body {
lsort [.t notify detailnames Greetings]
} -result {Sent Wrote}
test notify-3.1 {notify linkage: missing args} -body {
.t notify linkage
} -returnCodes error -result {wrong # args: should be ".t notify linkage pattern"}
test notify-3.2 {notify linkage: unknown event} -body {
.t notify linkage foo
} -returnCodes error -result {unknown event "foo"}
test notify-3.3 {notify linkage: standard event} -body {
.t notify linkage Scroll
} -result {static}
test notify-3.4 {notify linkage: self made event} -body {
.t notify linkage Greetings
} -result {dynamic}
test notify-3.5 {notify linkage: unknown detail} -body {
.t notify linkage Greetings foo
} -returnCodes error -result {unknown detail "foo" for event "Greetings"}
test notify-3.6 {notify linkage: standard event} -body {
.t notify linkage Scroll x
} -result {static}
test notify-3.7 {notify linkage: self made event} -body {
.t notify linkage Greetings Sent
} -result {dynamic}
test notify-4.1 {notify bind: too much args} -body {
.t notify bind z y z z y
} -returnCodes error -result {wrong # args: should be ".t notify bind ?object? ?pattern? ?script?"}
test notify-4.2 {notify bind: nothing bound yet} -body {
.t notify bind .t
} -result {}
test notify-4.3 {notify bind: invalid pattern} -body {
.t notify bind .t Greetings
} -returnCodes error -result {missing "<" in event pattern "Greetings"}
test notify-4.4 {notify bind: unknown event} -body {
.t notify bind .t <Hello>
} -returnCodes error -result {unknown event "Hello"}
test notify-4.5 {notify bind: unknown detail} -body {
.t notify bind .t <Greetings-Prepare>
} -returnCodes error -result {unknown detail "Prepare" for event "Greetings"}
test notify-4.6 {notify bind: nothing yet for simple event} -body {
.t notify bind .t <Greetings>
} -result {}
test notify-4.7 {notify bind: simple event} -body {
.t notify bind .t <GoodBye> {puts -nonewline "Bye bye"}
} -result {}
test notify-4.8 {notify bind: simple event, script added} -body {
.t notify bind .t <GoodBye> {+puts ""}
} -result {}
test notify-4.9 {notify bind: simple event defined} -body {
.t notify bind .t <GoodBye>
} -result {puts -nonewline "Bye bye"
puts ""}
test notify-4.10 {notify bind: nothing yet for event with detail} -body {
.t notify bind .t <Greetings-Sent>
} -result {}
test notify-4.11 {notify bind: event with detail} -body {
.t notify bind .t <Greetings-Wrote> {puts -nonewline "Hello World"}
.t notify bind .t <Greetings-Sent> {puts ""}
} -result {}
test notify-4.12 {notify bind: event with detail defined} -body {
.t notify bind .t <Greetings-Sent>
} -result {puts ""}
test notify-4.13 {notify bind without pattern} -body {
lsort [.t notify bind .t]
} -result {<GoodBye> <Greetings-Sent> <Greetings-Wrote>}
test notify-5.1 {notify configure: missing args} -body {
.t notify configure
} -returnCodes error -result {wrong # args: should be ".t notify configure object pattern ?option? ?value? ?option value ...?"}
test notify-5.2 {notify configure: unknown event} -body {
.t notify configure .t <Hello>
} -returnCodes error -result {unknown event "Hello"}
test notify-5.3 {notify configure: unknown event with detail} -body {
.t notify configure .t <Hello-World>
} -returnCodes error -result {unknown event "Hello"}
test notify-5.4 {notify configure: unbound event} -body {
.t notify configure .t <Scroll>
} -result {}
test notify-5.5 {notify configure: unbound event with details} -body {
.t notify configure .t <Scroll-x>
} -result {}
test notify-5.6 {notify configure: dynamic event} -body {
.t notify configure .t <Greetings-Sent>
} -result {-active 1}
test notify-5.7 {notify configure: dynamic event} -body {
.t notify configure .t <Greetings-Sent> -active 0
.t notify configure .t <Greetings-Sent>
} -result {-active 0}
test notify-6.1 {notify generate: missing args} -body {
.t notify generate
} -returnCodes error -result {wrong # args: should be ".t notify generate pattern ?charMap? ?percentsCommand?"}
test notify-6.2 {notify generate: invalid event} -body {
.t notify generate Greetings
} -returnCodes error -result {missing "<" in event pattern "Greetings"}
test notify-6.3 {notify generate: virtual event} -body {
.t notify generate <<Greetings>>
} -returnCodes error -result {unknown event "<Greetings>"}
test notify-6.4 {notify generate: unknown event} -body {
.t notify generate <Hello>
} -returnCodes error -result {unknown event "Hello"}
test notify-6.5 {notify generate: unknown detail} -body {
.t notify generate <Greetings-Prepare>
} -returnCodes error -result {unknown detail "Prepare" for event "Greetings"}
test notify-6.6 {notify generate: missing detail} -body {
.t notify generate <Greetings>
} -returnCodes error -result {cannot generate "<Greetings>": missing detail}
test notify-6.7 {notify generate: NOW!} -body {
.t notify generate <Greetings-Wrote>
} -output {Hello World}
test notify-6.8 {notify generate: not active} -body {
.t notify generate <Greetings-Sent>
} -result {}
test notify-6.9 {notify generate: and AGAIN!} -body {
.t notify configure .t <Greetings-Sent> -active 1
.t notify generate <Greetings-Sent>
} -output {
}
test notify-6.10 {notify generate: invalid percent char} -body {
.t notify generate <Greetings-Sent> {foo bar}
} -returnCodes error -result {invalid percent char "foo"}
test notify-6.11 {notify generate: odd number of field args} -body {
.t notify generate <Greetings-Sent> f
} -returnCodes error -result {char map must have even number of elements}
test notify-6.12 {notify generate: huge number of field args} -body {
for {set x 1} {$x < 2048} {incr x} {
lappend map f $x
}
.t notify generate <Greetings-Sent> $map
} -output {
}
test notify-6.13 {notify generate: not so much field args} -body {
.t notify generate <Greetings-Sent> \
{0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j X x}
} -output {
}
test notify-6.14 {notify install/bind/generate: do some replacements} -body {
.t notify install event Percent
.t notify install detail Percent Test
.t notify bind .t <Percent-Test> \
{puts -nonewline "%%W: %2 %b %| %~ %2 %b%%"}
.t notify generate <Percent-Test> {2 to b be ~ not | or}
} -output {%W: to be or not to be%}
proc doMyOwnSubst {field window eventName detail args} {
return [string map {2 TO b BE ~ NOT | OR} $field]
}
test notify-6.15 {notify install/bind/generate: my own replacements} -body {
.t notify uninstall detail Percent Test
.t notify install detail Percent Test doMyOwnSubst
.t notify bind .t <Percent-Test> \
{puts -nonewline "%%W: %2 %b %| %~ %2 %b%%"}
.t notify generate <Percent-Test>
} -output {%W: TO BE OR NOT TO BE%}
test notify-6.16 {notify install/bind/generate: standard replacements} -body {
.t notify generate <Percent-Test> {2 to b be ~ not | or}
} -output {%W: TO BE OR NOT TO BE%}
test notify-6.17 {notify install/bind/generate: my own replacements} -body {
.t notify uninstall detail Percent Test
.t notify uninstall event Percent
.t notify install event Percent doMyOwnSubst
.t notify bind .t <Percent> \
{puts -nonewline "%%W: %2 %b %| %~ %2 %b%%"}
.t notify generate <Percent>
} -output {%W: TO BE OR NOT TO BE%}
test notify-6.18 {notify install/bind/generate: standard replacements} -body {
.t notify generate <Percent> {2 to b be ~ not | or}
} -output {%W: TO BE OR NOT TO BE%}
test notify-7.1 {notify uninstall: missing args} -body {
.t notify uninstall
} -returnCodes error -result {wrong # args: should be ".t notify uninstall pattern"}
test notify-7.2 {notify uninstall: unknown command} -body {
.t notify uninstall foo
} -returnCodes error -result {missing "<" in event pattern "foo"}
test notify-7.3 {notify uninstall detail: missing args} -body {
.t notify uninstall detail
} -returnCodes error -result {wrong # args: should be ".t notify uninstall detail event detail"}
test notify-7.4 {notify uninstall detail: too much args} -body {
.t notify uninstall detail foo bar baz
} -returnCodes error -result {wrong # args: should be ".t notify uninstall detail event detail"}
test notify-7.5 {notify uninstall detail: unknown event} -body {
.t notify uninstall detail foo bar
} -returnCodes error -result {unknown event "foo"}
test notify-7.6 {notify uninstall detail: unknown detail} -body {
.t notify uninstall detail Greetings GoodBye
} -returnCodes error -result {unknown detail "GoodBye" for event "Greetings"}
test notify-7.7 {notify uninstall detail} -body {
.t notify uninstall detail Greetings Sent
} -result {}
test notify-7.8 {notify uninstall detail: double check} -body {
lsearch -exact [.t notify detailnames Greetings] Sent
} -result {-1}
test notify-7.9 {notify uninstall detail: delete a static detail} -body {
.t notify uninstall detail Scroll x
} -returnCodes error -result {can't uninstall static detail "x"}
test notify-7.10 {notify uninstall event: missing args} -body {
.t notify uninstall event
} -returnCodes error -result {wrong # args: should be ".t notify uninstall event name"}
test notify-7.11 {notify uninstall event: too much args} -body {
.t notify uninstall event foo bar
} -returnCodes error -result {wrong # args: should be ".t notify uninstall event name"}
test notify-7.12 {notify uninstall event: unknown event} -body {
.t notify uninstall event foo
} -returnCodes error -result {unknown event "foo"}
test notify-7.13 {notify uninstall event} -body {
.t notify uninstall event Greetings
} -result {}
test notify-7.14 {notify uninstall event: double check} -body {
lsearch -exact [.t notify eventnames] Greetings
} -result {-1}
test notify-7.15 {notify uninstall event: delete a static event} -body {
.t notify uninstall event Scroll
} -returnCodes error -result {can't uninstall static event "Scroll"}
test notify-99.1 {some needed cleanup} -body {
destroy .t
} -result {}
# cleanup
::tcltest::cleanupTests
return
|