home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume25 / tcl / part13 < prev    next >
Encoding:
Text File  |  1991-11-14  |  36.0 KB  |  1,100 lines

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v25i081:  tcl - tool command language, version 6.1, Part13/33
  4. Message-ID: <1991Nov14.203100.24086@sparky.imd.sterling.com>
  5. X-Md4-Signature: 24e161b8d7f9ba16091e298daafb566f
  6. Date: Thu, 14 Nov 1991 20:31:00 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 25, Issue 81
  11. Archive-name: tcl/part13
  12. Environment: UNIX
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 13 (of 33)."
  21. # Contents:  tcl6.1/tests/open.test tcl6.1/tests/set.test
  22. # Wrapped by karl@one on Tue Nov 12 19:44:22 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'tcl6.1/tests/open.test' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'tcl6.1/tests/open.test'\"
  26. else
  27. echo shar: Extracting \"'tcl6.1/tests/open.test'\" \(16158 characters\)
  28. sed "s/^X//" >'tcl6.1/tests/open.test' <<'END_OF_FILE'
  29. X# Commands covered:  open, close, gets, puts, read, seek, tell, eof, flush
  30. X#
  31. X# This file contains a collection of tests for one or more of the Tcl
  32. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  33. X# generates output for errors.  No output means no errors were found.
  34. X#
  35. X# Copyright 1991 Regents of the University of California
  36. X# Permission to use, copy, modify, and distribute this
  37. X# software and its documentation for any purpose and without
  38. X# fee is hereby granted, provided that this copyright notice
  39. X# appears in all copies.  The University of California makes no
  40. X# representations about the suitability of this software for any
  41. X# purpose.  It is provided "as is" without express or implied
  42. X# warranty.
  43. X#
  44. X# $Header: /sprite/src/lib/tcl/tests/RCS/open.test,v 1.8 91/09/24 16:17:00 ouster Exp $ (Berkeley)
  45. X
  46. Xif {[string compare test [info procs test]] == 1} then {source defs}
  47. X
  48. Xcatch {exec rm -f test1 test2 test3}
  49. Xexec cat > test1 << "Two lines: this one\nand this one\n"
  50. Xexec cat > test2 << "line1\nline2\nline3\nline4\nline5\n"
  51. X
  52. Xtest open-1.1 {open command (files only)} {
  53. X    set f [open test1]
  54. X    set x [gets $f]
  55. X    close $f
  56. X    set x
  57. X} {Two lines: this one}
  58. Xtest open-1.2 {open command (files only)} {
  59. X    set f [open test1]
  60. X    set f2 [open test2]
  61. X    set f3 [open test1]
  62. X    set f4 [open test1]
  63. X    set x [list [gets $f] [gets $f2] [gets $f3] [gets $f4] \
  64. X        [gets $f] [gets $f2]]
  65. X    close $f
  66. X    close $f2
  67. X    close $f3
  68. X    close $f4
  69. X    set x
  70. X} {{Two lines: this one} line1 {Two lines: this one} {Two lines: this one} {and this one} line2}
  71. Xtest open-1.3 {open command (files only)} {
  72. X    set f [open test3 w]
  73. X    puts $f xyz
  74. X    close $f
  75. X    exec cat test3
  76. X} "xyz"
  77. Xtest open-1.4 {open command (files only)} {
  78. X    set f [open test3 w]
  79. X    puts $f xyz
  80. X    close $f
  81. X    set f [open test3 a]
  82. X    puts $f 123
  83. X    close $f
  84. X    exec cat test3
  85. X} "xyz\n123"
  86. Xtest open-1.5 {open command (files only)} {
  87. X    set f [open test3 w]
  88. X    puts $f xyz\n123
  89. X    close $f
  90. X    set f [open test3 r+]
  91. X    set x [gets $f]
  92. X    seek $f 0 current
  93. X    puts $f 456
  94. X    close $f
  95. X    list $x [exec cat test3]
  96. X} "xyz {xyz
  97. X456}"
  98. Xtest open-1.6 {open command (files only)} {
  99. X    set f [open test3 w]
  100. X    puts $f xyz\n123
  101. X    close $f
  102. X    set f [open test3 w+]
  103. X    puts $f xyzzy
  104. X    seek $f 2
  105. X    set x [gets $f]
  106. X    close $f
  107. X    list $x [exec cat test3]
  108. X} "zzy xyzzy"
  109. Xtest open-1.7 {open command (files only)} {
  110. X    set f [open test3 w]
  111. X    puts $f xyz\n123
  112. X    close $f
  113. X    set f [open test3 a+]
  114. X    puts $f xyzzy
  115. X    flush $f
  116. X    set x [tell $f]
  117. X    seek $f -4 cur
  118. X    set y [gets $f]
  119. X    close $f
  120. X    list $x [exec cat test3] $y
  121. X} {14 {xyz
  122. X123
  123. Xxyzzy} zzy}
  124. X
  125. Xtest open-2.1 {errors in open command} {
  126. X    list [catch {open} msg] $msg
  127. X} {1 {wrong # args: should be "open filename ?access?"}}
  128. Xtest open-2.2 {errors in open command} {
  129. X    list [catch {open a b c} msg] $msg
  130. X} {1 {wrong # args: should be "open filename ?access?"}}
  131. Xtest open-2.3 {errors in open command} {
  132. X    list [catch {open test1 x} msg] $msg
  133. X} {1 {illegal access mode "x"}}
  134. Xtest open-2.4 {errors in open command} {
  135. X    list [catch {open test1 rw} msg] $msg
  136. X} {1 {illegal access mode "rw"}}
  137. Xtest open-2.5 {errors in open command} {
  138. X    list [catch {open test1 r+1} msg] $msg
  139. X} {1 {illegal access mode "r+1"}}
  140. Xtest open-2.6 {errors in open command} {
  141. X    string tolower [list [catch {open _non_existent_} msg] $msg $errorCode]
  142. X} {1 {couldn't open "_non_existent_": no such file or directory} {unix enoent {no such file or directory}}}
  143. X
  144. Xif {![file exists ~/_test_] && [file writable ~]} {
  145. X    test open-3.1 {tilde substitution in open} {
  146. X    set f [open ~/_test_ w]
  147. X    puts $f "Some text"
  148. X    close $f
  149. X    set x [file exists $env(HOME)/_test_]
  150. X    exec rm -f $env(HOME)/_test_
  151. X    set x
  152. X    } 1
  153. X}
  154. Xtest open-3.2 {tilde substitution in open} {
  155. X    set home $env(HOME)
  156. X    unset env(HOME)
  157. X    set x [list [catch {open ~/foo} msg] $msg]
  158. X    set env(HOME) $home
  159. X    set x
  160. X} {1 {couldn't find HOME environment variable to expand "~/foo"}}
  161. X
  162. Xtest open-4.1 {file id parsing errors} {
  163. X    list [catch {eof gorp} msg] $msg $errorCode
  164. X} {1 {bad file identifier "gorp"} NONE}
  165. Xtest open-4.2 {file id parsing errors} {
  166. X    list [catch {eof filex} msg] $msg
  167. X} {1 {bad file identifier "filex"}}
  168. Xtest open-4.3 {file id parsing errors} {
  169. X    list [catch {eof file12a} msg] $msg
  170. X} {1 {bad file identifier "file12a"}}
  171. Xtest open-4.4 {file id parsing errors} {
  172. X    list [catch {eof file123} msg] $msg
  173. X} {1 {file "file123" isn't open}}
  174. Xtest open-4.5 {file id parsing errors} {
  175. X    list [catch {eof file1} msg] $msg
  176. X} {0 0}
  177. Xtest open-4.5 {file id parsing errors} {
  178. X    list [catch {eof stdin} msg] $msg
  179. X} {0 0}
  180. Xtest open-4.6 {file id parsing errors} {
  181. X    list [catch {eof stdout} msg] $msg
  182. X} {0 0}
  183. Xtest open-4.7 {file id parsing errors} {
  184. X    list [catch {eof stderr} msg] $msg
  185. X} {0 0}
  186. Xtest open-4.8 {file id parsing errors} {
  187. X    list [catch {eof stderr1} msg] $msg
  188. X} {1 {bad file identifier "stderr1"}}
  189. Xset f [open test1]
  190. Xclose $f
  191. Xset expect "1 {file \"$f\" isn't open}"
  192. Xtest open-4.9 {file id parsing errors} {
  193. X    list [catch {eof $f} msg] $msg
  194. X} $expect
  195. X
  196. Xtest open-5.1 {close command (files only)} {
  197. X    list [catch {close} msg] $msg $errorCode
  198. X} {1 {wrong # args: should be "close fileId"} NONE}
  199. Xtest open-5.2 {close command (files only)} {
  200. X    list [catch {close a b} msg] $msg $errorCode
  201. X} {1 {wrong # args: should be "close fileId"} NONE}
  202. Xtest open-5.3 {close command (files only)} {
  203. X    list [catch {close gorp} msg] $msg $errorCode
  204. X} {1 {bad file identifier "gorp"} NONE}
  205. Xtest open-5.4 {close command (files only)} {
  206. X    list [catch {close file4} msg] \
  207. X        [string range $msg [string first {" } $msg] end] $errorCode
  208. X} {1 {" isn't open} NONE}
  209. X
  210. Xtest open-6.1 {puts command} {
  211. X    list [catch {puts file3} msg] $msg $errorCode
  212. X} {1 {wrong # args: should be "puts fileId string ?nonewline?"} NONE}
  213. Xtest open-6.2 {puts command} {
  214. X    list [catch {puts a b c d} msg] $msg $errorCode
  215. X} {1 {wrong # args: should be "puts fileId string ?nonewline?"} NONE}
  216. Xtest open-6.3 {puts command} {
  217. X    list [catch {puts a b nonewlinx} msg] $msg $errorCode
  218. X} {1 {bad argument "nonewlinx": should be "nonewline"} NONE}
  219. Xtest open-6.4 {puts command} {
  220. X    list [catch {puts gorp "New text"} msg] $msg $errorCode
  221. X} {1 {bad file identifier "gorp"} NONE}
  222. Xtest open-6.5 {puts command} {
  223. X    set f [open test3]
  224. X    set x [list [catch {puts $f "New text"} msg] \
  225. X    [string range $msg [string first " " $msg] end] $errorCode]
  226. X    close $f
  227. X    set x
  228. X} {1 { wasn't opened for writing} NONE}
  229. Xtest open-6.6 {puts command} {
  230. X    set f [open test3 w]
  231. X    puts $f "Text1" n
  232. X    puts $f " Text 2" no
  233. X    puts $f " Text 3"
  234. X    close $f
  235. X    exec cat test3
  236. X} {Text1 Text 2 Text 3}
  237. X
  238. Xtest open-7.1 {gets command} {
  239. X    list [catch {gets} msg] $msg $errorCode
  240. X} {1 {wrong # args: should be "gets fileId ?varName?"} NONE}
  241. Xtest open-7.2 {gets command} {
  242. X    list [catch {gets a b c} msg] $msg $errorCode
  243. X} {1 {wrong # args: should be "gets fileId ?varName?"} NONE}
  244. Xtest open-7.3 {gets command} {
  245. X    list [catch {gets a} msg] $msg $errorCode
  246. X} {1 {bad file identifier "a"} NONE}
  247. Xtest open-7.4 {gets command} {
  248. X    set f [open test3 w]
  249. X    set x [list [catch {gets $f} msg] \
  250. X        [string range $msg [string first " " $msg] end] $errorCode]
  251. X    close $f
  252. X    set x
  253. X} {1 { wasn't opened for reading} NONE}
  254. Xset f [open test3 w]
  255. Xputs $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" nonewline
  256. Xputs $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" nonewline
  257. Xputs $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" nonewline
  258. Xputs $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" nonewline
  259. Xputs $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  260. Xclose $f
  261. Xtest open-7.5 {gets command with long line} {
  262. X    set f [open test3]
  263. X    set x [gets $f]
  264. X    close $f
  265. X    set x
  266. X} {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
  267. Xtest open-7.6 {gets command with long line} {
  268. X    set f [open test3]
  269. X    set x [gets $f y]
  270. X    close $f
  271. X    list $x $y
  272. X} {260 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
  273. Xtest open-7.7 {gets command and end of file} {
  274. X    set f [open test3 w]
  275. X    puts $f "Test1\nTest2" nonewline
  276. X    close $f
  277. X    set f [open test3]
  278. X    set x {}
  279. X    set y {}
  280. X    lappend x [gets $f y] $y
  281. X    set y {}
  282. X    lappend x [gets $f y] $y
  283. X    set y {}
  284. X    lappend x [gets $f y] $y
  285. X    close $f
  286. X    set x
  287. X} {5 Test1 5 Test2 -1 {}}
  288. X
  289. Xtest open-8.1 {read command} {
  290. X    list [catch {read} msg] $msg $errorCode
  291. X} {1 {wrong # args: should be "read fileId ?numBytes|nonewline?"} NONE}
  292. Xtest open-8.2 {read command} {
  293. X    list [catch {read a b c} msg] $msg $errorCode
  294. X} {1 {wrong # args: should be "read fileId ?numBytes|nonewline?"} NONE}
  295. Xtest open-8.3 {read command} {
  296. X    list [catch {read file10} msg] $msg $errorCode
  297. X} {1 {file "file10" isn't open} NONE}
  298. Xtest open-8.4 {read command} {
  299. X    set f [open test3 w]
  300. X    set x [list [catch {read $f} msg] \
  301. X        [string range $msg [string first " " $msg] end] $errorCode]
  302. X    close $f
  303. X    set x
  304. X} {1 { wasn't opened for reading} NONE}
  305. Xtest open-8.5 {read command} {
  306. X    set f [open test1]
  307. X    set x [list [catch {read $f 12z} msg] $msg $errorCode]
  308. X    close $f
  309. X    set x
  310. X} {1 {expected integer but got "12z"} NONE}
  311. Xtest open-8.6 {read command} {
  312. X    set f [open test1]
  313. X    set x [list [catch {read $f z} msg] $msg $errorCode]
  314. X    close $f
  315. X    set x
  316. X} {1 {bad argument "z": should be "nonewline"} NONE}
  317. Xtest open-8.7 {read command} {
  318. X    set f [open test1]
  319. X    set x [list [read $f 1] [read $f 2] [read $f]]
  320. X    close $f
  321. X    set x
  322. X} {T wo { lines: this one
  323. Xand this one
  324. X}}
  325. Xtest open-8.8 {read command, with over-large count} {
  326. X    set f [open test1]
  327. X    set x [read $f 100]
  328. X    close $f
  329. X    set x
  330. X} {Two lines: this one
  331. Xand this one
  332. X}
  333. Xtest open-8.9 {read command, nonewline option} {
  334. X    set f [open test1]
  335. X    set x [read $f n]
  336. X    close $f
  337. X    set x
  338. X} {Two lines: this one
  339. Xand this one}
  340. X
  341. Xtest open-9.1 {seek command} {
  342. X    list [catch {seek foo} msg] $msg $errorCode
  343. X} {1 {wrong # args: should be "seek fileId offset ?origin?"} NONE}
  344. Xtest open-9.2 {seek command} {
  345. X    list [catch {seek foo a b c} msg] $msg $errorCode
  346. X} {1 {wrong # args: should be "seek fileId offset ?origin?"} NONE}
  347. Xtest open-9.3 {seek command} {
  348. X    list [catch {seek foo 0} msg] $msg $errorCode
  349. X} {1 {bad file identifier "foo"} NONE}
  350. Xtest open-9.4 {seek command} {
  351. X    set f [open test2]
  352. X    set x [list [catch {seek $f xyz} msg] $msg $errorCode]
  353. X    close $f
  354. X    set x
  355. X} {1 {expected integer but got "xyz"} NONE}
  356. Xtest open-9.5 {seek command} {
  357. X    set f [open test2]
  358. X    set x [list [catch {seek $f 100 gorp} msg] $msg $errorCode]
  359. X    close $f
  360. X    set x
  361. X} {1 {bad origin "gorp": should be start, current, or end} NONE}
  362. Xset f [open test3 w]
  363. Xputs $f "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" nonewline
  364. Xclose $f
  365. Xtest open-9.6 {seek command} {
  366. X    set f [open test3]
  367. X    set x [read $f 1]
  368. X    seek $f 3
  369. X    lappend x [read $f 1]
  370. X    seek $f 0 start
  371. X    lappend x [read $f 1]
  372. X    seek $f 10 current
  373. X    lappend x [read $f 1]
  374. X    seek $f -2 end
  375. X    lappend x [read $f 1]
  376. X    seek $f 50 end
  377. X    lappend x [read $f 1]
  378. X    seek $f 1
  379. X    lappend x [read $f 1]
  380. X    close $f
  381. X    set x
  382. X} {a d a l Y {} b}
  383. X
  384. Xtest open-10.1 {tell command} {
  385. X    list [catch {tell} msg] $msg $errorCode
  386. X} {1 {wrong # args: should be "tell fileId"} NONE}
  387. Xtest open-10.2 {tell command} {
  388. X    list [catch {tell a b} msg] $msg $errorCode
  389. X} {1 {wrong # args: should be "tell fileId"} NONE}
  390. Xtest open-10.3 {tell command} {
  391. X    list [catch {tell a} msg] $msg $errorCode
  392. X} {1 {bad file identifier "a"} NONE}
  393. Xtest open-10.4 {tell command} {
  394. X    set f [open test2]
  395. X    set x [tell $f]
  396. X    read $f 3
  397. X    lappend x [tell $f]
  398. X    seek $f 2
  399. X    lappend x [tell $f]
  400. X    seek $f 10 current
  401. X    lappend x [tell $f]
  402. X    seek $f 0 end
  403. X    lappend x [tell $f]
  404. X    close $f
  405. X    set x
  406. X} {0 3 2 12 30}
  407. X
  408. Xtest open-11.1 {eof command} {
  409. X    list [catch {eof} msg] $msg $errorCode
  410. X} {1 {wrong # args: should be "eof fileId"} NONE}
  411. Xtest open-11.2 {eof command} {
  412. X    list [catch {eof a b} msg] $msg $errorCode
  413. X} {1 {wrong # args: should be "eof fileId"} NONE}
  414. Xtest open-11.3 {eof command} {
  415. X    list [catch {eof file100} msg] $msg $errorCode
  416. X} {1 {file "file100" isn't open} NONE}
  417. Xtest open-11.4 {eof command} {
  418. X    set f [open test1]
  419. X    set x [eof $f]
  420. X    lappend x [eof $f]
  421. X    gets $f
  422. X    lappend x [eof $f]
  423. X    gets $f
  424. X    lappend x [eof $f]
  425. X    gets $f
  426. X    lappend x [eof $f]
  427. X    lappend x [eof $f]
  428. X    close $f
  429. X    set x
  430. X} {0 0 0 0 1 1}
  431. X
  432. Xtest open-12.1 {flush command} {
  433. X    list [catch {flush} msg] $msg $errorCode
  434. X} {1 {wrong # args: should be "flush fileId"} NONE}
  435. Xtest open-12.2 {flush command} {
  436. X    list [catch {flush a b} msg] $msg $errorCode
  437. X} {1 {wrong # args: should be "flush fileId"} NONE}
  438. Xtest open-12.3 {flush command} {
  439. X    list [catch {flush a} msg] $msg $errorCode
  440. X} {1 {bad file identifier "a"} NONE}
  441. Xtest open-12.4 {flush command} {
  442. X    set f [open test3]
  443. X    set x [list [catch {flush $f} msg] \
  444. X        [string range $msg [string first " " $msg] end] $errorCode]
  445. X    close $f
  446. X    set x
  447. X} {1 { wasn't opened for writing} NONE}
  448. Xtest open-12.5 {flush command} {
  449. X    set f [open test3 w]
  450. X    puts $f "Line 1"
  451. X    puts $f "Line 2"
  452. X    set f2 [open test3]
  453. X    set x {}
  454. X    lappend x [read $f2 nonewline]
  455. X    close $f2
  456. X    flush $f
  457. X    set f2 [open test3]
  458. X    lappend x [read $f2 nonewline]
  459. X    close $f2
  460. X    close $f
  461. X    set x
  462. X} {{} {Line 1
  463. XLine 2}}
  464. X
  465. Xtest open-13.1 {I/O to command pipelines} {
  466. X    list [catch {open "| cat < test1 > test3" w} msg] $msg $errorCode
  467. X} {1 {can't write input to command: standard input was redirected} NONE}
  468. Xtest open-13.2 {I/O to command pipelines} {
  469. X    list [catch {open "| echo > test3" r} msg] $msg $errorCode
  470. X} {1 {can't read output from command: standard output was redirected} NONE}
  471. Xtest open-13.3 {I/O to command pipelines} {
  472. X    list [catch {open "| echo > test3" r+} msg] $msg $errorCode
  473. X} {1 {can't read output from command: standard output was redirected} NONE}
  474. Xtest open-13.4 {writing to command pipelines} {
  475. X    exec rm test3
  476. X    set f [open "| cat | cat > test3" w]
  477. X    puts $f "Line 1"
  478. X    puts $f "Line 2"
  479. X    close $f
  480. X    exec cat test3
  481. X} {Line 1
  482. XLine 2}
  483. Xtest open-13.5 {reading from command pipelines} {
  484. X    set f [open "| cat test2" r]
  485. X    set x [list [gets $f] [gets $f] [gets $f]]
  486. X    close $f
  487. X    set x
  488. X} {line1 line2 line3}
  489. Xtest open-13.6 {both reading and writing from/to command pipelines} {
  490. X    set f [open "| cat" r+]
  491. X    puts $f "Line1"
  492. X    flush $f
  493. X    set x [gets $f]
  494. X    close $f
  495. X    set x
  496. X} {Line1}
  497. Xtest open-13.7 {errors in command pipelines} {
  498. X    set f [open "|gorp"]
  499. X    list [catch {close $f} msg] $msg [lindex $errorCode 0] [lindex $errorCode 2]
  500. X} {1 {couldn't find "gorp" to execute} CHILDSTATUS 1}
  501. Xtest open-13.8 {errors in command pipelines} {
  502. X    set f [open "|gorp" w]
  503. X    exec sleep 1
  504. X    puts $f output
  505. X    set x [list [catch {flush $f} msg] [concat \
  506. X        [string range $msg 0 [string first {"} $msg]] \
  507. X        [string range $msg [string first : $msg] end]] $errorCode]
  508. X    catch {close $f}
  509. X    string tolower $x
  510. X} {1 {error flushing " : broken pipe} {unix epipe {broken pipe}}}
  511. Xtest open-13.9 {errors in command pipelines} {
  512. X    set f [open "|gorp" w]
  513. X    list [catch {close $f} msg] $msg \
  514. X        [lindex $errorCode 0] [lindex $errorCode 2]
  515. X} {1 {couldn't find "gorp" to execute} CHILDSTATUS 1}
  516. Xtest open-13.10 {errors in command pipelines} {
  517. X    set f [open "|gorp" w]
  518. X    exec sleep 1
  519. X    puts $f output
  520. X    string tolower [list [catch {close $f} msg] [concat \
  521. X        [string range $msg 0 [string first {"} $msg]] \
  522. X        [string range $msg [string first : $msg] end]] \
  523. X        [lindex $errorCode 0] [lindex $errorCode 2]]
  524. X} {1 {error closing " : broken pipe
  525. Xcouldn't find "gorp" to execute} childstatus 1}
  526. X
  527. Xcatch {exec rm -f test1 test2 test3}
  528. Xconcat {}
  529. END_OF_FILE
  530. if test 16158 -ne `wc -c <'tcl6.1/tests/open.test'`; then
  531.     echo shar: \"'tcl6.1/tests/open.test'\" unpacked with wrong size!
  532. fi
  533. # end of 'tcl6.1/tests/open.test'
  534. fi
  535. if test -f 'tcl6.1/tests/set.test' -a "${1}" != "-c" ; then 
  536.   echo shar: Will not clobber existing file \"'tcl6.1/tests/set.test'\"
  537. else
  538. echo shar: Extracting \"'tcl6.1/tests/set.test'\" \(16970 characters\)
  539. sed "s/^X//" >'tcl6.1/tests/set.test' <<'END_OF_FILE'
  540. X# Commands covered:  set, unset, array
  541. X#
  542. X# This file contains a collection of tests for one or more of the Tcl
  543. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  544. X# generates output for errors.  No output means no errors were found.
  545. X#
  546. X# Copyright 1991 Regents of the University of California
  547. X# Permission to use, copy, modify, and distribute this
  548. X# software and its documentation for any purpose and without
  549. X# fee is hereby granted, provided that this copyright notice
  550. X# appears in all copies.  The University of California makes no
  551. X# representations about the suitability of this software for any
  552. X# purpose.  It is provided "as is" without express or implied
  553. X# warranty.
  554. X#
  555. X# $Header: /user6/ouster/tcl/tests/RCS/set.test,v 1.8 91/10/31 16:40:57 ouster Exp $ (Berkeley)
  556. X
  557. Xif {[string compare test [info procs test]] == 1} then {source defs}
  558. X
  559. Xproc ignore args {}
  560. X
  561. X# Simple variable operations.
  562. X
  563. Xcatch {unset a}
  564. Xtest set-1.1 {basic variable setting and unsetting} {
  565. X    set a 22
  566. X} 22
  567. Xtest set-1.2 {basic variable setting and unsetting} {
  568. X    set a 123
  569. X    set a
  570. X} 123
  571. Xtest set-1.3 {basic variable setting and unsetting} {
  572. X    set a xxx
  573. X    format %s $a
  574. X} xxx
  575. Xtest set-1.4 {basic variable setting and unsetting} {
  576. X    set a 44
  577. X    unset a
  578. X    list [catch {set a} msg] $msg
  579. X} {1 {can't read "a": no such variable}}
  580. X
  581. X# Basic array operations.
  582. X
  583. Xcatch {unset a}
  584. Xset a(xyz) 2
  585. Xset a(44) 3
  586. Xset {a(a long name)} test
  587. Xtest set-2.1 {basic array operations} {
  588. X    lsort [array names a]
  589. X} {44 {a long name} xyz}
  590. Xtest set-2.2 {basic array operations} {
  591. X    set a(44)
  592. X} 3
  593. Xtest set-2.3 {basic array operations} {
  594. X    set a(xyz)
  595. X} 2
  596. Xtest set-2.4 {basic array operations} {
  597. X    set "a(a long name)"
  598. X} test
  599. Xtest set-2.5 {basic array operations} {
  600. X    list [catch {set a(other)} msg] $msg
  601. X} {1 {can't read "a(other)": no such element in array}}
  602. Xtest set-2.6 {basic array operations} {
  603. X    list [catch {set a} msg] $msg
  604. X} {1 {can't read "a": no such variable}}
  605. Xtest set-2.7 {basic array operations} {
  606. X    format %s $a(44)
  607. X} 3
  608. Xtest set-2.8 {basic array operations} {
  609. X    format %s $a(a long name)
  610. X} test
  611. Xunset a(44)
  612. Xtest set-2.9 {basic array operations} {
  613. X    lsort [array names a]
  614. X} {{a long name} xyz}
  615. Xunset a
  616. Xtest set-2.10 {basic array operations} {
  617. X    list [catch {set a(xyz)} msg] $msg
  618. X} {1 {can't read "a(xyz)": no such variable}}
  619. X
  620. X# Test the set commands, and exercise the corner cases of the code
  621. X# that parses array references into two parts.
  622. X
  623. Xtest set-3.1 {set command} {
  624. X    list [catch {set} msg] $msg
  625. X} {1 {wrong # args: should be "set varName ?newValue?"}}
  626. Xtest set-3.2 {set command} {
  627. X    list [catch {set x y z} msg] $msg
  628. X} {1 {wrong # args: should be "set varName ?newValue?"}}
  629. Xtest set-3.3 {set command} {
  630. X    catch {unset a}
  631. X    list [catch {set a} msg] $msg
  632. X} {1 {can't read "a": no such variable}}
  633. Xtest set-3.4 {set command} {
  634. X    catch {unset a}
  635. X    set a(14) 83
  636. X    list [catch {set a 22} msg] $msg
  637. X} {1 {can't set "a": variable is array}}
  638. X
  639. X# Test the corner-cases of parsing array names, using set and unset.
  640. X
  641. Xtest set-4.1 {parsing array names} {
  642. X    catch {unset a}
  643. X    set a(()) 44
  644. X    list [catch {array names a} msg] $msg
  645. X} {0 ()}
  646. Xtest set-4.2 {parsing array names} {
  647. X    catch {unset a a(abcd}
  648. X    set a(abcd 33
  649. X    info exists a(abcd
  650. X} 1
  651. Xtest set-4.3 {parsing array names} {
  652. X    catch {unset a a(abcd}
  653. X    set a(abcd 33
  654. X    list [catch {array names a} msg] $msg
  655. X} {1 {"a" isn't an array}}
  656. Xtest set-4.4 {parsing array names} {
  657. X    catch {unset a abcd)}
  658. X    set abcd) 33
  659. X    info exists abcd)
  660. X} 1
  661. Xtest set-4.5 {parsing array names} {
  662. X    set a(bcd yyy
  663. X    catch {unset a}
  664. X    list [catch {set a(bcd} msg] $msg
  665. X} {0 yyy}
  666. Xtest set-4.6 {parsing array names} {
  667. X    catch {unset a}
  668. X    set a 44
  669. X    list [catch {set a(bcd test} msg] $msg
  670. X} {0 test}
  671. X
  672. X# Errors in reading variables
  673. X
  674. Xtest set-5.1 {errors in reading variables} {
  675. X    catch {unset a}
  676. X    list [catch {set a} msg] $msg
  677. X} {1 {can't read "a": no such variable}}
  678. Xtest set-5.2 {errors in reading variables} {
  679. X    catch {unset a}
  680. X    set a 44
  681. X    list [catch {set a(18)} msg] $msg
  682. X} {1 {can't read "a(18)": variable isn't array}}
  683. Xtest set-5.3 {errors in reading variables} {
  684. X    catch {unset a}
  685. X    set a(6) 44
  686. X    list [catch {set a(18)} msg] $msg
  687. X} {1 {can't read "a(18)": no such element in array}}
  688. Xtest set-5.4 {errors in reading variables} {
  689. X    catch {unset a}
  690. X    set a(6) 44
  691. X    list [catch {set a} msg] $msg
  692. X} {1 {can't read "a": no such variable}}
  693. X
  694. X# Errors and other special cases in writing variables
  695. X
  696. Xtest set-6.1 {creating array during write} {
  697. X    catch {unset a}
  698. X    trace var a rwu ignore
  699. X    list [catch {set a(14) 186} msg] $msg [array names a]
  700. X} {0 186 14}
  701. Xtest set-6.2 {errors in writing variables} {
  702. X    catch {unset a}
  703. X    set a xxx
  704. X    list [catch {set a(14) 186} msg] $msg
  705. X} {1 {can't set "a(14)": variable isn't array}}
  706. Xtest set-6.3 {errors in writing variables} {
  707. X    catch {unset a}
  708. X    set a(100) yyy
  709. X    list [catch {set a 2} msg] $msg
  710. X} {1 {can't set "a": variable is array}}
  711. Xtest set-6.4 {expanding variable size} {
  712. X    catch {unset a}
  713. X    list [set a short] [set a "longer name"] [set a "even longer name"] \
  714. X        [set a "a much much truly longer name"]
  715. X} {short {longer name} {even longer name} {a much much truly longer name}}
  716. X
  717. X# Unset command, Tcl_UnsetVar procedures
  718. X
  719. Xtest set-7.1 {unset command} {
  720. X    catch {unset a}; catch {unset b}; catch {unset c}; catch {unset d}
  721. X    set a 44
  722. X    set b 55
  723. X    set c 66
  724. X    set d 77
  725. X    unset a b c
  726. X    list [catch {set a(0) 0}] [catch {set b(0) 0}] [catch {set c(0) 0}] \
  727. X        [catch {set d(0) 0}]
  728. X} {0 0 0 1}
  729. Xtest set-7.2 {unset command} {
  730. X    list [catch {unset} msg] $msg
  731. X} {1 {wrong # args: should be "unset varName ?varName ...?"}}
  732. Xtest set-7.3 {unset command} {
  733. X    catch {unset a}
  734. X    list [catch {unset a} msg] $msg
  735. X} {1 {can't unset "a": no such variable}}
  736. Xtest set-7.4 {unset command} {
  737. X    catch {unset a}
  738. X    set a 44
  739. X    list [catch {unset a(14)} msg] $msg
  740. X} {1 {can't unset "a(14)": variable isn't array}}
  741. Xtest set-7.5 {unset command} {
  742. X    catch {unset a}
  743. X    set a(0) xx
  744. X    list [catch {unset a(14)} msg] $msg
  745. X} {1 {can't unset "a(14)": no such element in array}}
  746. Xtest set-7.6 {unset command} {
  747. X    catch {unset a}; catch {unset b}; catch {unset c}
  748. X    set a foo
  749. X    set c gorp
  750. X    list [catch {unset a a a(14)} msg] $msg [info exists c]
  751. X} {1 {can't unset "a": no such variable} 1}
  752. Xtest set-7.7 {unsetting globals from within procedures} {
  753. X    set y 0
  754. X    proc p1 {} {
  755. X    global y
  756. X    set z [p2]
  757. X    return [list $z [catch {set y} msg] $msg]
  758. X    }
  759. X    proc p2 {} {global y; unset y; list [catch {set y} msg] $msg}
  760. X    p1
  761. X} {{1 {can't read "y": no such variable}} 1 {can't read "y": no such variable}}
  762. Xtest set-7.8 {unsetting globals from within procedures} {
  763. X    set y 0
  764. X    proc p1 {} {
  765. X    global y
  766. X    p2
  767. X    return [list [catch {set y 44} msg] $msg]
  768. X    }
  769. X    proc p2 {} {global y; unset y}
  770. X    concat [p1] [list [catch {set y} msg] $msg]
  771. X} {0 44 0 44}
  772. Xtest set-7.9 {unsetting globals from within procedures} {
  773. X    set y 0
  774. X    proc p1 {} {
  775. X    global y
  776. X    unset y
  777. X    return [list [catch {set y 55} msg] $msg]
  778. X    }
  779. X    concat [p1] [list [catch {set y} msg] $msg]
  780. X} {0 55 0 55}
  781. Xtest set-7.10 {unset command} {
  782. X    catch {unset a}
  783. X    set a(14) 22
  784. X    unset a(14)
  785. X    list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
  786. X} {1 {can't read "a(14)": no such element in array} 0 {}}
  787. Xtest set-7.11 {unset command} {
  788. X    catch {unset a}
  789. X    set a(14) 22
  790. X    unset a
  791. X    list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
  792. X} {1 {can't read "a(14)": no such variable} 1 {"a" isn't an array}}
  793. X
  794. X# Array command.
  795. X
  796. Xtest set-8.1 {array command} {
  797. X    list [catch {array} msg] $msg
  798. X} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
  799. Xtest set-8.2 {array command} {
  800. X    catch {unset a}
  801. X    list [catch {array names a} msg] $msg
  802. X} {1 {"a" isn't an array}}
  803. Xtest set-8.3 {array command} {
  804. X    catch {unset a}
  805. X    set a 44
  806. X    list [catch {array names a} msg] $msg
  807. X} {1 {"a" isn't an array}}
  808. Xtest set-8.4 {array command} {
  809. X    catch {unset a}
  810. X    set a(22) 3
  811. X    list [catch {array gorp a} msg] $msg
  812. X} {1 {bad option "gorp": should be anymore, donesearch, names, nextelement, size, or startsearch}}
  813. Xtest set-8.5 {array command, names option} {
  814. X    catch {unset a}
  815. X    set a(22) 3
  816. X    list [catch {array names a 4} msg] $msg
  817. X} {1 {wrong # args: should be "array names arrayName"}}
  818. Xtest set-8.6 {array command, names option} {
  819. X    catch {unset a}
  820. X    set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
  821. X    list [catch {lsort [array names a]} msg] $msg
  822. X} {0 {22 Textual_name {name with spaces}}}
  823. Xtest set-8.7 {array command, names option} {
  824. X    catch {unset a}
  825. X    set a(22) 3; set a(33) 44;
  826. X    trace var a(xxx) w ignore
  827. X    list [catch {lsort [array names a]} msg] $msg
  828. X} {0 {22 33}}
  829. Xtest set-8.8 {array command, names option} {
  830. X    catch {unset a}
  831. X    set a(22) 3; set a(33) 44;
  832. X    trace var a(xxx) w ignore
  833. X    set a(xxx) value
  834. X    list [catch {lsort [array names a]} msg] $msg
  835. X} {0 {22 33 xxx}}
  836. Xtest set-8.9 {array command, size option} {
  837. X    catch {unset a}
  838. X    set a(22) 3
  839. X    list [catch {array size a 4} msg] $msg
  840. X} {1 {wrong # args: should be "array size arrayName"}}
  841. Xtest set-8.10 {array command, size option} {
  842. X    catch {unset a}
  843. X    set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
  844. X    list [catch {array size a} msg] $msg
  845. X} {0 3}
  846. Xtest set-8.10 {array command, size option} {
  847. X    catch {unset a}
  848. X    set a(22) 3; set a(xx) 44; set a(y) xxx
  849. X    unset a(22) a(y) a(xx)
  850. X    list [catch {array size a} msg] $msg
  851. X} {0 0}
  852. Xtest set-8.11 {array command, size option} {
  853. X    catch {unset a}
  854. X    set a(22) 3;
  855. X    trace var a(33) rwu ignore
  856. X    list [catch {array size a} msg] $msg
  857. X} {0 1}
  858. X
  859. Xtest set-9.1 {ids for array enumeration} {
  860. X    catch {unset a}
  861. X    set a(a) 1
  862. X    list [array st a] [array st a] [array done a s-1-a; array st a] \
  863. X        [array done a s-2-a; array d a s-3-a; array start a]
  864. X} {s-1-a s-2-a s-3-a s-1-a}
  865. Xtest set-9.2 {array enumeration} {
  866. X    catch {unset a}
  867. X    set a(a) 1
  868. X    set a(b) 1
  869. X    set a(c) 1
  870. X    set x [array startsearch a]
  871. X    list [array nextelement a $x] [array ne a $x] [array next a $x] \
  872. X        [array next a $x] [array next a $x]
  873. X} {a b c {} {}}
  874. Xtest set-9.3 {array enumeration} {
  875. X    catch {unset a}
  876. X    set a(a) 1
  877. X    set a(b) 1
  878. X    set a(c) 1
  879. X    set x [array startsearch a]
  880. X    set y [array startsearch a]
  881. X    set z [array startsearch a]
  882. X    list [array nextelement a $x] [array ne a $x] \
  883. X        [array next a $y] [array next a $z] [array next a $y] \
  884. X        [array next a $z] [array next a $y] [array next a $z] \
  885. X        [array next a $y] [array next a $z] [array next a $x] \
  886. X        [array next a $x]
  887. X} {a b a a b b c c {} {} c {}}
  888. Xtest set-9.4 {array enumeration: stopping searches} {
  889. X    catch {unset a}
  890. X    set a(a) 1
  891. X    set a(b) 1
  892. X    set a(c) 1
  893. X    set x [array startsearch a]
  894. X    set y [array startsearch a]
  895. X    set z [array startsearch a]
  896. X    list [array next a $x] [array next a $x] [array next a $y] \
  897. X        [array done a $z; array next a $x] \
  898. X        [array done a $x; array next a $y] [array next a $y]
  899. X} {a b a c b c}
  900. Xtest set-9.5 {array enumeration: stopping searches} {
  901. X    catch {unset a}
  902. X    set a(a) 1
  903. X    set x [array startsearch a]
  904. X    array done a $x
  905. X    list [catch {array next a $x} msg] $msg
  906. X} {1 {couldn't find search "s-1-a"}}
  907. Xtest set-9.6 {array enumeration: searches automatically stopped} {
  908. X    catch {unset a}
  909. X    set a(a) 1
  910. X    set x [array startsearch a]
  911. X    set y [array startsearch a]
  912. X    set a(b) 1
  913. X    list [catch {array next a $x} msg] $msg \
  914. X        [catch {array next a $y} msg2] $msg2
  915. X} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
  916. Xtest set-9.7 {array enumeration: searches automatically stopped} {
  917. X    catch {unset a}
  918. X    set a(a) 1
  919. X    set x [array startsearch a]
  920. X    set y [array startsearch a]
  921. X    set a(a) 2
  922. X    list [catch {array next a $x} msg] $msg \
  923. X        [catch {array next a $y} msg2] $msg2
  924. X} {0 a 0 a}
  925. Xtest set-9.8 {array enumeration: searches automatically stopped} {
  926. X    catch {unset a}
  927. X    set a(a) 1
  928. X    set x [array startsearch a]
  929. X    set y [array startsearch a]
  930. X    catch {unset a(c)}
  931. X    list [catch {array next a $x} msg] $msg \
  932. X        [catch {array next a $y} msg2] $msg2
  933. X} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
  934. Xtest set-9.9 {array enumeration: searches automatically stopped} {
  935. X    catch {unset a}
  936. X    set a(a) 1
  937. X    set x [array startsearch a]
  938. X    set y [array startsearch a]
  939. X    trace var a(b) r {}
  940. X    list [catch {array next a $x} msg] $msg \
  941. X        [catch {array next a $y} msg2] $msg2
  942. X} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
  943. Xtest set-9.10 {array enumeration: searches automatically stopped} {
  944. X    catch {unset a}
  945. X    set a(a) 1
  946. X    set x [array startsearch a]
  947. X    set y [array startsearch a]
  948. X    trace var a(a) r {}
  949. X    list [catch {array next a $x} msg] $msg \
  950. X        [catch {array next a $y} msg2] $msg2
  951. X} {0 a 0 a}
  952. Xtest set-9.11 {array enumeration with traced undefined elements} {
  953. X    catch {unset a}
  954. X    set a(a) 1
  955. X    trace var a(b) r {}
  956. X    set x [array startsearch a]
  957. X    list [array next a $x] [array next a $x]
  958. X} {a {}}
  959. X
  960. Xtest set-10.1 {array enumeration errors} {
  961. X    list [catch {array start} msg] $msg
  962. X} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
  963. Xtest set-10.2 {array enumeration errors} {
  964. X    list [catch {array start a b} msg] $msg
  965. X} {1 {wrong # args: should be "array startsearch arrayName"}}
  966. Xtest set-10.3 {array enumeration errors} {
  967. X    catch {unset a}
  968. X    list [catch {array start a} msg] $msg
  969. X} {1 {"a" isn't an array}}
  970. Xtest set-10.4 {array enumeration errors} {
  971. X    catch {unset a}
  972. X    set a(a) 1
  973. X    set x [array startsearch a]
  974. X    list [catch {array next a} msg] $msg
  975. X} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
  976. Xtest set-10.5 {array enumeration errors} {
  977. X    catch {unset a}
  978. X    set a(a) 1
  979. X    set x [array startsearch a]
  980. X    list [catch {array next a b c} msg] $msg
  981. X} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
  982. Xtest set-10.6 {array enumeration errors} {
  983. X    catch {unset a}
  984. X    set a(a) 1
  985. X    set x [array startsearch a]
  986. X    list [catch {array next a a-1-a} msg] $msg
  987. X} {1 {illegal search identifier "a-1-a"}}
  988. Xtest set-10.7 {array enumeration errors} {
  989. X    catch {unset a}
  990. X    set a(a) 1
  991. X    set x [array startsearch a]
  992. X    list [catch {array next a sx1-a} msg] $msg
  993. X} {1 {illegal search identifier "sx1-a"}}
  994. Xtest set-10.8 {array enumeration errors} {
  995. X    catch {unset a}
  996. X    set a(a) 1
  997. X    set x [array startsearch a]
  998. X    list [catch {array next a s--a} msg] $msg
  999. X} {1 {illegal search identifier "s--a"}}
  1000. Xtest set-10.9 {array enumeration errors} {
  1001. X    catch {unset a}
  1002. X    set a(a) 1
  1003. X    set x [array startsearch a]
  1004. X    list [catch {array next a s-1-b} msg] $msg
  1005. X} {1 {search identifier "s-1-b" isn't for variable "a"}}
  1006. Xtest set-10.10 {array enumeration errors} {
  1007. X    catch {unset a}
  1008. X    set a(a) 1
  1009. X    set x [array startsearch a]
  1010. X    list [catch {array next a s-1ba} msg] $msg
  1011. X} {1 {illegal search identifier "s-1ba"}}
  1012. Xtest set-10.11 {array enumeration errors} {
  1013. X    catch {unset a}
  1014. X    set a(a) 1
  1015. X    set x [array startsearch a]
  1016. X    list [catch {array next a s-2-a} msg] $msg
  1017. X} {1 {couldn't find search "s-2-a"}}
  1018. Xtest set-10.12 {array enumeration errors} {
  1019. X    list [catch {array done a} msg] $msg
  1020. X} {1 {wrong # args: should be "array donesearch arrayName searchId"}}
  1021. Xtest set-10.13 {array enumeration errors} {
  1022. X    list [catch {array done a b c} msg] $msg
  1023. X} {1 {wrong # args: should be "array donesearch arrayName searchId"}}
  1024. Xtest set-10.14 {array enumeration errors} {
  1025. X    list [catch {array done a b} msg] $msg
  1026. X} {1 {illegal search identifier "b"}}
  1027. Xtest set-10.15 {array enumeration errors} {
  1028. X    list [catch {array anymore a} msg] $msg
  1029. X} {1 {wrong # args: should be "array anymore arrayName searchId"}}
  1030. Xtest set-10.16 {array enumeration errors} {
  1031. X    list [catch {array any a b c} msg] $msg
  1032. X} {1 {wrong # args: should be "array anymore arrayName searchId"}}
  1033. Xtest set-10.17 {array enumeration errors} {
  1034. X    catch {unset a}
  1035. X    set a(0) 44
  1036. X    list [catch {array any a bogus} msg] $msg
  1037. X} {1 {illegal search identifier "bogus"}}
  1038. X
  1039. X# Array enumeration with "anymore" option
  1040. X
  1041. Xtest set-11.1 {array anymore option} {
  1042. X    catch {unset a}
  1043. X    set a(a) 1
  1044. X    set a(b) 2
  1045. X    set a(c) 3
  1046. X    array startsearch a
  1047. X    list [array anymore a s-1-a] [array next a s-1-a] \
  1048. X        [array anymore a s-1-a] [array next a s-1-a] \
  1049. X        [array anymore a s-1-a] [array next a s-1-a] \
  1050. X        [array anymore a s-1-a] [array next a s-1-a] 
  1051. X} {1 a 1 b 1 c 0 {}}
  1052. Xtest set-11.2 {array anymore option} {
  1053. X    catch {unset a}
  1054. X    set a(a) 1
  1055. X    set a(b) 2
  1056. X    set a(c) 3
  1057. X    array startsearch a
  1058. X    list [array next a s-1-a] [array next a s-1-a] \
  1059. X        [array anymore a s-1-a] [array next a s-1-a] \
  1060. X        [array next a s-1-a] [array anymore a s-1-a] 
  1061. X} {a b 1 c {} 0}
  1062. X
  1063. X# Must delete variables when done, since these arrays get used as
  1064. X# scalars by other tests.
  1065. X
  1066. Xcatch {unset a}
  1067. Xcatch {unset b}
  1068. Xcatch {unset c}
  1069. Xreturn ""
  1070. END_OF_FILE
  1071. if test 16970 -ne `wc -c <'tcl6.1/tests/set.test'`; then
  1072.     echo shar: \"'tcl6.1/tests/set.test'\" unpacked with wrong size!
  1073. fi
  1074. # end of 'tcl6.1/tests/set.test'
  1075. fi
  1076. echo shar: End of archive 13 \(of 33\).
  1077. cp /dev/null ark13isdone
  1078. MISSING=""
  1079. for I in 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 ; do
  1080.     if test ! -f ark${I}isdone ; then
  1081.     MISSING="${MISSING} ${I}"
  1082.     fi
  1083. done
  1084. if test "${MISSING}" = "" ; then
  1085.     echo You have unpacked all 33 archives.
  1086.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1087. else
  1088.     echo You still need to unpack the following archives:
  1089.     echo "        " ${MISSING}
  1090. fi
  1091. ##  End of shell archive.
  1092. exit 0
  1093.  
  1094. exit 0 # Just in case...
  1095. -- 
  1096. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1097. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1098. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1099. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1100.