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

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v25i083:  tcl - tool command language, version 6.1, Part15/33
  4. Message-ID: <1991Nov15.224703.20643@sparky.imd.sterling.com>
  5. X-Md4-Signature: 3125ebba285bdb6a44fba3ec1d6d7da0
  6. Date: Fri, 15 Nov 1991 22:47:03 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 25, Issue 83
  11. Archive-name: tcl/part15
  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 15 (of 33)."
  21. # Contents:  tcl6.1/tests/scan.test tcl6.1/tests/trace.test
  22. # Wrapped by karl@one on Tue Nov 12 19:44:23 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'tcl6.1/tests/scan.test' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'tcl6.1/tests/scan.test'\"
  26. else
  27. echo shar: Extracting \"'tcl6.1/tests/scan.test'\" \(20188 characters\)
  28. sed "s/^X//" >'tcl6.1/tests/scan.test' <<'END_OF_FILE'
  29. X# Commands covered:  scan
  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: /user6/ouster/tcl/tests/RCS/scan.test,v 1.9 91/10/17 16:25:28 ouster Exp $ (Berkeley)
  45. X
  46. Xif {[string compare test [info procs test]] == 1} then {source defs}
  47. X
  48. Xtest scan-1.1 {integer scanning} {
  49. X    set a {}; set b {}; set c {}; set d {}
  50. X    scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  51. X} 4
  52. Xtest scan-1.2 {integer scanning} {
  53. X    set a {}; set b {}; set c {}; set d {}
  54. X    scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  55. X    set a
  56. X} -20
  57. Xtest scan-1.3 {integer scanning} {
  58. X    set a {}; set b {}; set c {}; set d {}
  59. X    scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  60. X    set b
  61. X} 1476
  62. Xtest scan-1.4 {integer scanning} {
  63. X    set a {}; set b {}; set c {}; set d {}
  64. X    scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  65. X    set c
  66. X} 33
  67. Xtest scan-1.5 {integer scanning} {
  68. X    set a {}; set b {}; set c {}; set d {}
  69. X    scan "-20 1476 \n33 0" "%d %d %d %d" a b c d
  70. X    set d
  71. X} 0
  72. Xtest scan-1.6 {integer scanning} {
  73. X    set a {}; set b {}; set c {}
  74. X    scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  75. X} 3
  76. Xtest scan-1.7 {integer scanning} {
  77. X    set a {}; set b {}; set c {}
  78. X    scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  79. X    set a
  80. X} -4
  81. Xtest scan-1.8 {integer scanning} {
  82. X    set a {}; set b {}; set c {}
  83. X    scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  84. X    set b
  85. X} 16
  86. Xtest scan-1.9 {integer scanning} {
  87. X    set a {}; set b {}; set c {}
  88. X    scan "-45 16 7890 +10" "%2d %*d %10d %d" a b c
  89. X    set c
  90. X} 7890
  91. Xtest scan-1.10 {integer scanning} {
  92. X    set a {}; set b {}; set c {}; set d {}
  93. X    scan "-45 16 +10 987" "%D %d %D %d" a b c d
  94. X} 4
  95. Xtest scan-1.11 {integer scanning} {
  96. X    set a {}; set b {}; set c {}; set d {}
  97. X    scan "-45 16 +10 987" "%D %d %D %d" a b c d
  98. X    set a
  99. X} -45
  100. Xtest scan-1.12 {integer scanning} {
  101. X    set a {}; set b {}; set c {}; set d {}
  102. X    scan "-45 16 +10 987" "%D %d%D %d" a b c d
  103. X    set b
  104. X} 16
  105. Xtest scan-1.13 {integer scanning} {
  106. X    set a {}; set b {}; set c {}; set d {}
  107. X    scan "-45 16 +10 987" "%D %d %D %d" a b c d
  108. X    set c
  109. X} 10
  110. Xtest scan-1.14 {integer scanning} {
  111. X    set a {}; set b {}; set c {}; set d {}
  112. X    scan "-45 16 +10 987" "%D %d %D %d" a b c d
  113. X    set d
  114. X} 987
  115. Xtest scan-1.15 {integer scanning} {
  116. X    set a {}; set b {}; set c {}; set d {}
  117. X    scan "14 1ab 62 10" "%d %x %O %x" a b c d
  118. X} 4
  119. Xtest scan-1.16 {integer scanning} {
  120. X    set a {}; set b {}; set c {}; set d {}
  121. X    scan "14 1ab 62 10" "%d %x %O %x" a b c d
  122. X    set a
  123. X} 14
  124. Xtest scan-1.17 {integer scanning} {
  125. X    set a {}; set b {}; set c {}; set d {}
  126. X    scan "14 1ab 62 10" "%d %x %O %x" a b c d
  127. X    set b
  128. X} 427
  129. Xtest scan-1.18 {integer scanning} {
  130. X    set a {}; set b {}; set c {}; set d {}
  131. X    scan "14 1ab 62 10" "%d %x %O %x" a b c d
  132. X    set c
  133. X} 50
  134. Xtest scan-1.19 {integer scanning} {
  135. X    set a {}; set b {}; set c {}; set d {}
  136. X    scan "14 1ab 62 10" "%d %x %O %x" a b c d
  137. X    set d
  138. X} 16
  139. Xtest scan-1.20 {integer scanning} {
  140. X    set a {}; set b {}; set c {}; set d {}
  141. X    scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  142. X} 4
  143. Xtest scan-1.21 {integer scanning} {
  144. X    set a {}; set b {}; set c {}; set d {}
  145. X    scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  146. X    set a
  147. X} 2739128
  148. Xtest scan-1.22 {integer scanning} {
  149. X    set a {}; set b {}; set c {}; set d {}
  150. X    scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  151. X    set b
  152. X} 342391
  153. Xtest scan-1.23 {integer scanning} {
  154. X    set a {}; set b {}; set c {}; set d {}
  155. X    scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  156. X    set c
  157. X} 561323
  158. Xtest scan-1.24 {integer scanning} {
  159. X    set a {}; set b {}; set c {}; set d {}
  160. X    scan "12345670 1234567890ab cdefg" "%o     %o %x %X" a b c d
  161. X    set d
  162. X} 52719
  163. Xtest scan-1.25 {integer scanning} {
  164. X    set a {}; set b {}; set c {}; set d {}
  165. X    scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  166. X} 4
  167. Xtest scan-1.26 {integer scanning} {
  168. X    set a {}; set b {}; set c {}; set d {}
  169. X    scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  170. X    set a
  171. X} 171
  172. Xtest scan-1.27 {integer scanning} {
  173. X    set a {}; set b {}; set c {}; set d {}
  174. X    scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  175. X    set b
  176. X} 291
  177. Xtest scan-1.28 {integer scanning} {
  178. X    set a {}; set b {}; set c {}; set d {}
  179. X    scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  180. X    set c
  181. X} -20
  182. Xtest scan-1.29 {integer scanning} {
  183. X    set a {}; set b {}
  184. X    scan "ab123-24642" "%2x %3x %3o %2o" a b c d
  185. X    set d
  186. X} 52
  187. Xtest scan-1.30 {integer scanning} {
  188. X    set a {}; set b {}
  189. X    scan "1234567 234 567  " "%*3x %x %*o %4o" a b
  190. X} 2
  191. Xtest scan-1.31 {integer scanning} {
  192. X    set a {}; set b {}
  193. X    scan "1234567 234 567  " "%*3x %x %*o %4o" a b
  194. X    set a
  195. X} 17767
  196. Xtest scan-1.32 {integer scanning} {
  197. X    set a {}; set b {}
  198. X    scan "a    1234" "%d %d" a b
  199. X} 0
  200. Xtest scan-1.33 {integer scanning} {
  201. X    set a {}
  202. X    scan "a    1234" "%d %d" a b
  203. X    set a
  204. X} {}
  205. Xtest scan-1.34 {integer scanning} {
  206. X    set a {}; set b {}; set c {}; set d {};
  207. X    scan "12345678" "%2d %2d %2d %2d" a b c d
  208. X} 4
  209. Xtest scan-1.35 {integer scanning} {
  210. X    set a {}; set b {}; set c {}; set d {};
  211. X    scan "12345678" "%2d %2d %2d %2d" a b c d
  212. X    set a
  213. X} 12
  214. Xtest scan-1.36 {integer scanning} {
  215. X    set a {}; set b {}; set c {}; set d {}
  216. X    scan "12345678" "%2d %2d %2d %2d" a b c d
  217. X    set b
  218. X} 34
  219. Xtest scan-1.37 {integer scanning} {
  220. X    set a {}; set b {}; set c {}; set d {}
  221. X    scan "12345678" "%2d %2d %2d %2d" a b c d
  222. X    set c
  223. X} 56
  224. Xtest scan-1.38 {integer scanning} {
  225. X    set a {}; set b {}; set c {}; set d {}
  226. X    scan "12345678" "%2d %2d %2d %2d" a b c d
  227. X    set d
  228. X} 78
  229. Xtest scan-1.39 {integer scanning} {
  230. X    set a {}; set b {}; set c {}; set d {}
  231. X    scan "1 2 " "%d %d %d %d" a b c d
  232. X} 2
  233. Xtest scan-1.40 {integer scanning} {
  234. X    set a {}; set b {}; set c {}; set d {}
  235. X    scan "1 2 " "%d %d %d %d" a b c d
  236. X    set a
  237. X} 1
  238. Xtest scan-1.41 {integer scanning} {
  239. X    set a {}; set b {}; set c {}; set d {}
  240. X    scan "1 2 " "%d %d %d %d" a b c d
  241. X    set b
  242. X} 2
  243. Xtest scan-1.42 {integer scanning} {
  244. X    set a {}; set b {}; set c {}; set d {}
  245. X    scan "1 2 " "%d %d %d %d" a b c d
  246. X} 2
  247. Xtest scan-1.43 {integer scanning} {
  248. X    set a {}; set b {}; set c {}; set d {}
  249. X    scan "1 2 " "%d %d %d %d" a b c d
  250. X    set d
  251. X} {}
  252. X
  253. Xtest scan-2.1 {floating-point scanning} {
  254. X    set a {}; set b {}; set c {}; set d {}
  255. X    scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  256. X} 3
  257. Xtest scan-2.2 {floating-point scanning} {
  258. X    set a {}; set b {}; set c {}; set d {}
  259. X    scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  260. X    set a
  261. X} 2.1
  262. Xtest scan-2.3 {floating-point scanning} {
  263. X    set a {}; set b {}; set c {}; set d {}
  264. X    scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  265. X    set b
  266. X} -3e+08
  267. Xtest scan-2.4 {floating-point scanning} {
  268. X    set a {}; set b {}; set c {}; set d {}
  269. X    scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  270. X    set c
  271. X} 0.99962
  272. Xtest scan-2.5 {floating-point scanning} {
  273. X    set a {}; set b {}; set c {}; set d {}
  274. X    scan "2.1 -3.0e8 .99962 a" "%f%f%f%f" a b c d
  275. X    set d
  276. X} {}
  277. Xtest scan-2.6 {floating-point scanning} {
  278. X    set a {}; set b {}; set c {}; set d {}
  279. X    scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  280. X} 4
  281. Xtest scan-2.7 {floating-point scanning} {
  282. X    set a {}; set b {}; set c {}; set d {}
  283. X    scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  284. X    set a
  285. X} -1
  286. Xtest scan-2.8 {floating-point scanning} {
  287. X    set a {}; set b {}; set c {}; set d {}
  288. X    scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  289. X    set b
  290. X} 234
  291. Xtest scan-2.9 {floating-point scanning} {
  292. X    set a {}; set b {}; set c {}; set d {}
  293. X    scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  294. X    set c
  295. X} 5
  296. Xtest scan-2.10 {floating-point scanning} {
  297. X    set a {}; set b {}; set c {}; set d {}
  298. X    scan "-1.2345 +8.2 9" "%3e %3f %f %f" a b c d
  299. X    set d
  300. X} 8.2
  301. Xtest scan-2.11 {floating-point scanning} {
  302. X    set a {}; set b {}; set c {}
  303. X    scan "1e00004 332E-4 3e+4" "%f %*2e %f %f" a b c
  304. X} 3
  305. Xtest scan-2.12 {floating-point scanning} {
  306. X    set a {}; set b {}; set c {}
  307. X    scan "1e00004 332E-4 3e+4" "%f %*2e %f %f" a b c
  308. X    set a
  309. X} 10000
  310. Xtest scan-2.13 {floating-point scanning} {
  311. X    set a {}; set b {}; set c {}
  312. X    scan "1e00004 332E-4 3e+4" "%f %*2e %f %f" a b c
  313. X    set c
  314. X} 30000
  315. Xtest scan-2.14 {floating-point scanning} {
  316. X    set a {}; set b {}; set c {}
  317. X    scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  318. X} 3
  319. Xtest scan-2.15 {floating-point scanning} {
  320. X    set a {}; set b {}; set c {}
  321. X    scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  322. X    set a
  323. X} 1
  324. Xtest scan-2.16 {floating-point scanning} {
  325. X    set a {}; set b {}; set c {}
  326. X    scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  327. X    set b
  328. X} 200
  329. Xtest scan-2.17 {floating-point scanning} {
  330. X    set a {}; set b {}; set c {}
  331. X    scan "1. 47.6 2.e2 3.e-" "%f %*f %f %f" a b c
  332. X    set c
  333. X} 3
  334. Xtest scan-2.18 {floating-point scanning} {
  335. X    set a {}; set b {}
  336. X    scan "1.eabc" "%f %x" a b
  337. X} 2
  338. Xtest scan-2.19 {floating-point scanning} {
  339. X    set a {}; set b {}
  340. X    scan "1.eabc" "%f %x" a b
  341. X    set a
  342. X} 1
  343. Xtest scan-2.20 {floating-point scanning} {
  344. X    set a {}; set b {}; set c {}; set d {}
  345. X    scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  346. X} 4
  347. Xtest scan-2.21 {floating-point scanning} {
  348. X    set a {}; set b {}; set c {}; set d {}
  349. X    scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  350. X    set a
  351. X} 4.6
  352. Xtest scan-2.22 {floating-point scanning} {
  353. X    set a {}; set b {}; set c {}; set d {}
  354. X    scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  355. X    set b
  356. X} 99999.7
  357. Xtest scan-2.23 {floating-point scanning} {
  358. X    set a {}; set b {}; set c {}; set d {}
  359. X    scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  360. X    set c
  361. X} 87.643
  362. Xtest scan-2.24 {floating-point scanning} {
  363. X    set a {}; set b {}; set c {}; set d {}
  364. X    scan "4.6 99999.7 876.43e-1 118" "%f %f %f %e" a b c d
  365. X    set d
  366. X} 118
  367. Xtest scan-2.25 {floating-point scanning} {
  368. X    set a {}; set b {}; set c {}; set d {}
  369. X    scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  370. X} 4
  371. Xtest scan-2.26 {floating-point scanning} {
  372. X    set a {}; set b {}; set c {}; set d {}
  373. X    scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  374. X    set a
  375. X} 1.2345
  376. Xtest scan-2.27 {floating-point scanning} {
  377. X    set a {}; set b {}; set c {}; set d {}
  378. X    scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  379. X    set b
  380. X} 0.697
  381. Xtest scan-2.28 {floating-point scanning} {
  382. X    set a {}; set b {}; set c {}; set d {}
  383. X    scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  384. X    set c
  385. X} 124
  386. Xtest scan-2.29 {floating-point scanning} {
  387. X    set a {}; set b {}; set c {}; set d {}
  388. X    scan "1.2345 697.0e-3 124 .00005" "%f %e %f %e" a b c d
  389. X    set d
  390. X} 5e-05
  391. Xtest scan-2.30 {floating-point scanning} {
  392. X    set a {}; set b {}; set c {}; set d {}
  393. X    scan "4.6abc" "%f %f %f %f" a b c d
  394. X} 1
  395. Xtest scan-2.31 {floating-point scanning} {
  396. X    set a {}; set b {}; set c {}; set d {}
  397. X    scan "4.6abc" "%f %f %f %f" a b c d
  398. X    set a
  399. X} 4.6
  400. Xtest scan-2.32 {floating-point scanning} {
  401. X    set a {}; set b {}; set c {}; set d {}
  402. X    scan "4.6abc" "%f %f %f %f" a b c d
  403. X    set b
  404. X} {}
  405. Xtest scan-2.33 {floating-point scanning} {
  406. X    set a {}; set b {}; set c {}; set d {}
  407. X    scan "4.6abc" "%f %f %f %f" a b c d
  408. X    set c
  409. X} {}
  410. Xtest scan-2.34 {floating-point scanning} {
  411. X    set a {}; set b {}; set c {}; set d {}
  412. X    scan "4.6abc" "%f %f %f %f" a b c d
  413. X    set d
  414. X} {}
  415. Xtest scan-2.35 {floating-point scanning} {
  416. X    set a {}; set b {}; set c {}; set d {}
  417. X    scan "4.6 5.2" "%f %f %f %f" a b c d
  418. X} 2
  419. Xtest scan-2.36 {floating-point scanning} {
  420. X    set a {}; set b {}; set c {}; set d {}
  421. X    scan "4.6 5.2" "%f %f %f %f" a b c d
  422. X    set a
  423. X} 4.6
  424. Xtest scan-2.37 {floating-point scanning} {
  425. X    set a {}; set b {}; set c {}; set d {}
  426. X    scan "4.6 5.2" "%f %f %f %f" a b c d
  427. X    set b
  428. X} 5.2
  429. Xtest scan-2.38 {floating-point scanning} {
  430. X    set a {}; set b {}; set c {}; set d {}
  431. X    scan "4.6 5.2" "%f %f %f %f" a b c d
  432. X    set c
  433. X} {}
  434. Xtest scan-2.39 {floating-point scanning} {
  435. X    set a {}; set b {}; set c {}; set d {}
  436. X    scan "4.6 5.2" "%f %f %f %f" a b c d
  437. X    set d
  438. X} {}
  439. X
  440. Xtest scan-3.1 {string and character scanning} {
  441. X    set a {}; set b {}; set c {}; set d {}
  442. X    scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  443. X} 4
  444. Xtest scan-3.2 {string and character scanning} {
  445. X    set a {}; set b {}; set c {}; set d {}
  446. X    scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  447. X    set a
  448. X} abc
  449. Xtest scan-3.3 {string and character scanning} {
  450. X    set a {}; set b {}; set c {}; set d {}
  451. X    scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  452. X    set b
  453. X} def
  454. Xtest scan-3.4 {string and character scanning} {
  455. X    set a {}; set b {}; set c {}; set d {}
  456. X    scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  457. X    set c
  458. X} ghijk
  459. Xtest scan-3.5 {string and character scanning} {
  460. X    set a {}; set b {}; set c {}; set d {}
  461. X    scan "abc defghijk dum " "%s %3s %20s %s" a b c d
  462. X    set d
  463. X} dum
  464. Xtest scan-3.6 {string and character scanning} {
  465. X    set a {}; set b {}; set c {}; set d {}
  466. X    scan "a       bcdef" "%c%c%1s %s" a b c d
  467. X} 4
  468. Xtest scan-3.7 {string and character scanning} {
  469. X    set a {}; set b {}; set c {}; set d {}
  470. X    scan "a       bcdef" "%c%c%1s %s" a b c d
  471. X    set a
  472. X} 97
  473. Xtest scan-3.8 {string and character scanning} {
  474. X    set a {}; set b {}; set c {}; set d {}
  475. X    scan "a       bcdef" "%c%c%1s %s" a b c d
  476. X    set b
  477. X} 32
  478. Xtest scan-3.9 {string and character scanning} {
  479. X    set a {}; set b {}; set c {}; set d {}
  480. X    scan "a       bcdef" "%c%c%1s %s" a b c d
  481. X    set c
  482. X} b
  483. Xtest scan-3.10 {string and character scanning} {
  484. X    set a {}; set b {}; set c {}; set d {}
  485. X    scan "a       bcdef" "%c%c%1s %s" a b c d
  486. X    set d
  487. X} cdef
  488. Xtest scan-3.11 {string and character scanning} {
  489. X    set a {}; set b {}; set c {}
  490. X    scan "123456 test " "%*c%*s %s %s %s" a b c
  491. X} 1
  492. Xtest scan-3.12 {string and character scanning} {
  493. X    set a {}; set b {}; set c {}
  494. X    scan "123456 test " "%*c%*s %s %s %s" a b c
  495. X    set a
  496. X} test
  497. Xtest scan-3.13 {string and character scanning} {
  498. X    set a {}; set b {}; set c {}
  499. X    scan "123456 test " "%*c%*s %s %s %s" a b c
  500. X    set b
  501. X} {}
  502. Xtest scan-3.14 {string and character scanning} {
  503. X    set a {}; set b {}; set c {}
  504. X    scan "123456 test " "%*c%*s %s %s %s" a b c
  505. X    set c
  506. X} {}
  507. Xtest scan-3.15 {string and character scanning} {
  508. X    set a {}; set b {}; set c {}; set d
  509. X    scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  510. X} 4
  511. Xtest scan-3.16 {string and character scanning} {
  512. X    set a {}; set b {}; set c {}; set d
  513. X    scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  514. X    set a
  515. X} abab
  516. Xtest scan-3.17 {string and character scanning} {
  517. X    set a {}; set b {}; set c {}; set d
  518. X    scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  519. X    set b
  520. X} cd
  521. Xtest scan-3.18 {string and character scanning} {
  522. X    set a {}; set b {}; set c {}; set d
  523. X    scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  524. X    set c
  525. X} {01234  }
  526. Xtest scan-3.19 {string and character scanning} {
  527. X    set a {}; set b {}; set c {}; set d
  528. X    scan "ababcd01234  f 123450" {%4[abcd] %4[abcd] %[^abcdef] %[^0]} a b c d
  529. X    set d
  530. X} {f 12345}
  531. Xtest scan-3.20 {string and character scanning} {
  532. X    set a {}; set b {}; set c {}
  533. X    scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  534. X} 3
  535. Xtest scan-3.21 {string and character scanning} {
  536. X    set a {}; set b {}; set c {}
  537. X    scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  538. X    set a
  539. X} aabc
  540. Xtest scan-3.22 {string and character scanning} {
  541. X    set a {}; set b {}; set c {}
  542. X    scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  543. X    set b
  544. X} bcdefg
  545. Xtest scan-3.23 {string and character scanning} {
  546. X    set a {}; set b {}; set c {}
  547. X    scan "aaaaaabc aaabcdefg  + +  XYZQR" {%*4[a] %s %*4[a]%s%*4[ +]%c} a b c
  548. X    set c
  549. X} 43
  550. X
  551. Xtest scan-4.1 {error conditions} {
  552. X    catch {scan a}
  553. X} 1
  554. Xtest scan-4.2 {error conditions} {
  555. X    catch {scan a} msg
  556. X    set msg
  557. X} {wrong # args: should be "scan string format ?varName varName ...?"}
  558. Xtest scan-4.3 {error conditions} {
  559. X    catch {scan "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21" \
  560. X"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" \
  561. Xa1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21}
  562. X} 1
  563. Xtest scan-4.4 {error conditions} {
  564. X    catch {scan "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21" \
  565. X"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" \
  566. Xa1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21} msg
  567. X    set msg
  568. X} {too many fields to scan}
  569. Xtest scan-4.5 {error conditions} {
  570. X    catch {scan a %z}
  571. X} 1
  572. Xtest scan-4.6 {error conditions} {
  573. X    catch {scan a %z} msg
  574. X    set msg
  575. X} {bad scan conversion character "z"}
  576. Xtest scan-4.7 {error conditions} {
  577. X    catch {scan a "%d %d" a}
  578. X} 1
  579. Xtest scan-4.8 {error conditions} {
  580. X    catch {scan a "%d %d" a} msg
  581. X    set msg
  582. X} {different numbers of variable names and field specifiers}
  583. Xtest scan-4.9 {error conditions} {
  584. X    catch {scan a "%d %d" a b c}
  585. X} 1
  586. Xtest scan-4.10 {error conditions} {
  587. X    catch {scan a "%d %d" a b c} msg
  588. X    set msg
  589. X} {different numbers of variable names and field specifiers}
  590. Xtest scan-4.11 {error conditions} {
  591. X    set a {}; set b {}; set c {}; set d {}
  592. X    expr {[scan "  a" " a %d %d %d %d" a b c d] <= 0}
  593. X} 1
  594. Xtest scan-4.12 {error conditions} {
  595. X    set a {}; set b {}; set c {}; set d {}
  596. X    scan "  a" " a %d %d %d %d" a b c d
  597. X    set a
  598. X} {}
  599. Xtest scan-4.13 {error conditions} {
  600. X    set a {}; set b {}; set c {}; set d {}
  601. X    scan "  a" " a %d %d %d %d" a b c d
  602. X    set b
  603. X} {}
  604. Xtest scan-4.14 {error conditions} {
  605. X    set a {}; set b {}; set c {}; set d {}
  606. X    scan "  a" " a %d %d %d %d" a b c d
  607. X    set c
  608. X} {}
  609. Xtest scan-4.15 {error conditions} {
  610. X    set a {}; set b {}; set c {}; set d {}
  611. X    scan "  a" " a %d %d %d %d" a b c d
  612. X    set d
  613. X} {}
  614. Xtest scan-4.16 {error conditions} {
  615. X    set a {}; set b {}; set c {}; set d {}
  616. X    scan "1 2" "%d %d %d %d" a b c d
  617. X} 2
  618. Xtest scan-4.17 {error conditions} {
  619. X    set a {}; set b {}; set c {}; set d {}
  620. X    scan "1 2" "%d %d %d %d" a b c d
  621. X    set a
  622. X} 1
  623. Xtest scan-4.18 {error conditions} {
  624. X    set a {}; set b {}; set c {}; set d {}
  625. X    scan "1 2" "%d %d %d %d" a b c d
  626. X    set b
  627. X} 2
  628. Xtest scan-4.19 {error conditions} {
  629. X    set a {}; set b {}; set c {}; set d {}
  630. X    scan "1 2" "%d %d %d %d" a b c d
  631. X    set c
  632. X} {}
  633. Xtest scan-4.20 {error conditions} {
  634. X    set a {}; set b {}; set c {}; set d {}
  635. X    scan "1 2" "%d %d %d %d" a b c d
  636. X    set d
  637. X} {}
  638. Xtest scan-4.21 {error conditions} {
  639. X    catch {unset a}
  640. X    set a(0) 44
  641. X    list [catch {scan 44 %d a} msg] $msg
  642. X} {1 {couldn't set variable "a"}}
  643. Xtest scan-4.22 {error conditions} {
  644. X    catch {unset a}
  645. X    set a(0) 44
  646. X    list [catch {scan 44 %c a} msg] $msg
  647. X} {1 {couldn't set variable "a"}}
  648. Xtest scan-4.23 {error conditions} {
  649. X    catch {unset a}
  650. X    set a(0) 44
  651. X    list [catch {scan 44 %s a} msg] $msg
  652. X} {1 {couldn't set variable "a"}}
  653. Xtest scan-4.24 {error conditions} {
  654. X    catch {unset a}
  655. X    set a(0) 44
  656. X    list [catch {scan 44 %f a} msg] $msg
  657. X} {1 {couldn't set variable "a"}}
  658. Xtest scan-4.25 {error conditions} {
  659. X    catch {unset a}
  660. X    set a(0) 44
  661. X    list [catch {scan 44 %f a} msg] $msg
  662. X} {1 {couldn't set variable "a"}}
  663. Xcatch {unset a}
  664. Xtest scan-4.26 {error conditions} {
  665. X    list [catch {scan 44 %2c a} msg] $msg
  666. X} {1 {field width may not be specified in %c conversion}}
  667. X
  668. Xtest scan-5.1 {lots of arguments} {
  669. X    scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 \
  670. X200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 \
  671. Xa4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
  672. X} 20
  673. Xtest scan-5.2 {lots of arguments} {
  674. X    scan "10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 \
  675. X200" "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d" a1 a2 a3 \
  676. Xa4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20
  677. X    set a20
  678. X} 200
  679. END_OF_FILE
  680. if test 20188 -ne `wc -c <'tcl6.1/tests/scan.test'`; then
  681.     echo shar: \"'tcl6.1/tests/scan.test'\" unpacked with wrong size!
  682. fi
  683. # end of 'tcl6.1/tests/scan.test'
  684. fi
  685. if test -f 'tcl6.1/tests/trace.test' -a "${1}" != "-c" ; then 
  686.   echo shar: Will not clobber existing file \"'tcl6.1/tests/trace.test'\"
  687. else
  688. echo shar: Extracting \"'tcl6.1/tests/trace.test'\" \(20398 characters\)
  689. sed "s/^X//" >'tcl6.1/tests/trace.test' <<'END_OF_FILE'
  690. X# Commands covered:  trace
  691. X#
  692. X# This file contains a collection of tests for one or more of the Tcl
  693. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  694. X# generates output for errors.  No output means no errors were found.
  695. X#
  696. X# Copyright 1991 Regents of the University of California
  697. X# Permission to use, copy, modify, and distribute this
  698. X# software and its documentation for any purpose and without
  699. X# fee is hereby granted, provided that this copyright notice
  700. X# appears in all copies.  The University of California makes no
  701. X# representations about the suitability of this software for any
  702. X# purpose.  It is provided "as is" without express or implied
  703. X# warranty.
  704. X#
  705. X# $Header: /user6/ouster/tcl/tests/RCS/trace.test,v 1.11 91/10/31 16:40:51 ouster Exp $ (Berkeley)
  706. X
  707. Xif {[string compare test [info procs test]] == 1} then {source defs}
  708. X
  709. Xproc traceScalar {name1 name2 op} {
  710. X    global info
  711. X    set info [list $name1 $name2 $op [catch {uplevel set $name1} msg] $msg]
  712. X}
  713. Xproc traceArray {name1 name2 op} {
  714. X    global info
  715. X    set info [list $name1 $name2 $op [catch {uplevel set [set name1]($name2)} msg] $msg]
  716. X}
  717. Xproc traceProc {name1 name2 op} {
  718. X    global info
  719. X    set info [concat $info [list $name1 $name2 $op]]
  720. X}
  721. Xproc traceTag {tag args} {
  722. X    global info
  723. X    set info [concat $info $tag]
  724. X}
  725. Xproc traceError {args} {
  726. X    error error
  727. X}
  728. Xproc traceCheck {cmd args} {
  729. X    global info
  730. X    set info [list [catch $cmd msg] $msg]
  731. X}
  732. X
  733. X# Read-tracing on variables
  734. X
  735. Xtest trace-1.1 {trace variable reads} {
  736. X    catch {unset x}
  737. X    set info {}
  738. X    trace var x r traceScalar
  739. X    list [catch {set x} msg] $msg $info
  740. X} {1 {can't read "x": no such variable} {x {} r 1 {can't read "x": no such variable}}}
  741. Xtest trace-1.2 {trace variable reads} {
  742. X    catch {unset x}
  743. X    set x 123
  744. X    set info {}
  745. X    trace var x r traceScalar
  746. X    list [catch {set x} msg] $msg $info
  747. X} {0 123 {x {} r 0 123}}
  748. Xtest trace-1.3 {trace variable reads} {
  749. X    catch {unset x}
  750. X    set info {}
  751. X    trace var x r traceScalar
  752. X    set x 123
  753. X    set info
  754. X} {}
  755. Xtest trace-1.4 {trace array element reads} {
  756. X    catch {unset x}
  757. X    set info {}
  758. X    trace var x(2) r traceArray
  759. X    list [catch {set x(2)} msg] $msg $info
  760. X} {1 {can't read "x(2)": no such variable} {x 2 r 1 {can't read "x(2)": no such variable}}}
  761. Xtest trace-1.5 {trace array element reads} {
  762. X    catch {unset x}
  763. X    set x(2) zzz
  764. X    set info {}
  765. X    trace var x(2) r traceArray
  766. X    list [catch {set x(2)} msg] $msg $info
  767. X} {0 zzz {x 2 r 0 zzz}}
  768. Xtest trace-1.6 {trace reads on whole arrays} {
  769. X    catch {unset x}
  770. X    set info {}
  771. X    trace var x r traceArray
  772. X    list [catch {set x(2)} msg] $msg $info
  773. X} {1 {can't read "x(2)": no such variable} {}}
  774. Xtest trace-1.7 {trace reads on whole arrays} {
  775. X    catch {unset x}
  776. X    set x(2) zzz
  777. X    set info {}
  778. X    trace var x r traceArray
  779. X    list [catch {set x(2)} msg] $msg $info
  780. X} {0 zzz {x 2 r 0 zzz}}
  781. Xtest trace-1.8 {trace variable reads} {
  782. X    catch {unset x}
  783. X    set x 444
  784. X    set info {}
  785. X    trace var x r traceScalar
  786. X    unset x
  787. X    set info
  788. X} {}
  789. X
  790. X# Basic write-tracing on variables
  791. X
  792. Xtest trace-2.1 {trace variable writes} {
  793. X    catch {unset x}
  794. X    set info {}
  795. X    trace var x w traceScalar
  796. X    set x 123
  797. X    set info
  798. X} {x {} w 0 123}
  799. Xtest trace-2.2 {trace writes to array elements} {
  800. X    catch {unset x}
  801. X    set info {}
  802. X    trace var x(33) w traceArray
  803. X    set x(33) 444
  804. X    set info
  805. X} {x 33 w 0 444}
  806. Xtest trace-2.3 {trace writes on whole arrays} {
  807. X    catch {unset x}
  808. X    set info {}
  809. X    trace var x w traceArray
  810. X    set x(abc) qq
  811. X    set info
  812. X} {x abc w 0 qq}
  813. Xtest trace-2.4 {trace variable writes} {
  814. X    catch {unset x}
  815. X    set x 1234
  816. X    set info {}
  817. X    trace var x w traceScalar
  818. X    set x
  819. X    set info
  820. X} {}
  821. Xtest trace-2.5 {trace variable writes} {
  822. X    catch {unset x}
  823. X    set x 1234
  824. X    set info {}
  825. X    trace var x w traceScalar
  826. X    unset x
  827. X    set info
  828. X} {}
  829. X
  830. X# Basic unset-tracing on variables
  831. X
  832. Xtest trace-3.1 {trace variable unsets} {
  833. X    catch {unset x}
  834. X    set info {}
  835. X    trace var x u traceScalar
  836. X    catch {unset x}
  837. X    set info
  838. X} {x {} u 1 {can't read "x": no such variable}}
  839. Xtest trace-3.2 {variable mustn't exist during unset trace} {
  840. X    catch {unset x}
  841. X    set x 1234
  842. X    set info {}
  843. X    trace var x u traceScalar
  844. X    unset x
  845. X    set info
  846. X} {x {} u 1 {can't read "x": no such variable}}
  847. Xtest trace-3.3 {unset traces mustn't be called during reads and writes} {
  848. X    catch {unset x}
  849. X    set info {}
  850. X    trace var x u traceScalar
  851. X    set x 44
  852. X    set x
  853. X    set info
  854. X} {}
  855. Xtest trace-3.4 {trace unsets on array elements} {
  856. X    catch {unset x}
  857. X    set x(0) 18
  858. X    set info {}
  859. X    trace var x(1) u traceArray
  860. X    catch {unset x(1)}
  861. X    set info
  862. X} {x 1 u 1 {can't read "x(1)": no such element in array}}
  863. Xtest trace-3.5 {trace unsets on array elements} {
  864. X    catch {unset x}
  865. X    set x(1) 18
  866. X    set info {}
  867. X    trace var x(1) u traceArray
  868. X    unset x(1)
  869. X    set info
  870. X} {x 1 u 1 {can't read "x(1)": no such element in array}}
  871. Xtest trace-3.6 {trace unsets on array elements} {
  872. X    catch {unset x}
  873. X    set x(1) 18
  874. X    set info {}
  875. X    trace var x(1) u traceArray
  876. X    unset x
  877. X    set info
  878. X} {x 1 u 1 {can't read "x(1)": no such variable}}
  879. Xtest trace-3.7 {trace unsets on whole arrays} {
  880. X    catch {unset x}
  881. X    set x(1) 18
  882. X    set info {}
  883. X    trace var x u traceProc
  884. X    catch {unset x(0)}
  885. X    set info
  886. X} {}
  887. Xtest trace-3.8 {trace unsets on whole arrays} {
  888. X    catch {unset x}
  889. X    set x(1) 18
  890. X    set info {}
  891. X    trace var x u traceProc
  892. X    unset x(1)
  893. X    set info
  894. X} {x 1 u}
  895. Xtest trace-3.9 {trace unsets on whole arrays} {
  896. X    catch {unset x}
  897. X    set x(1) 18
  898. X    set info {}
  899. X    trace var x u traceProc
  900. X    unset x
  901. X    set info
  902. X} {x {} u}
  903. X
  904. X# Trace multiple trace types at once.
  905. X
  906. Xtest trace-4.1 {multiple ops traced at once} {
  907. X    catch {unset x}
  908. X    set info {}
  909. X    trace var x rwu traceProc
  910. X    catch {set x}
  911. X    set x 22
  912. X    set x
  913. X    set x 33
  914. X    unset x
  915. X    set info
  916. X} {x {} r x {} w x {} r x {} w x {} u}
  917. Xtest trace-4.2 {multiple ops traced on array element} {
  918. X    catch {unset x}
  919. X    set info {}
  920. X    trace var x(0) rwu traceProc
  921. X    catch {set x(0)}
  922. X    set x(0) 22
  923. X    set x(0)
  924. X    set x(0) 33
  925. X    unset x(0)
  926. X    unset x
  927. X    set info
  928. X} {x 0 r x 0 w x 0 r x 0 w x 0 u}
  929. Xtest trace-4.3 {multiple ops traced on whole array} {
  930. X    catch {unset x}
  931. X    set info {}
  932. X    trace var x rwu traceProc
  933. X    catch {set x(0)}
  934. X    set x(0) 22
  935. X    set x(0)
  936. X    set x(0) 33
  937. X    unset x(0)
  938. X    unset x
  939. X    set info
  940. X} {x 0 w x 0 r x 0 w x 0 u x {} u}
  941. X
  942. X# Check order of invocation of traces
  943. X
  944. Xtest trace-5.1 {order of invocation of traces} {
  945. X    catch {unset x}
  946. X    set info {}
  947. X    trace var x r "traceTag 1"
  948. X    trace var x r "traceTag 2"
  949. X    trace var x r "traceTag 3"
  950. X    catch {set x}
  951. X    set x 22
  952. X    set x
  953. X    set info
  954. X} {3 2 1 3 2 1}
  955. Xtest trace-5.2 {order of invocation of traces} {
  956. X    catch {unset x}
  957. X    set x(0) 44
  958. X    set info {}
  959. X    trace var x(0) r "traceTag 1"
  960. X    trace var x(0) r "traceTag 2"
  961. X    trace var x(0) r "traceTag 3"
  962. X    set x(0)
  963. X    set info
  964. X} {3 2 1}
  965. Xtest trace-5.3 {order of invocation of traces} {
  966. X    catch {unset x}
  967. X    set x(0) 44
  968. X    set info {}
  969. X    trace var x(0) r "traceTag 1"
  970. X    trace var x r "traceTag A1"
  971. X    trace var x(0) r "traceTag 2"
  972. X    trace var x r "traceTag A2"
  973. X    trace var x(0) r "traceTag 3"
  974. X    trace var x r "traceTag A3"
  975. X    set x(0)
  976. X    set info
  977. X} {A3 A2 A1 3 2 1}
  978. X
  979. X# Check effects of errors in trace procedures
  980. X
  981. Xtest trace-6.1 {error returns from traces} {
  982. X    catch {unset x}
  983. X    set x 123
  984. X    set info {}
  985. X    trace var x r "traceTag 1"
  986. X    trace var x r error
  987. X    list [catch {set x} msg] $msg $info
  988. X} {1 {can't read "x": access disallowed by trace command} {}}
  989. Xtest trace-6.2 {error returns from traces} {
  990. X    catch {unset x}
  991. X    set x 123
  992. X    set info {}
  993. X    trace var x w "traceTag 1"
  994. X    trace var x w error
  995. X    list [catch {set x 44} msg] $msg $info
  996. X} {1 {can't set "x": access disallowed by trace command} {}}
  997. Xtest trace-6.3 {error returns from traces} {
  998. X    catch {unset x}
  999. X    set x 123
  1000. X    set info {}
  1001. X    trace var x u "traceTag 1"
  1002. X    trace var x u error
  1003. X    list [catch {unset x} msg] $msg $info
  1004. X} {0 {} 1}
  1005. Xtest trace-6.4 {error returns from traces} {
  1006. X    catch {unset x}
  1007. X    set x(0) 123
  1008. X    set info {}
  1009. X    trace var x(0) r "traceTag 1"
  1010. X    trace var x r "traceTag 2"
  1011. X    trace var x r error
  1012. X    trace var x r "traceTag 3"
  1013. X    list [catch {set x(0)} msg] $msg $info
  1014. X} {1 {can't read "x(0)": access disallowed by trace command} 3}
  1015. X
  1016. X# Check to see that variables are expunged before trace
  1017. X# procedures are invoked, so trace procedure can even manipulate
  1018. X# a new copy of the variables.
  1019. X
  1020. Xtest trace-7.1 {be sure variable is unset before trace is called} {
  1021. X    catch {unset x}
  1022. X    set x 33
  1023. X    set info {}
  1024. X    trace var x u {traceCheck {uplevel set x}}
  1025. X    unset x
  1026. X    set info
  1027. X} {1 {can't read "x": no such variable}}
  1028. Xtest trace-7.2 {be sure variable is unset before trace is called} {
  1029. X    catch {unset x}
  1030. X    set x 33
  1031. X    set info {}
  1032. X    trace var x u {traceCheck {uplevel set x 22}}
  1033. X    unset x
  1034. X    concat $info [list [catch {set x} msg] $msg]
  1035. X} {0 22 0 22}
  1036. Xtest trace-7.3 {be sure traces are cleared before unset trace called} {
  1037. X    catch {unset x}
  1038. X    set x 33
  1039. X    set info {}
  1040. X    trace var x u {traceCheck {uplevel trace vinfo x}}
  1041. X    unset x
  1042. X    set info
  1043. X} {0 {}}
  1044. Xtest trace-7.4 {set new trace during unset trace} {
  1045. X    catch {unset x}
  1046. X    set x 33
  1047. X    set info {}
  1048. X    trace var x u {traceCheck {global x; trace var x u traceProc}}
  1049. X    unset x
  1050. X    concat $info [trace vinfo x]
  1051. X} {0 {} {u traceProc}}
  1052. X
  1053. Xtest trace-8.1 {make sure array elements are unset before traces are called} {
  1054. X    catch {unset x}
  1055. X    set x(0) 33
  1056. X    set info {}
  1057. X    trace var x(0) u {traceCheck {uplevel set x(0)}}
  1058. X    unset x(0)
  1059. X    set info
  1060. X} {1 {can't read "x(0)": no such element in array}}
  1061. Xtest trace-8.2 {make sure array elements are unset before traces are called} {
  1062. X    catch {unset x}
  1063. X    set x(0) 33
  1064. X    set info {}
  1065. X    trace var x(0) u {traceCheck {uplevel set x(0) zzz}}
  1066. X    unset x(0)
  1067. X    concat $info [list [catch {set x(0)} msg] $msg]
  1068. X} {0 zzz 0 zzz}
  1069. Xtest trace-8.3 {array elements are unset before traces are called} {
  1070. X    catch {unset x}
  1071. X    set x(0) 33
  1072. X    set info {}
  1073. X    trace var x(0) u {traceCheck {global x; trace vinfo x(0)}}
  1074. X    unset x(0)
  1075. X    set info
  1076. X} {0 {}}
  1077. Xtest trace-8.4 {set new array element trace during unset trace} {
  1078. X    catch {unset x}
  1079. X    set x(0) 33
  1080. X    set info {}
  1081. X    trace var x(0) u {traceCheck {uplevel {trace variable x(0) r {}}}}
  1082. X    catch {unset x(0)}
  1083. X    concat $info [trace vinfo x(0)]
  1084. X} {0 {} {r {}}}
  1085. X
  1086. Xtest trace-9.1 {make sure arrays are unset before traces are called} {
  1087. X    catch {unset x}
  1088. X    set x(0) 33
  1089. X    set info {}
  1090. X    trace var x u {traceCheck {uplevel set x(0)}}
  1091. X    unset x
  1092. X    set info
  1093. X} {1 {can't read "x(0)": no such variable}}
  1094. Xtest trace-9.2 {make sure arrays are unset before traces are called} {
  1095. X    catch {unset x}
  1096. X    set x(y) 33
  1097. X    set info {}
  1098. X    trace var x u {traceCheck {uplevel set x(y) 22}}
  1099. X    unset x
  1100. X    concat $info [list [catch {set x(y)} msg] $msg]
  1101. X} {0 22 0 22}
  1102. Xtest trace-9.3 {make sure arrays are unset before traces are called} {
  1103. X    catch {unset x}
  1104. X    set x(y) 33
  1105. X    set info {}
  1106. X    trace var x u {traceCheck {uplevel array names x}}
  1107. X    unset x
  1108. X    set info
  1109. X} {1 {"x" isn't an array}}
  1110. Xtest trace-9.4 {make sure arrays are unset before traces are called} {
  1111. X    catch {unset x}
  1112. X    set x(y) 33
  1113. X    set info {}
  1114. X    set cmd {traceCheck {uplevel {trace vinfo x}}}
  1115. X    trace var x u $cmd
  1116. X    unset x
  1117. X    set info
  1118. X} {0 {}}
  1119. Xtest trace-9.5 {set new array trace during unset trace} {
  1120. X    catch {unset x}
  1121. X    set x(y) 33
  1122. X    set info {}
  1123. X    trace var x u {traceCheck {global x; trace var x r {}}}
  1124. X    unset x
  1125. X    concat $info [trace vinfo x]
  1126. X} {0 {} {r {}}}
  1127. Xtest trace-9.6 {create scalar during array unset trace} {
  1128. X    catch {unset x}
  1129. X    set x(y) 33
  1130. X    set info {}
  1131. X    trace var x u {traceCheck {global x; set x 44}}
  1132. X    unset x
  1133. X    concat $info [list [catch {set x} msg] $msg]
  1134. X} {0 44 0 44}
  1135. X
  1136. X# Check special conditions (e.g. errors) in Tcl_TraceVar2.
  1137. X
  1138. Xtest trace-10.1 {creating array when setting variable traces} {
  1139. X    catch {unset x}
  1140. X    set info {}
  1141. X    trace var x(0) w traceProc
  1142. X    list [catch {set x 22} msg] $msg
  1143. X} {1 {can't set "x": variable is array}}
  1144. Xtest trace-10.2 {creating array when setting variable traces} {
  1145. X    catch {unset x}
  1146. X    set info {}
  1147. X    trace var x(0) w traceProc
  1148. X    list [catch {set x(0)} msg] $msg
  1149. X} {1 {can't read "x(0)": no such variable}}
  1150. Xtest trace-10.3 {creating array when setting variable traces} {
  1151. X    catch {unset x}
  1152. X    set info {}
  1153. X    trace var x(0) w traceProc
  1154. X    set x(0) 22
  1155. X    set info
  1156. X} {x 0 w}
  1157. Xtest trace-10.4 {creating variable when setting variable traces} {
  1158. X    catch {unset x}
  1159. X    set info {}
  1160. X    trace var x w traceProc
  1161. X    list [catch {set x} msg] $msg
  1162. X} {1 {can't read "x": no such variable}}
  1163. Xtest trace-10.5 {creating variable when setting variable traces} {
  1164. X    catch {unset x}
  1165. X    set info {}
  1166. X    trace var x w traceProc
  1167. X    set x 22
  1168. X    set info
  1169. X} {x {} w}
  1170. Xtest trace-10.6 {creating variable when setting variable traces} {
  1171. X    catch {unset x}
  1172. X    set info {}
  1173. X    trace var x w traceProc
  1174. X    set x(0) 22
  1175. X    set info
  1176. X} {x 0 w}
  1177. Xtest trace-10.7 {errors when setting variable traces} {
  1178. X    catch {unset x}
  1179. X    set x 44
  1180. X    list [catch {trace var x(0) w traceProc} msg] $msg
  1181. X} {1 {variable isn't array}}
  1182. X
  1183. X# Check deleting one trace from another.
  1184. X
  1185. Xtest trace-11.1 {delete one trace from another} {
  1186. X    proc delTraces {args} {
  1187. X    global x
  1188. X    trace vdel x r {traceTag 2}
  1189. X    trace vdel x r {traceTag 3}
  1190. X    trace vdel x r {traceTag 4}
  1191. X    }
  1192. X    catch {unset x}
  1193. X    set x 44
  1194. X    set info {}
  1195. X    trace var x r {traceTag 1}
  1196. X    trace var x r {traceTag 2}
  1197. X    trace var x r {traceTag 3}
  1198. X    trace var x r {traceTag 4}
  1199. X    trace var x r delTraces 
  1200. X    trace var x r {traceTag 5}
  1201. X    set x
  1202. X    set info
  1203. X} {5 1}
  1204. X
  1205. X# Check operation and syntax of "trace" command.
  1206. X
  1207. Xtest trace-12.1 {trace command (overall)} {
  1208. X    list [catch {trace} msg] $msg
  1209. X} {1 {too few args: should be "trace option [arg arg ...]"}}
  1210. Xtest trace-12.2 {trace command (overall)} {
  1211. X    list [catch {trace gorp} msg] $msg
  1212. X} {1 {bad option "gorp": should be variable, vdelete, or vinfo}}
  1213. Xtest trace-12.3 {trace command ("variable" option)} {
  1214. X    list [catch {trace variable x y} msg] $msg
  1215. X} {1 {wrong # args: should be "trace variable name ops command"}}
  1216. Xtest trace-12.4 {trace command ("variable" option)} {
  1217. X    list [catch {trace var x y z z2} msg] $msg
  1218. X} {1 {wrong # args: should be "trace variable name ops command"}}
  1219. Xtest trace-12.5 {trace command ("variable" option)} {
  1220. X    list [catch {trace var x y z} msg] $msg
  1221. X} {1 {bad operations "y": should be one or more of rwu}}
  1222. Xtest trace-12.6 {trace command ("vdelete" option)} {
  1223. X    list [catch {trace vdelete x y} msg] $msg
  1224. X} {1 {wrong # args: should be "trace vdelete name ops command"}}
  1225. Xtest trace-12.7 {trace command ("vdelete" option)} {
  1226. X    list [catch {trace vdelete x y z foo} msg] $msg
  1227. X} {1 {wrong # args: should be "trace vdelete name ops command"}}
  1228. Xtest trace-12.8 {trace command ("vdelete" option)} {
  1229. X    list [catch {trace vdelete x y z} msg] $msg
  1230. X} {1 {bad operations "y": should be one or more of rwu}}
  1231. Xtest trace-12.9 {trace command ("vdelete" option)} {
  1232. X    catch {unset x}
  1233. X    set info {}
  1234. X    trace var x w traceProc
  1235. X    trace vdelete x w traceProc
  1236. X} {}
  1237. Xtest trace-12.10 {trace command ("vdelete" option)} {
  1238. X    catch {unset x}
  1239. X    set info {}
  1240. X    trace var x w traceProc
  1241. X    trace vdelete x w traceProc
  1242. X    set x 12345
  1243. X    set info
  1244. X} {}
  1245. Xtest trace-12.11 {trace command ("vdelete" option)} {
  1246. X    catch {unset x}
  1247. X    set info {}
  1248. X    trace var x w {traceTag 1}
  1249. X    trace var x w traceProc
  1250. X    trace var x w {traceTag 2}
  1251. X    set x yy
  1252. X    trace vdelete x w traceProc
  1253. X    set x 12345
  1254. X    trace vdelete x w {traceTag 1}
  1255. X    set x foo
  1256. X    trace vdelete x w {traceTag 2}
  1257. X    set x gorp
  1258. X    set info
  1259. X} {2 x {} w 1 2 1 2}
  1260. Xtest trace-12.12 {trace command ("vdelete" option)} {
  1261. X    catch {unset x}
  1262. X    set info {}
  1263. X    trace var x w {traceTag 1}
  1264. X    trace vdelete x w non_existent
  1265. X    set x 12345
  1266. X    set info
  1267. X} {1}
  1268. Xtest trace-12.13 {trace command ("vinfo" option)} {
  1269. X    list [catch {trace vinfo} msg] $msg]
  1270. X} {1 {wrong # args: should be "trace vinfo name"]}}
  1271. Xtest trace-12.14 {trace command ("vinfo" option)} {
  1272. X    list [catch {trace vinfo x y} msg] $msg]
  1273. X} {1 {wrong # args: should be "trace vinfo name"]}}
  1274. Xtest trace-12.15 {trace command ("vinfo" option)} {
  1275. X    catch {unset x}
  1276. X    trace var x w {traceTag 1}
  1277. X    trace var x w traceProc
  1278. X    trace var x w {traceTag 2}
  1279. X    trace vinfo x
  1280. X} {{w {traceTag 2}} {w traceProc} {w {traceTag 1}}}
  1281. Xtest trace-12.16 {trace command ("vinfo" option)} {
  1282. X    catch {unset x}
  1283. X    trace vinfo x
  1284. X} {}
  1285. Xtest trace-12.17 {trace command ("vinfo" option)} {
  1286. X    catch {unset x}
  1287. X    trace vinfo x(0)
  1288. X} {}
  1289. Xtest trace-12.18 {trace command ("vinfo" option)} {
  1290. X    catch {unset x}
  1291. X    set x 44
  1292. X    trace vinfo x(0)
  1293. X} {}
  1294. Xtest trace-12.19 {trace command ("vinfo" option)} {
  1295. X    catch {unset x}
  1296. X    set x 44
  1297. X    trace var x w {traceTag 1}
  1298. X    proc check {} {global x; trace vinfo x}
  1299. X    check
  1300. X} {{w {traceTag 1}}}
  1301. X
  1302. X# Check fancy trace commands (long ones, weird arguments, etc.)
  1303. X
  1304. Xtest trace-13.1 {long trace command} {
  1305. X    catch {unset x}
  1306. X    set info {}
  1307. X    trace var x w {traceTag {This is a very very long argument.  It's \
  1308. X    designed to test out the facilities of TraceVarProc for dealing \
  1309. X    with such long arguments by malloc-ing space.  One possibility \
  1310. X    is that space doesn't get freed properly.  If this happens, then \
  1311. X    invoking this test over and over again will eventually leak memory.}}
  1312. X    set x 44
  1313. X    set info
  1314. X} {This is a very very long argument.  It's \
  1315. X    designed to test out the facilities of TraceVarProc for dealing \
  1316. X    with such long arguments by malloc-ing space.  One possibility \
  1317. X    is that space doesn't get freed properly.  If this happens, then \
  1318. X    invoking this test over and over again will eventually leak memory.}
  1319. Xtest trace-13.2 {long trace command result to ignore} {
  1320. X    proc longResult {args} {return "quite a bit of text, designed to
  1321. X    generate a core leak if this command file is invoked over and over again
  1322. X    and memory isn't being recycled correctly"}
  1323. X    catch {unset x}
  1324. X    trace var x w longResult
  1325. X    set x 44
  1326. X    set x 5
  1327. X    set x abcde
  1328. X} abcde
  1329. Xtest trace-13.3 {special list-handling in trace commands} {
  1330. X    catch {unset "x y z"}
  1331. X    set "x y z(a\n\{)" 44
  1332. X    set info {}
  1333. X    trace var "x y z(a\n\{)" w traceProc
  1334. X    set "x y z(a\n\{)" 33
  1335. X    set info
  1336. X} "{x y z} a\\n\{ w"
  1337. X
  1338. X# Check for things that are illegal while a trace is active (such
  1339. X# as deleting a variable).
  1340. X
  1341. Xtest trace-14.1 {unsets must be disallowed during traces} {
  1342. X    catch {unset x}
  1343. X    set x 123
  1344. X    set info {}
  1345. X    trace var x r {traceCheck {global x; unset x}}
  1346. X    set x
  1347. X    concat $info [list [catch {set x} msg] $msg]
  1348. X} {1 {can't unset "x": trace is active on variable} 0 123}
  1349. Xtest trace-14.2 {unsets must be disallowed during traces} {
  1350. X    catch {unset x}
  1351. X    set x 123
  1352. X    set info {}
  1353. X    trace var x r {traceCheck {uplevel {unset x}}}
  1354. X    set x
  1355. X    concat $info [list [catch {set x} msg] $msg]
  1356. X} {1 {can't unset "x": trace is active on variable} 0 123}
  1357. Xtest trace-14.3 {unsets must be disallowed during traces} {
  1358. X    catch {unset x}
  1359. X    set x(14) 123
  1360. X    set info {}
  1361. X    trace var x(14) r {traceCheck {uplevel {unset x}}}
  1362. X    set x(14)
  1363. X    concat $info [list [catch {set x(14)} msg] $msg]
  1364. X} {1 {can't unset "x": trace is active on variable} 0 123}
  1365. X
  1366. X# Check various non-interference between traces and other things.
  1367. X
  1368. Xtest trace-15.1 {trace doesn't prevent unset errors} {
  1369. X    catch {unset x}
  1370. X    set info {}
  1371. X    trace var x u {traceProc}
  1372. X    list [catch {unset x} msg] $msg $info
  1373. X} {1 {can't set "x": no such element in array} {x {} u}}
  1374. Xtest trace-15.2 {traced variables must survive procedure exits} {
  1375. X    catch {unset x}
  1376. X    proc p1 {} {global x; trace var x w traceProc}
  1377. X    p1
  1378. X    trace vinfo x
  1379. X} {{w traceProc}}
  1380. Xtest trace-15.3 {traced variables must survive procedure exits} {
  1381. X    catch {unset x}
  1382. X    set info {}
  1383. X    proc p1 {} {global x; trace var x w traceProc}
  1384. X    p1
  1385. X    set x 44
  1386. X    set info
  1387. X} {x {} w}
  1388. X
  1389. X# Be sure that procedure frames are released before unset traces
  1390. X# are invoked.
  1391. X
  1392. Xtest trace-16.1 {unset traces on procedure returns} {
  1393. X    proc p1 {x y} {set a 44; p2 14}
  1394. X    proc p2 {z} {trace var z u {traceCheck {lsort [uplevel {info vars}]}}}
  1395. X    set info {}
  1396. X    p1 foo bar
  1397. X    set info
  1398. X} {0 {a x y}}
  1399. X
  1400. X# Delete arrays when done, so they can be re-used as scalars
  1401. X# elsewhere.
  1402. X
  1403. Xcatch {unset x}
  1404. Xreturn ""
  1405. END_OF_FILE
  1406. if test 20398 -ne `wc -c <'tcl6.1/tests/trace.test'`; then
  1407.     echo shar: \"'tcl6.1/tests/trace.test'\" unpacked with wrong size!
  1408. fi
  1409. # end of 'tcl6.1/tests/trace.test'
  1410. fi
  1411. echo shar: End of archive 15 \(of 33\).
  1412. cp /dev/null ark15isdone
  1413. MISSING=""
  1414. 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
  1415.     if test ! -f ark${I}isdone ; then
  1416.     MISSING="${MISSING} ${I}"
  1417.     fi
  1418. done
  1419. if test "${MISSING}" = "" ; then
  1420.     echo You have unpacked all 33 archives.
  1421.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1422. else
  1423.     echo You still need to unpack the following archives:
  1424.     echo "        " ${MISSING}
  1425. fi
  1426. ##  End of shell archive.
  1427. exit 0
  1428.  
  1429. exit 0 # Just in case...
  1430. -- 
  1431. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1432. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1433. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1434. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1435.