1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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
|
-
+
+
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
|
# Commands covered: info
#
# 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) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994-1995 Sun Microsystems, Inc.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: info.test,v 1.5 1998/11/11 02:39:56 welch Exp $
# RCS: @(#) $Id: info.test,v 1.6 1999/04/16 00:47:29 stanton Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
source [file join [pwd] [file dirname [info script]] defs.tcl]
}
if {[string compare test [info procs test]] == 1} then {source defs}
# Set up namespaces needed to test operation of "info args", "info body",
# "info default", and "info procs" with imported procedures.
catch {namespace delete test_ns_info1 test_ns_info2}
namespace eval test_ns_info1 {
namespace export *
proc p {x} {return "x=$x"}
proc q {{y 27} z} {return "y=$y"}
}
test info-1.1 {info args option} {
proc t1 {a bbb c} {return foo}
info args t1
} {a bbb c}
test info-1.2 {info args option} {
proc t1 {{a default1} {bbb default2} {c default3} args} {return foo}
|
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
|
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
|
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
catch {rename _t1_ {}}
catch {rename _t2_ {}}
test info-4.5 {info commands option} {
list [catch {info commands a b} msg] $msg
} {1 {wrong # args: should be "info commands ?pattern?"}}
test info-5.1 {info complete option} {
list [catch {info complete} msg] $msg
} {1 {wrong # args: should be "info complete command"}}
test info-5.2 {info complete option} {
info complete ""
info complete abc
} 1
test info-5.2 {info complete option} {
info complete " \n"
} 1
info complete "\{abcd "
} 0
test info-5.3 {info complete option} {
info complete "abc def"
} 1
test info-5.4 {info complete option} {
info complete "a b c d e f \t\n"
} 1
test info-5.5 {info complete option} {
info complete {a b c"d}
} 1
test info-5.6 {info complete option} {
info complete {a b "c d" e}
} 1
test info-5.7 {info complete option} {
info complete {a b "c d"}
} 1
test info-5.8 {info complete option} {
info complete {a b "c d"}
} 1
test info-5.9 {info complete option} {
info complete {a b "c d}
} 0
test info-5.10 {info complete option} {
info complete {a b "}
info complete {# Comment should be complete command}
} 0
test info-5.11 {info complete option} {
info complete {a b "cd"xyz}
} 1
test info-5.12 {info complete option} {
info complete {a b "c $d() d"}
} 1
test info-5.13 {info complete option} {
info complete {a b "c $dd("}
} 0
test info-5.14 {info complete option} {
info complete {a b "c \"}
} 0
test info-5.15 {info complete option} {
info complete {a b "c [d e f]"}
} 1
test info-5.16 {info complete option} {
info complete {a b "c [d e f] g"}
} 1
test info-5.17 {info complete option} {
info complete {a b "c [d e f"}
} 0
test info-5.18 {info complete option} {
info complete {a {b c d} e}
} 1
test info-5.19 {info complete option} {
info complete {a {b c d}}
} 1
test info-5.20 {info complete option} {
info complete "a b\{c d"
} 1
test info-5.21 {info complete option} {
info complete "a b \{c"
} 0
test info-5.22 {info complete option} {
info complete "a b \{c{ }"
} 0
test info-5.23 {info complete option} {
info complete "a b {c d e}xxx"
} 1
test info-5.24 {info complete option} {
info complete "a b {c \\\{d e}xxx"
} 1
test info-5.25 {info complete option} {
info complete {a b [ab cd ef]}
} 1
test info-5.26 {info complete option} {
info complete {a b x[ab][cd][ef] gh}
} 1
test info-5.27 {info complete option} {
info complete {a b x[ab][cd[ef] gh}
} 0
test info-5.28 {info complete option} {
info complete {a b x[ gh}
} 0
test info-5.29 {info complete option} {
info complete {[]]]}
} 1
test info-5.30 {info complete option} {
info complete {abc x$yyy}
} 1
test info-5.31 {info complete option} {
info complete "abc x\${abc\[\\d} xyz"
} 1
test info-5.32 {info complete option} {
info complete "abc x\$\{ xyz"
} 0
test info-5.33 {info complete option} {
info complete {word $a(xyz)}
} 1
test info-5.34 {info complete option} {
info complete {word $a(}
} 0
test info-5.35 {info complete option} {
info complete "set a \\\n"
} 0
test info-5.36 {info complete option} {
info complete "set a \\n "
} 1
test info-5.37 {info complete option} {
info complete "set a \\"
} 1
test info-5.38 {info complete option} {
info complete "foo \\\n\{"
} 0
test info-5.39 {info complete option} {
info complete " # \{"
} 1
test info-5.40 {info complete option} {
info complete "foo bar;# \{"
} 1
test info-5.41 {info complete option} {
info complete "a\nb\n# \{\n# \{\nc\n"
} 1
test info-5.42 {info complete option} {
info complete "#Incomplete comment\\\n"
} 0
test info-5.43 {info complete option} {
info complete "#Incomplete comment\\\nBut now it's complete.\n"
} 1
test info-5.44 {info complete option} {
info complete "# Complete comment\\\\\n"
} 1
test info-5.45 {info complete option} {
info complete "abc\\\n def"
} 1
test info-5.46 {info complete option} {
info complete "abc\\\n "
} 1
test info-5.47 {info complete option} {
info complete "abc\\\n"
} 0
test info-5.48 {info complete option} {
info complete "set x [binary format H 00]; puts hi"
} 1
test info-5.49 {info complete option} {
info complete "set x [binary format H 00]; \{"
} 0
test info-6.1 {info default option} {
proc t1 {a b {c d} {e "long default value"}} {}
info default t1 a value
} 0
test info-6.2 {info default option} {
proc t1 {a b {c d} {e "long default value"}} {}
|
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
|
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
|
lsort [info pr _tt*]
} {_tt1 _tt2}
catch {rename _tt1 {}}
catch {rename _tt2 {}}
test info-15.3 {info procs option} {
list [catch {info procs 2 3} msg] $msg
} {1 {wrong # args: should be "info procs ?pattern?"}}
set self info.test
if {$tcl_platform(os) == "Win32s"} {
set self info~1.tes
}
test info-15.4 {info procs option} {
catch {namespace delete test_ns_info2}
namespace eval test_ns_info2 {
namespace import ::test_ns_info1::*
proc r {} {}
list [info procs] [info procs p*]
}
} {{p q r} p}
test info-16.1 {info script option} {
list [catch {info script x} msg] $msg
} {1 {wrong # args: should be "info script"}}
test info-16.2 {info script option} {
file tail [info sc]
} $self
} "info.test"
removeFile gorp.info
makeFile "info script\n" gorp.info
test info-16.3 {info script option} {
list [source gorp.info] [file tail [info script]]
} [list gorp.info $self]
} [list gorp.info info.test]
test info-16.4 {resetting "info script" after errors} {
catch {source ~_nobody_/foo}
file tail [info script]
} $self
} "info.test"
test info-16.5 {resetting "info script" after errors} {
catch {source _nonexistent_}
file tail [info script]
} $self
} "info.test"
removeFile gorp.info
test info-17.1 {info sharedlibextension option} {
list [catch {info sharedlibextension foo} msg] $msg
} {1 {wrong # args: should be "info sharedlibextension"}}
test info-18.1 {info tclversion option} {
|
590
591
592
593
594
595
596
|
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
} {1 {ambiguous option "c": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
test info-20.4 {miscellaneous error conditions} {
list [catch {info l} msg] $msg
} {1 {ambiguous option "l": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
test info-20.5 {miscellaneous error conditions} {
list [catch {info s} msg] $msg
} {1 {ambiguous option "s": must be args, body, cmdcount, commands, complete, default, exists, globals, hostname, level, library, loaded, locals, nameofexecutable, patchlevel, procs, script, sharedlibextension, tclversion, or vars}}
# cleanup
catch {namespace delete test_ns_info1 test_ns_info2}
::tcltest::cleanupTests
return
|