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

  1. Newsgroups: comp.sources.misc
  2. From: karl@sugar.neosoft.com (Karl Lehenbauer)
  3. Subject:  v25i070:  tcl - tool command language, version 6.1, Part02/33
  4. Message-ID: <1991Nov14.202536.23156@sparky.imd.sterling.com>
  5. X-Md4-Signature: 743852cd0db93e77b02a0e4d85767fc5
  6. Date: Thu, 14 Nov 1991 20:25:36 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
  10. Posting-number: Volume 25, Issue 70
  11. Archive-name: tcl/part02
  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 2 (of 33)."
  21. # Contents:  tcl6.1/compat/strtol.c tcl6.1/tclTest.c
  22. #   tcl6.1/tests/append.test tcl6.1/tests/case.test
  23. #   tcl6.1/tests/cd.test tcl6.1/tests/env.test tcl6.1/tests/incr.test
  24. #   tcl6.1/tests/lindex.test tcl6.1/tests/linsert.test
  25. #   tcl6.1/tests/list.test tcl6.1/tests/lrange.test
  26. #   tcl6.1/tests/lreplace.test tcl6.1/tests/rename.test
  27. #   tcl6.1/tests/source.test tcl6.1/tests/uplevel.test
  28. #   tcl6.1/tests/while.test
  29. # Wrapped by karl@one on Tue Nov 12 19:44:11 1991
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'tcl6.1/compat/strtol.c' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'tcl6.1/compat/strtol.c'\"
  33. else
  34. echo shar: Extracting \"'tcl6.1/compat/strtol.c'\" \(2267 characters\)
  35. sed "s/^X//" >'tcl6.1/compat/strtol.c' <<'END_OF_FILE'
  36. X/* 
  37. X * strtol.c --
  38. X *
  39. X *    Source code for the "strtol" library procedure.
  40. X *
  41. X * Copyright 1988 Regents of the University of California
  42. X * Permission to use, copy, modify, and distribute this
  43. X * software and its documentation for any purpose and without
  44. X * fee is hereby granted, provided that the above copyright
  45. X * notice appear in all copies.  The University of California
  46. X * makes no representations about the suitability of this
  47. X * software for any purpose.  It is provided "as is" without
  48. X * express or implied warranty.
  49. X */
  50. X
  51. X#ifndef lint
  52. Xstatic char rcsid[] = "$Header: /sprite/src/lib/tcl/compat/RCS/strtol.c,v 1.1 91/09/22 15:42:49 ouster Exp $ SPRITE (Berkeley)";
  53. X#endif /* not lint */
  54. X
  55. X#include <ctype.h>
  56. X
  57. X
  58. X/*
  59. X *----------------------------------------------------------------------
  60. X *
  61. X * strtol --
  62. X *
  63. X *    Convert an ASCII string into an integer.
  64. X *
  65. X * Results:
  66. X *    The return value is the integer equivalent of string.  If endPtr
  67. X *    is non-NULL, then *endPtr is filled in with the character
  68. X *    after the last one that was part of the integer.  If string
  69. X *    doesn't contain a valid integer value, then zero is returned
  70. X *    and *endPtr is set to string.
  71. X *
  72. X * Side effects:
  73. X *    None.
  74. X *
  75. X *----------------------------------------------------------------------
  76. X */
  77. X
  78. Xlong int
  79. Xstrtol(string, endPtr, base)
  80. X    char *string;        /* String of ASCII digits, possibly
  81. X                 * preceded by white space.  For bases
  82. X                 * greater than 10, either lower- or
  83. X                 * upper-case digits may be used.
  84. X                 */
  85. X    char **endPtr;        /* Where to store address of terminating
  86. X                 * character, or NULL. */
  87. X    int base;            /* Base for conversion.  Must be less
  88. X                 * than 37.  If 0, then the base is chosen
  89. X                 * from the leading characters of string:
  90. X                 * "0x" means hex, "0" means octal, anything
  91. X                 * else means decimal.
  92. X                 */
  93. X{
  94. X    register char *p;
  95. X    int result;
  96. X
  97. X    /*
  98. X     * Skip any leading blanks.
  99. X     */
  100. X
  101. X    p = string;
  102. X    while (isspace(*p)) {
  103. X    p += 1;
  104. X    }
  105. X
  106. X    /*
  107. X     * Check for a sign.
  108. X     */
  109. X
  110. X    if (*p == '-') {
  111. X    p += 1;
  112. X    result = -(strtoul(p, endPtr, base));
  113. X    } else {
  114. X    if (*p == '+') {
  115. X        p += 1;
  116. X    }
  117. X    result = strtoul(p, endPtr, base);
  118. X    }
  119. X    if ((result == 0) && (endPtr != 0) && (*endPtr == p)) {
  120. X    *endPtr = string;
  121. X    }
  122. X    return result;
  123. X}
  124. END_OF_FILE
  125. if test 2267 -ne `wc -c <'tcl6.1/compat/strtol.c'`; then
  126.     echo shar: \"'tcl6.1/compat/strtol.c'\" unpacked with wrong size!
  127. fi
  128. # end of 'tcl6.1/compat/strtol.c'
  129. fi
  130. if test -f 'tcl6.1/tclTest.c' -a "${1}" != "-c" ; then 
  131.   echo shar: Will not clobber existing file \"'tcl6.1/tclTest.c'\"
  132. else
  133. echo shar: Extracting \"'tcl6.1/tclTest.c'\" \(3427 characters\)
  134. sed "s/^X//" >'tcl6.1/tclTest.c' <<'END_OF_FILE'
  135. X/* 
  136. X * tclTest.c --
  137. X *
  138. X *    Test driver for TCL.
  139. X *
  140. X * Copyright 1987-1991 Regents of the University of California
  141. X * All rights reserved.
  142. X *
  143. X * Permission to use, copy, modify, and distribute this
  144. X * software and its documentation for any purpose and without
  145. X * fee is hereby granted, provided that the above copyright
  146. X * notice appears in all copies.  The University of California
  147. X * makes no representations about the suitability of this
  148. X * software for any purpose.  It is provided "as is" without
  149. X * express or implied warranty.
  150. X */
  151. X
  152. X#ifndef lint
  153. Xstatic char rcsid[] = "$Header: /user6/ouster/tcl/tclTest/RCS/tclTest.c,v 1.18 91/10/27 16:46:07 ouster Exp $ SPRITE (Berkeley)";
  154. X#endif
  155. X
  156. X#include <stdio.h>
  157. X#include <errno.h>
  158. X#include <string.h>
  159. X#include "tcl.h"
  160. X
  161. Xextern int exit();
  162. Xextern int Tcl_DumpActiveMemory();
  163. X
  164. XTcl_Interp *interp;
  165. XTcl_CmdBuf buffer;
  166. Xchar dumpFile[100];
  167. Xint quitFlag = 0;
  168. X
  169. Xchar *initCmd =
  170. X    "if [file exists [info library]/init.tcl] {source [info library]/init.tcl}";
  171. X
  172. X    /* ARGSUSED */
  173. Xint
  174. XcmdCheckmem(clientData, interp, argc, argv)
  175. X    ClientData *clientData;
  176. X    Tcl_Interp *interp;
  177. X    int argc;
  178. X    char *argv[];
  179. X{
  180. X    if (argc != 2) {
  181. X    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
  182. X        " fileName\"", (char *) NULL);
  183. X    return TCL_ERROR;
  184. X    }
  185. X    strcpy(dumpFile, argv[1]);
  186. X    quitFlag = 1;
  187. X    return TCL_OK;
  188. X}
  189. X
  190. X    /* ARGSUSED */
  191. Xint
  192. XcmdEcho(clientData, interp, argc, argv)
  193. X    ClientData *clientData;
  194. X    Tcl_Interp *interp;
  195. X    int argc;
  196. X    char *argv[];
  197. X{
  198. X    int i;
  199. X
  200. X    for (i = 1; ; i++) {
  201. X    if (argv[i] == NULL) {
  202. X        if (i != argc) {
  203. X        echoError:
  204. X        sprintf(interp->result,
  205. X            "argument list wasn't properly NULL-terminated in \"%s\" command",
  206. X            argv[0]);
  207. X        }
  208. X        break;
  209. X    }
  210. X    if (i >= argc) {
  211. X        goto echoError;
  212. X    }
  213. X    fputs(argv[i], stdout);
  214. X    if (i < (argc-1)) {
  215. X        printf(" ");
  216. X    }
  217. X    }
  218. X    printf("\n");
  219. X    return TCL_OK;
  220. X}
  221. X
  222. Xvoid
  223. XdeleteProc(clientData)
  224. X    char *clientData;
  225. X{
  226. X    printf("Deleting command with clientData \"%s\".\n", clientData);
  227. X}
  228. X
  229. Xint
  230. Xmain()
  231. X{
  232. X    char line[1000], *cmd;
  233. X    int result, gotPartial;
  234. X
  235. X    interp = Tcl_CreateInterp();
  236. X#ifdef TCL_MEM_DEBUG
  237. X    Tcl_InitMemory(interp);
  238. X#endif
  239. X    Tcl_CreateCommand(interp, "echo", cmdEcho, (ClientData) "echo",
  240. X        (Tcl_CmdDeleteProc *) NULL);
  241. X    Tcl_CreateCommand(interp, "checkmem", cmdCheckmem, (ClientData) 0,
  242. X        (Tcl_CmdDeleteProc *) NULL);
  243. X    buffer = Tcl_CreateCmdBuf();
  244. X    result = Tcl_Eval(interp, initCmd, 0, (char **) NULL);
  245. X    if (result != TCL_OK) {
  246. X    printf("%s\n", interp->result);
  247. X    exit(1);
  248. X    }
  249. X
  250. X    gotPartial = 0;
  251. X    while (1) {
  252. X    clearerr(stdin);
  253. X    if (!gotPartial) {
  254. X        fputs("% ", stdout);
  255. X        fflush(stdout);
  256. X    }
  257. X    if (fgets(line, 1000, stdin) == NULL) {
  258. X        if (!gotPartial) {
  259. X        exit(0);
  260. X        }
  261. X        line[0] = 0;
  262. X    }
  263. X    cmd = Tcl_AssembleCmd(buffer, line);
  264. X    if (cmd == NULL) {
  265. X        gotPartial = 1;
  266. X        continue;
  267. X    }
  268. X
  269. X    gotPartial = 0;
  270. X    result = Tcl_RecordAndEval(interp, cmd, 0);
  271. X    if (result == TCL_OK) {
  272. X        if (*interp->result != 0) {
  273. X        printf("%s\n", interp->result);
  274. X        }
  275. X        if (quitFlag) {
  276. X        Tcl_DeleteInterp(interp);
  277. X        Tcl_DeleteCmdBuf(buffer);
  278. X#ifdef TCL_MEM_DEBUG
  279. X        Tcl_DumpActiveMemory(dumpFile);
  280. X#endif
  281. X        exit(0);
  282. X        }
  283. X    } else {
  284. X        if (result == TCL_ERROR) {
  285. X        printf("Error");
  286. X        } else {
  287. X        printf("Error %d", result);
  288. X        }
  289. X        if (*interp->result != 0) {
  290. X        printf(": %s\n", interp->result);
  291. X        } else {
  292. X        printf("\n");
  293. X        }
  294. X    }
  295. X    }
  296. X}
  297. END_OF_FILE
  298. if test 3427 -ne `wc -c <'tcl6.1/tclTest.c'`; then
  299.     echo shar: \"'tcl6.1/tclTest.c'\" unpacked with wrong size!
  300. fi
  301. # end of 'tcl6.1/tclTest.c'
  302. fi
  303. if test -f 'tcl6.1/tests/append.test' -a "${1}" != "-c" ; then 
  304.   echo shar: Will not clobber existing file \"'tcl6.1/tests/append.test'\"
  305. else
  306. echo shar: Extracting \"'tcl6.1/tests/append.test'\" \(3126 characters\)
  307. sed "s/^X//" >'tcl6.1/tests/append.test' <<'END_OF_FILE'
  308. X# Commands covered:  append lappend
  309. X#
  310. X# This file contains a collection of tests for one or more of the Tcl
  311. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  312. X# generates output for errors.  No output means no errors were found.
  313. X#
  314. X# Copyright 1991 Regents of the University of California
  315. X# Permission to use, copy, modify, and distribute this
  316. X# software and its documentation for any purpose and without
  317. X# fee is hereby granted, provided that this copyright notice
  318. X# appears in all copies.  The University of California makes no
  319. X# representations about the suitability of this software for any
  320. X# purpose.  It is provided "as is" without express or implied
  321. X# warranty.
  322. X#
  323. X# $Header: /sprite/src/lib/tcl/tests/RCS/append.test,v 1.3 91/09/08 13:43:32 ouster Exp $ (Berkeley)
  324. X
  325. Xif {[string compare test [info procs test]] == 1} then {source defs}
  326. X
  327. Xcatch {unset x}
  328. Xtest append-1.1 {append command} {
  329. X    catch {unset x}
  330. X    list [append x 1 2 abc "long string"] $x
  331. X} {{12abclong string} {12abclong string}}
  332. Xtest append-1.2 {append command} {
  333. X    set x ""
  334. X    list [append x first] [append x second] [append x third] $x
  335. X} {first firstsecond firstsecondthird firstsecondthird}
  336. X
  337. Xtest append-2.1 {long appends} {
  338. X    set x ""
  339. X    for {set i 0} {$i < 1000} {set i [expr $i+1]} {
  340. X    append x "foobar "
  341. X    }
  342. X    set y "foobar"
  343. X    set y "$y $y $y $y $y $y $y $y $y $y"
  344. X    set y "$y $y $y $y $y $y $y $y $y $y"
  345. X    set y "$y $y $y $y $y $y $y $y $y $y "
  346. X    expr {$x == $y}
  347. X} 1
  348. X
  349. Xtest append-3.1 {append errors} {
  350. X    list [catch {append} msg] $msg
  351. X} {1 {wrong # args: should be "append varName value ?value ...?"}}
  352. Xtest append-3.2 {append errors} {
  353. X    list [catch {append x} msg] $msg
  354. X} {1 {wrong # args: should be "append varName value ?value ...?"}}
  355. Xtest append-3.3 {append errors} {
  356. X    set x ""
  357. X    list [catch {append x(0) 44} msg] $msg
  358. X} {1 {can't set "x(0)": variable isn't array}}
  359. X
  360. Xtest append-4.1 {lappend command} {
  361. X    catch {unset x}
  362. X    list [lappend x 1 2 abc "long string"] $x
  363. X} {{1 2 abc {long string}} {1 2 abc {long string}}}
  364. Xtest append-4.2 {lappend command} {
  365. X    set x ""
  366. X    list [lappend x first] [lappend x second] [lappend x third] $x
  367. X} {first {first second} {first second third} {first second third}}
  368. X
  369. Xproc check {var size} {
  370. X    set l [llength $var]
  371. X    if {$l != $size} {
  372. X    return "length mismatch: should have been $size, was $l"
  373. X    }
  374. X    for {set i 0} {$i < $size} {set i [expr $i+1]} {
  375. X    set j [lindex $var $i]
  376. X    if {$j != "item $i"} {
  377. X        return "element $i should have been \"item $i\", was \"$j\"
  378. X    }
  379. X    }
  380. X    return ok
  381. X}
  382. Xtest append-5.1 {long lappends} {
  383. X    set x ""
  384. X    for {set i 0} {$i < 300} {set i [expr $i+1]} {
  385. X    lappend x "item $i"
  386. X    }
  387. X    check $x 300
  388. X} ok
  389. X
  390. Xtest append-6.1 {lappend errors} {
  391. X    list [catch {lappend} msg] $msg
  392. X} {1 {wrong # args: should be "lappend varName value ?value ...?"}}
  393. Xtest append-6.2 {lappend errors} {
  394. X    list [catch {lappend x} msg] $msg
  395. X} {1 {wrong # args: should be "lappend varName value ?value ...?"}}
  396. Xtest append-6.3 {lappend errors} {
  397. X    set x ""
  398. X    list [catch {lappend x(0) 44} msg] $msg
  399. X} {1 {can't set "x(0)": variable isn't array}}
  400. END_OF_FILE
  401. if test 3126 -ne `wc -c <'tcl6.1/tests/append.test'`; then
  402.     echo shar: \"'tcl6.1/tests/append.test'\" unpacked with wrong size!
  403. fi
  404. # end of 'tcl6.1/tests/append.test'
  405. fi
  406. if test -f 'tcl6.1/tests/case.test' -a "${1}" != "-c" ; then 
  407.   echo shar: Will not clobber existing file \"'tcl6.1/tests/case.test'\"
  408. else
  409. echo shar: Extracting \"'tcl6.1/tests/case.test'\" \(2756 characters\)
  410. sed "s/^X//" >'tcl6.1/tests/case.test' <<'END_OF_FILE'
  411. X# Commands covered:  case
  412. X#
  413. X# This file contains a collection of tests for one or more of the Tcl
  414. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  415. X# generates output for errors.  No output means no errors were found.
  416. X#
  417. X# Copyright 1991 Regents of the University of California
  418. X# Permission to use, copy, modify, and distribute this
  419. X# software and its documentation for any purpose and without
  420. X# fee is hereby granted, provided that this copyright notice
  421. X# appears in all copies.  The University of California makes no
  422. X# representations about the suitability of this software for any
  423. X# purpose.  It is provided "as is" without express or implied
  424. X# warranty.
  425. X#
  426. X# $Header: /user6/ouster/tcl/tests/RCS/case.test,v 1.5 91/11/07 09:01:50 ouster Exp $ (Berkeley)
  427. X
  428. Xif {[string compare test [info procs test]] == 1} then {source defs}
  429. X
  430. Xtest case-1.1 {simple pattern} {
  431. X    case a in a {format 1} b {format 2} c {format 3} default {format 4}
  432. X} 1
  433. Xtest case-1.2 {simple pattern} {
  434. X    case b a {format 1} b {format 2} c {format 3} default {format 4}
  435. X} 2
  436. Xtest case-1.3 {simple pattern} {
  437. X    case x in a {format 1} b {format 2} c {format 3} default {format 4}
  438. X} 4
  439. Xtest case-1.4 {simple pattern} {
  440. X    case x a {format 1} b {format 2} c {format 3}
  441. X} {}
  442. Xtest case-1.5 {simple pattern matches many times} {
  443. X    case b a {format 1} b {format 2} b {format 3} b {format 4}
  444. X} 2
  445. Xtest case-1.6 {fancier pattern} {
  446. X    case cx a {format 1} *c {format 2} *x {format 3} default {format 4}
  447. X} 3
  448. Xtest case-1.7 {list of patterns} {
  449. X    case abc in {a b c} {format 1} {def abc ghi} {format 2}
  450. X} 2
  451. X
  452. Xtest case-2.1 {error in executed command} {
  453. X    list [catch {case a in a {error "Just a test"} default {format 1}} msg] \
  454. X        $msg $errorInfo
  455. X} {1 {Just a test} {Just a test
  456. X    while executing
  457. X"error "Just a test""
  458. X    ("a" arm line 1)
  459. X    invoked from within
  460. X"case a in a {error "Just a test"} default {format 1}"}}
  461. Xtest case-2.2 {error: not enough args} {
  462. X    list [catch {case} msg] $msg
  463. X} {1 {wrong # args: should be "case string ?in? patList body ... ?default body?"}}
  464. Xtest case-2.3 {error: pattern with no body} {
  465. X    list [catch {case a b} msg] $msg
  466. X} {1 {extra case pattern with no body}}
  467. Xtest case-2.4 {error: pattern with no body} {
  468. X    list [catch {case a in b {format 1} c} msg] $msg
  469. X} {1 {extra case pattern with no body}}
  470. X
  471. Xtest case-3.1 {single-argument form for pattern/command pairs} {
  472. X    case b in {
  473. X    a {format 1}
  474. X    b {format 2}
  475. X    default {format 6}
  476. X    }
  477. X} {2}
  478. Xtest case-3.2 {single-argument form for pattern/command pairs} {
  479. X    case b {
  480. X    a {format 1}
  481. X    b {format 2}
  482. X    default {format 6}
  483. X    }
  484. X} {2}
  485. Xtest case-3.3 {single-argument form for pattern/command pairs} {
  486. X    list [catch {case z in {a 2 b}} msg] $msg
  487. X} {1 {extra case pattern with no body}}
  488. END_OF_FILE
  489. if test 2756 -ne `wc -c <'tcl6.1/tests/case.test'`; then
  490.     echo shar: \"'tcl6.1/tests/case.test'\" unpacked with wrong size!
  491. fi
  492. # end of 'tcl6.1/tests/case.test'
  493. fi
  494. if test -f 'tcl6.1/tests/cd.test' -a "${1}" != "-c" ; then 
  495.   echo shar: Will not clobber existing file \"'tcl6.1/tests/cd.test'\"
  496. else
  497. echo shar: Extracting \"'tcl6.1/tests/cd.test'\" \(2888 characters\)
  498. sed "s/^X//" >'tcl6.1/tests/cd.test' <<'END_OF_FILE'
  499. X# Commands covered:  cd, pwd
  500. X#
  501. X# This file contains a collection of tests for one or more of the Tcl
  502. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  503. X# generates output for errors.  No output means no errors were found.
  504. X#
  505. X# Copyright 1991 Regents of the University of California
  506. X# Permission to use, copy, modify, and distribute this
  507. X# software and its documentation for any purpose and without
  508. X# fee is hereby granted, provided that this copyright notice
  509. X# appears in all copies.  The University of California makes no
  510. X# representations about the suitability of this software for any
  511. X# purpose.  It is provided "as is" without express or implied
  512. X# warranty.
  513. X#
  514. X# $Header: /user6/ouster/tcl/tests/RCS/cd.test,v 1.15 91/10/17 16:22:35 ouster Exp $ (Berkeley)
  515. X
  516. Xif {[string compare test [info procs test]] == 1} then {source defs}
  517. X
  518. Xcatch {exec rm -rf cd.dir}
  519. Xexec mkdir cd.dir
  520. Xexec cat << "Sample text" > cd.dir/test.file
  521. Xset cwd [exec pwd]
  522. X
  523. Xtest cd-1.1 {simple pwd check} {
  524. X    pwd
  525. X} $cwd
  526. X
  527. Xcd cd.dir
  528. Xtest cd-2.1 {changing directories} {
  529. X    list [exec pwd]
  530. X} $cwd/cd.dir
  531. Xtest cd-2.2 {changing directories} {
  532. X    pwd
  533. X} $cwd/cd.dir
  534. Xtest cd-2.3 {changing directories} {
  535. X    exec cat test.file
  536. X} "Sample text"
  537. Xcd ..
  538. Xtest cd-2.4 {changing directories} {
  539. X    exec pwd 
  540. X} $cwd
  541. Xtest cd-2.5 {changing directories} {
  542. X    pwd 
  543. X} $cwd
  544. Xtest cd-2.6 {changing directories} {
  545. X    exec cat cd.dir/test.file
  546. X} "Sample text"
  547. Xset home [exec sh -c "cd; pwd"]
  548. Xtest cd-2.7 {changing directories} {
  549. X    cd ~
  550. X    set x [list [exec pwd] [pwd]]
  551. X    cd $cwd
  552. X    set x
  553. X} "$home $home"
  554. Xtest cd-2.8 {changing directories} {
  555. X    cd
  556. X    set x [list [exec pwd] [pwd]]
  557. X    cd $cwd
  558. X    set x
  559. X} "$home $home"
  560. X
  561. Xtest cd-3.1 {cd return value} {
  562. X    cd .
  563. X} {}
  564. X
  565. Xtest cd-4.1 {errors in cd command} {
  566. X    list [catch {cd 1 2} msg] $msg $errorCode
  567. X} {1 {wrong # args: should be "cd dirName"} NONE}
  568. Xtest cd-4.2 {errors in cd command} {
  569. X    string tolower [list [catch {cd _non_existent_dir} msg] $msg $errorCode]
  570. X} {1 {couldn't change working directory to "_non_existent_dir": no such file or directory} \
  571. X{unix enoent {no such file or directory}}}
  572. Xtest cd-4.3 {errors in cd command} {
  573. X    string tolower [list [catch {cd cd.dir/test.file} msg] $msg $errorCode]
  574. X} {1 {couldn't change working directory to "cd.dir/test.file": not a directory} {unix enotdir {not a directory}}}
  575. Xtest cd-4.4 {errors in cd command} {
  576. X    set home $env(HOME)
  577. X    unset env(HOME)
  578. X    set x [list [catch cd msg] $msg]
  579. X    set env(HOME) $home
  580. X    set x
  581. X} {1 {couldn't find HOME environment variable to expand "~"}}
  582. X
  583. Xtest cd-5.1 {errors in pwd command} {
  584. X    list [catch {pwd a} msg] $msg
  585. X} {1 {wrong # args: should be "pwd"}}
  586. Xexec mkdir cd.dir/child
  587. Xcd cd.dir/child
  588. Xexec chmod 111 ..
  589. Xif {$user != "root"} {
  590. X    test cd-5.2 {errors in pwd command} {
  591. X    catch pwd msg
  592. X    } 1
  593. X}
  594. Xcd $cwd
  595. Xexec chmod 775 cd.dir
  596. X
  597. Xcatch {exec rm -rf cd.dir}
  598. Xformat ""
  599. END_OF_FILE
  600. if test 2888 -ne `wc -c <'tcl6.1/tests/cd.test'`; then
  601.     echo shar: \"'tcl6.1/tests/cd.test'\" unpacked with wrong size!
  602. fi
  603. # end of 'tcl6.1/tests/cd.test'
  604. fi
  605. if test -f 'tcl6.1/tests/env.test' -a "${1}" != "-c" ; then 
  606.   echo shar: Will not clobber existing file \"'tcl6.1/tests/env.test'\"
  607. else
  608. echo shar: Extracting \"'tcl6.1/tests/env.test'\" \(2832 characters\)
  609. sed "s/^X//" >'tcl6.1/tests/env.test' <<'END_OF_FILE'
  610. X# Commands covered:  none (tests environment variable implementation)
  611. X#
  612. X# This file contains a collection of tests for one or more of the Tcl
  613. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  614. X# generates output for errors.  No output means no errors were found.
  615. X#
  616. X# Copyright 1991 Regents of the University of California
  617. X# Permission to use, copy, modify, and distribute this
  618. X# software and its documentation for any purpose and without
  619. X# fee is hereby granted, provided that this copyright notice
  620. X# appears in all copies.  The University of California makes no
  621. X# representations about the suitability of this software for any
  622. X# purpose.  It is provided "as is" without express or implied
  623. X# warranty.
  624. X#
  625. X# $Header: /sprite/src/lib/tcl/tests/RCS/env.test,v 1.4 91/09/16 14:39:47 ouster Exp $ (Berkeley)
  626. X
  627. Xif {[string compare test [info procs test]] == 1} then {source defs}
  628. X
  629. X# If there is no "printenv" program on this system, then it's just too
  630. X# much trouble to run this test (can't necessarily run csh to get the
  631. X# envionrment:  on some systems it barfs if there isn't a minimum set
  632. X# predefined environment variables.  Also, printenv returns a non-zero
  633. X# status on some systems, so read the environment using a procedure
  634. X# that catches errors.
  635. X
  636. Xset printenv {}
  637. Xif [info exists env(PATH)] {
  638. X    set dirs [split $env(PATH) :]
  639. X} else {
  640. X    set dirs {/bin /usr/bin /usr/ucb /usr/local /usr/public /usr/etc}
  641. X}
  642. Xforeach i $dirs {
  643. X    if [file executable $i/printenv] {
  644. X    set printenv $i/printenv
  645. X    break
  646. X    }
  647. X}
  648. Xif {$printenv == ""} {
  649. X    puts stdout "Skipping env tests:  need \"printenv\" to read environment."
  650. X    return ""
  651. X}
  652. Xproc getenv {} {
  653. X    global printenv
  654. X    catch {exec $printenv} out
  655. X    return $out
  656. X}
  657. X
  658. X# Save the current environment variables at the start of the test.
  659. X
  660. Xforeach name [array names env] {
  661. X    set env2($name) $env($name)
  662. X    unset env($name)
  663. X}
  664. X
  665. Xtest env-1.1 {adding environment variables} {
  666. X    getenv
  667. X} {}
  668. X
  669. Xset env(NAME1) "test string"
  670. Xtest env-1.2 {adding environment variables} {
  671. X    getenv
  672. X} {NAME1=test string}
  673. X
  674. Xset env(NAME2) "more"
  675. Xtest env-1.3 {adding environment variables} {
  676. X    getenv
  677. X} {NAME1=test string
  678. XNAME2=more}
  679. X
  680. Xset env(XYZZY) "garbage"
  681. Xtest env-1.4 {adding environment variables} {
  682. X    getenv
  683. X} {NAME1=test string
  684. XNAME2=more
  685. XXYZZY=garbage}
  686. X
  687. Xset env(NAME2) "new value"
  688. Xtest env-2.1 {changing environment variables} {
  689. X    getenv
  690. X} {NAME1=test string
  691. XNAME2=new value
  692. XXYZZY=garbage}
  693. X
  694. Xunset env(NAME2)
  695. Xtest env-3.1 {unsetting environment variables} {
  696. X    getenv
  697. X} {NAME1=test string
  698. XXYZZY=garbage}
  699. Xunset env(NAME1)
  700. Xtest env-3.2 {unsetting environment variables} {
  701. X    getenv
  702. X} {XYZZY=garbage}
  703. X
  704. X# Restore the environment variables at the end of the test.
  705. X
  706. Xforeach name [array names env] {
  707. X    unset env($name)
  708. X}
  709. Xforeach name [array names env2] {
  710. X    set env($name) $env2($name)
  711. X}
  712. END_OF_FILE
  713. if test 2832 -ne `wc -c <'tcl6.1/tests/env.test'`; then
  714.     echo shar: \"'tcl6.1/tests/env.test'\" unpacked with wrong size!
  715. fi
  716. # end of 'tcl6.1/tests/env.test'
  717. fi
  718. if test -f 'tcl6.1/tests/incr.test' -a "${1}" != "-c" ; then 
  719.   echo shar: Will not clobber existing file \"'tcl6.1/tests/incr.test'\"
  720. else
  721. echo shar: Extracting \"'tcl6.1/tests/incr.test'\" \(2296 characters\)
  722. sed "s/^X//" >'tcl6.1/tests/incr.test' <<'END_OF_FILE'
  723. X# Commands covered:  lreplace
  724. X#
  725. X# This file contains a collection of tests for one or more of the Tcl
  726. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  727. X# generates output for errors.  No output means no errors were found.
  728. X#
  729. X# Copyright 1991 Regents of the University of California
  730. X# Permission to use, copy, modify, and distribute this
  731. X# software and its documentation for any purpose and without
  732. X# fee is hereby granted, provided that this copyright notice
  733. X# appears in all copies.  The University of California makes no
  734. X# representations about the suitability of this software for any
  735. X# purpose.  It is provided "as is" without express or implied
  736. X# warranty.
  737. X#
  738. X# $Header: /sprite/src/lib/tcl/tests/RCS/incr.test,v 1.2 91/08/28 16:27:35 ouster Exp $ (Berkeley)
  739. X
  740. Xif {[string compare test [info procs test]] == 1} then {source defs}
  741. X
  742. Xcatch {unset x}
  743. X
  744. Xtest incr-1.1 {basic incr operation} {
  745. X    set x 23
  746. X    list [incr x] $x
  747. X} {24 24}
  748. Xtest incr-1.2 {basic incr operation} {
  749. X    set x 106
  750. X    list [incr x -5] $x
  751. X} {101 101}
  752. X
  753. Xtest incr-2.1 {incr errors} {
  754. X    list [catch incr msg] $msg
  755. X} {1 {wrong # args: should be "incr varName ?increment?"}}
  756. Xtest incr-2.2 {incr errors} {
  757. X    list [catch {incr a b c} msg] $msg
  758. X} {1 {wrong # args: should be "incr varName ?increment?"}}
  759. Xtest incr-2.3 {incr errors} {
  760. X    catch {unset x}
  761. X    list [catch {incr x} msg] $msg $errorInfo
  762. X} {1 {can't read "x": no such variable} {can't read "x": no such variable
  763. X    while executing
  764. X"incr x"}}
  765. Xtest incr-2.4 {incr errors} {
  766. X    set x abc
  767. X    list [catch {incr x} msg] $msg $errorInfo
  768. X} {1 {expected integer but got "abc"} {expected integer but got "abc"
  769. X    (reading value of variable to increment)
  770. X    invoked from within
  771. X"incr x"}}
  772. Xtest incr-2.5 {incr errors} {
  773. X    set x 123
  774. X    list [catch {incr x 1a} msg] $msg $errorInfo
  775. X} {1 {expected integer but got "1a"} {expected integer but got "1a"
  776. X    (reading increment)
  777. X    invoked from within
  778. X"incr x 1a"}}
  779. Xtest incr-2.6 {incr errors} {
  780. X    proc readonly args {error "variable is read-only"}
  781. X    set x 123
  782. X    trace var x w readonly
  783. X    list [catch {incr x 1} msg] $msg $errorInfo
  784. X} {1 {can't set "x": access disallowed by trace command} {can't set "x": access disallowed by trace command
  785. X    while executing
  786. X"incr x 1"}}
  787. X
  788. Xcatch {unset x}
  789. Xconcat {}
  790. END_OF_FILE
  791. if test 2296 -ne `wc -c <'tcl6.1/tests/incr.test'`; then
  792.     echo shar: \"'tcl6.1/tests/incr.test'\" unpacked with wrong size!
  793. fi
  794. # end of 'tcl6.1/tests/incr.test'
  795. fi
  796. if test -f 'tcl6.1/tests/lindex.test' -a "${1}" != "-c" ; then 
  797.   echo shar: Will not clobber existing file \"'tcl6.1/tests/lindex.test'\"
  798. else
  799. echo shar: Extracting \"'tcl6.1/tests/lindex.test'\" \(2290 characters\)
  800. sed "s/^X//" >'tcl6.1/tests/lindex.test' <<'END_OF_FILE'
  801. X# Commands covered:  lindex
  802. X#
  803. X# This file contains a collection of tests for one or more of the Tcl
  804. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  805. X# generates output for errors.  No output means no errors were found.
  806. X#
  807. X# Copyright 1991 Regents of the University of California
  808. X# Permission to use, copy, modify, and distribute this
  809. X# software and its documentation for any purpose and without
  810. X# fee is hereby granted, provided that this copyright notice
  811. X# appears in all copies.  The University of California makes no
  812. X# representations about the suitability of this software for any
  813. X# purpose.  It is provided "as is" without express or implied
  814. X# warranty.
  815. X#
  816. X# $Header: /sprite/src/lib/tcl/tests/RCS/lindex.test,v 1.1 91/09/06 14:48:02 ouster Exp $ (Berkeley)
  817. X
  818. Xif {[string compare test [info procs test]] == 1} then {source defs}
  819. X
  820. Xtest lindex-1.1 {basic tests} {
  821. X    lindex {a b c} 0} a
  822. Xtest lindex-1.2 {basic tests} {
  823. X    lindex {a {b c d} x} 1} {b c d}
  824. Xtest lindex-1.3 {basic tests} {
  825. X    lindex {a b\ c\ d x} 1} {b c d}
  826. Xtest lindex-1.4 {basic tests} {
  827. X    lindex {a b c} 3} {}
  828. Xtest lindex-1.5 {basic tests} {
  829. X    list [catch {lindex {a b c} -1} msg] $msg
  830. X} {0 {}}
  831. X
  832. Xtest lindex-2.1 {error conditions} {
  833. X    list [catch {lindex msg} msg] $msg
  834. X} {1 {wrong # args: should be "lindex list index"}}
  835. Xtest lindex-2.2 {error conditions} {
  836. X    list [catch {lindex 1 2 3 4} msg] $msg
  837. X} {1 {wrong # args: should be "lindex list index"}}
  838. Xtest lindex-2.3 {error conditions} {
  839. X    list [catch {lindex 1 2a2} msg] $msg
  840. X} {1 {expected integer but got "2a2"}}
  841. Xtest lindex-2.4 {error conditions} {
  842. X    list [catch {lindex "a \{" 2} msg] $msg
  843. X} {1 {unmatched open brace in list}}
  844. Xtest lindex-2.5 {error conditions} {
  845. X    list [catch {lindex {a {b c}d e} 2} msg] $msg
  846. X} {1 {list element in braces followed by "d" instead of space}}
  847. Xtest lindex-2.6 {error conditions} {
  848. X    list [catch {lindex {a "b c"def ghi} 2} msg] $msg
  849. X} {1 {list element in quotes followed by "def" instead of space}}
  850. X
  851. Xtest lindex-3.1 {quoted elements} {
  852. X    lindex {a "b c" d} 1
  853. X} {b c}
  854. Xtest lindex-3.2 {quoted elements} {
  855. X    lindex {"{}" b c} 0
  856. X} {{}}
  857. Xtest lindex-3.3 {quoted elements} {
  858. X    lindex {ab "c d \" x" y} 1
  859. X} {c d " x}
  860. Xtest lindex-3.4 {quoted elements} {
  861. X    lindex {a b {c d "e} {f g"}} 2
  862. X} {c d "e}
  863. END_OF_FILE
  864. if test 2290 -ne `wc -c <'tcl6.1/tests/lindex.test'`; then
  865.     echo shar: \"'tcl6.1/tests/lindex.test'\" unpacked with wrong size!
  866. fi
  867. # end of 'tcl6.1/tests/lindex.test'
  868. fi
  869. if test -f 'tcl6.1/tests/linsert.test' -a "${1}" != "-c" ; then 
  870.   echo shar: Will not clobber existing file \"'tcl6.1/tests/linsert.test'\"
  871. else
  872. echo shar: Extracting \"'tcl6.1/tests/linsert.test'\" \(2399 characters\)
  873. sed "s/^X//" >'tcl6.1/tests/linsert.test' <<'END_OF_FILE'
  874. X# Commands covered:  linsert
  875. X#
  876. X# This file contains a collection of tests for one or more of the Tcl
  877. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  878. X# generates output for errors.  No output means no errors were found.
  879. X#
  880. X# Copyright 1991 Regents of the University of California
  881. X# Permission to use, copy, modify, and distribute this
  882. X# software and its documentation for any purpose and without
  883. X# fee is hereby granted, provided that this copyright notice
  884. X# appears in all copies.  The University of California makes no
  885. X# representations about the suitability of this software for any
  886. X# purpose.  It is provided "as is" without express or implied
  887. X# warranty.
  888. X#
  889. X# $Header: /sprite/src/lib/tcl/tests/RCS/linsert.test,v 1.1 91/08/21 13:37:24 ouster Exp $ (Berkeley)
  890. X
  891. Xif {[string compare test [info procs test]] == 1} then {source defs}
  892. X
  893. Xtest linsert-1.1 {linsert command} {
  894. X    linsert {1 2 3 4 5} 0 a
  895. X} {a 1 2 3 4 5}
  896. Xtest linsert-1.2 {linsert command} {
  897. X    linsert {1 2 3 4 5} 1 a
  898. X} {1 a 2 3 4 5}
  899. Xtest linsert-1.3 {linsert command} {
  900. X    linsert {1 2 3 4 5} 2 a
  901. X} {1 2 a 3 4 5}
  902. Xtest linsert-1.4 {linsert command} {
  903. X    linsert {1 2 3 4 5} 3 a
  904. X} {1 2 3 a 4 5}
  905. Xtest linsert-1.5 {linsert command} {
  906. X    linsert {1 2 3 4 5} 4 a
  907. X} {1 2 3 4 a 5}
  908. Xtest linsert-1.6 {linsert command} {
  909. X    linsert {1 2 3 4 5} 5 a
  910. X} {1 2 3 4 5 a}
  911. Xtest linsert-1.7 {linsert command} {
  912. X    linsert {1 2 3 4 5} 2 one two \{three \$four
  913. X} {1 2 one two \{three {$four} 3 4 5}
  914. Xtest linsert-1.8 {linsert command} {
  915. X    linsert {\{one \$two \{three \ four \ five} 2 a b c
  916. X} {\{one \$two a b c \{three \ four \ five}
  917. Xtest linsert-1.9 {linsert command} {
  918. X    linsert {{1 2} {3 4} {5 6} {7 8}} 2 {x y} {a b}
  919. X} {{1 2} {3 4} {x y} {a b} {5 6} {7 8}}
  920. Xtest linsert-1.10 {linsert command} {
  921. X    linsert {} 2 a b c
  922. X} {a b c}
  923. Xtest linsert-1.11 {linsert command} {
  924. X    linsert {} 2 {}
  925. X} {{}}
  926. X
  927. Xtest linsert-2.1 {linsert errors} {
  928. X    list [catch linsert msg] $msg
  929. X} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  930. Xtest linsert-2.2 {linsert errors} {
  931. X    list [catch {linsert a b} msg] $msg
  932. X} {1 {wrong # args: should be "linsert list index element ?element ...?"}}
  933. Xtest linsert-2.3 {linsert errors} {
  934. X    list [catch {linsert a 12x 2} msg] $msg
  935. X} {1 {expected integer but got "12x"}}
  936. Xtest linsert-2.4 {linsert errors} {
  937. X    list [catch {linsert \{ 12 2} msg] $msg
  938. X} {1 {unmatched open brace in list}}
  939. END_OF_FILE
  940. if test 2399 -ne `wc -c <'tcl6.1/tests/linsert.test'`; then
  941.     echo shar: \"'tcl6.1/tests/linsert.test'\" unpacked with wrong size!
  942. fi
  943. # end of 'tcl6.1/tests/linsert.test'
  944. fi
  945. if test -f 'tcl6.1/tests/list.test' -a "${1}" != "-c" ; then 
  946.   echo shar: Will not clobber existing file \"'tcl6.1/tests/list.test'\"
  947. else
  948. echo shar: Extracting \"'tcl6.1/tests/list.test'\" \(2924 characters\)
  949. sed "s/^X//" >'tcl6.1/tests/list.test' <<'END_OF_FILE'
  950. X# Commands covered:  list
  951. X#
  952. X# This file contains a collection of tests for one or more of the Tcl
  953. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  954. X# generates output for errors.  No output means no errors were found.
  955. X#
  956. X# Copyright 1991 Regents of the University of California
  957. X# Permission to use, copy, modify, and distribute this
  958. X# software and its documentation for any purpose and without
  959. X# fee is hereby granted, provided that this copyright notice
  960. X# appears in all copies.  The University of California makes no
  961. X# representations about the suitability of this software for any
  962. X# purpose.  It is provided "as is" without express or implied
  963. X# warranty.
  964. X#
  965. X# $Header: /user6/ouster/tcl/tests/RCS/list.test,v 1.9 91/10/17 15:49:39 ouster Exp $ (Berkeley)
  966. X
  967. Xif {[string compare test [info procs test]] == 1} then {source defs}
  968. X
  969. X# First, a bunch of individual tests
  970. X
  971. Xtest list-1.1 {basic tests} {list a b c} {a b c}
  972. Xtest list-1.2 {basic tests} {list {a b} c} {{a b} c}
  973. Xtest list-1.3 {basic tests} {list \{a b c} {\{a b c}
  974. Xtest list-1.4 {basic tests} "list a{}} b{} c}" "a{}} b{} c}"
  975. Xtest list-1.5 {basic tests} {list a\[ b\] } "{a\[} b\\]"
  976. Xtest list-1.6 {basic tests} {list c\  d\t } "{c } {d\t}"
  977. Xtest list-1.7 {basic tests} {list e\n f\$ } "{e\n} {f\$}"
  978. Xtest list-1.8 {basic tests} {list g\; h\\} {{g;} h\\}
  979. Xtest list-1.9 {basic tests} "list a\\\[} b\\\]} " "a\\\[} b\\\]}"
  980. Xtest list-1.10 {basic tests} "list c\\\} d\\t} " "c} d\\t}"
  981. Xtest list-1.11 {basic tests} "list e\\n} f\\$} " "e\\n} f\\$}"
  982. Xtest list-1.12 {basic tests} "list g\\;} h\\\\} " "g\\;} {h\\}}"
  983. Xtest list-1.13 {basic tests} {list a {{}} b} {a {{}} b}
  984. Xtest list-1.14 {basic tests} {list a b xy\\} "a b xy\\\\"
  985. Xtest list-1.15 {basic tests} "list a b\} e\\" "a b} e\\\\"
  986. Xtest list-1.16 {basic tests} "list a b\}\\\$ e\\\$\\" "a b\}\\\$ e\\\$\\\\"
  987. Xtest list-1.17 {basic tests} {list a\f \{\f} "{a\f} \\\{\\f"
  988. Xtest list-1.18 {basic tests} {list a\r \{\r} "{a\r} \\\{\\r"
  989. Xtest list-1.19 {basic tests} {list a\v \{\v} "{a\v} \\\{\\v"
  990. X
  991. X# For the next round of tests create a list and then pick it apart
  992. X# with "index" to make sure that we get back exactly what went in.
  993. X
  994. Xset num 1
  995. Xproc lcheck {a b c} {
  996. X    global num d
  997. X    set d [list $a $b $c]
  998. X    test list-2.$num {what goes in must come out} {lindex $d 0} $a
  999. X    set num [expr $num+1]
  1000. X    test list-2.$num {what goes in must come out} {lindex $d 1} $b
  1001. X    set num [expr $num+1]
  1002. X    test list-2.$num {what goes in must come out} {lindex $d 2} $c
  1003. X    set num [expr $num+1]
  1004. X}
  1005. Xlcheck a b c
  1006. Xlcheck "a b" c\td e\nf
  1007. Xlcheck {{a b}} {} {  }
  1008. Xlcheck \$ \$ab ab\$
  1009. Xlcheck \; \;ab ab\;
  1010. Xlcheck \[ \[ab ab\[
  1011. Xlcheck \\ \\ab ab\\
  1012. Xlcheck {"} {"ab} {ab"}
  1013. Xlcheck {a b} { ab} {ab }
  1014. Xlcheck a{ a{b \{ab
  1015. Xlcheck a} a}b }ab
  1016. Xlcheck a\\} {a \}b} {a \{c}
  1017. X
  1018. Xtest list-3.1 {error conditions} {catch list msg} 1
  1019. Xtest list-3.2 {error conditions} {
  1020. X    catch list msg
  1021. X    set msg
  1022. X} {wrong # args: should be "list arg ?arg ...?"}
  1023. END_OF_FILE
  1024. if test 2924 -ne `wc -c <'tcl6.1/tests/list.test'`; then
  1025.     echo shar: \"'tcl6.1/tests/list.test'\" unpacked with wrong size!
  1026. fi
  1027. # end of 'tcl6.1/tests/list.test'
  1028. fi
  1029. if test -f 'tcl6.1/tests/lrange.test' -a "${1}" != "-c" ; then 
  1030.   echo shar: Will not clobber existing file \"'tcl6.1/tests/lrange.test'\"
  1031. else
  1032. echo shar: Extracting \"'tcl6.1/tests/lrange.test'\" \(2523 characters\)
  1033. sed "s/^X//" >'tcl6.1/tests/lrange.test' <<'END_OF_FILE'
  1034. X# Commands covered:  lrange
  1035. X#
  1036. X# This file contains a collection of tests for one or more of the Tcl
  1037. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1038. X# generates output for errors.  No output means no errors were found.
  1039. X#
  1040. X# Copyright 1991 Regents of the University of California
  1041. X# Permission to use, copy, modify, and distribute this
  1042. X# software and its documentation for any purpose and without
  1043. X# fee is hereby granted, provided that this copyright notice
  1044. X# appears in all copies.  The University of California makes no
  1045. X# representations about the suitability of this software for any
  1046. X# purpose.  It is provided "as is" without express or implied
  1047. X# warranty.
  1048. X#
  1049. X# $Header: /sprite/src/lib/tcl/tests/RCS/lrange.test,v 1.1 91/09/06 14:47:58 ouster Exp $ (Berkeley)
  1050. X
  1051. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1052. X
  1053. Xtest lrange-1.1 {range of list elements} {
  1054. X    lrange {a b c d} 1 2
  1055. X} {b c}
  1056. Xtest lrange-1.2 {range of list elements} {
  1057. X    lrange {a {bcd e {f g {}}} l14 l15 d} 1 1
  1058. X} {{bcd e {f g {}}}}
  1059. Xtest lrange-1.3 {range of list elements} {
  1060. X    lrange {a {bcd e {f g {}}} l14 l15 d} 3 end
  1061. X} {l15 d}
  1062. Xtest lrange-1.4 {range of list elements} {
  1063. X    lrange {a {bcd e {f g {}}} l14 l15 d} 4 10000
  1064. X} {d}
  1065. Xtest lrange-1.5 {range of list elements} {
  1066. X    lrange {a {bcd e {f g {}}} l14 l15 d} 4 3
  1067. X} {}
  1068. Xtest lrange-1.6 {range of list elements} {
  1069. X    lrange {a {bcd e {f g {}}} l14 l15 d} 10 11
  1070. X} {}
  1071. Xtest lrange-1.7 {range of list elements} {
  1072. X    lrange {a b c d e} -1 2
  1073. X} {a b c}
  1074. Xtest lrange-1.8 {range of list elements} {
  1075. X    lrange {a b c d e} -2 -1
  1076. X} {}
  1077. Xtest lrange-1.9 {range of list elements} {
  1078. X    lrange {a b c d e} -2 e
  1079. X} {a b c d e}
  1080. Xtest lrange-1.10 {range of list elements} {
  1081. X    lrange "a b\{c d" 1 2
  1082. X} "b\{c d"
  1083. X
  1084. Xtest lrange-2.1 {error conditions} {
  1085. X    list [catch {lrange a b} msg] $msg
  1086. X} {1 {wrong # args: should be "lrange list first last"}}
  1087. Xtest lrange-2.2 {error conditions} {
  1088. X    list [catch {lrange a b 6 7} msg] $msg
  1089. X} {1 {wrong # args: should be "lrange list first last"}}
  1090. Xtest lrange-2.3 {error conditions} {
  1091. X    list [catch {lrange a b 6} msg] $msg
  1092. X} {1 {expected integer but got "b"}}
  1093. Xtest lrange-2.4 {error conditions} {
  1094. X    list [catch {lrange a 0 enigma} msg] $msg
  1095. X} {1 {expected integer or "end" but got "enigma"}}
  1096. Xtest lrange-2.5 {error conditions} {
  1097. X    list [catch {lrange "a \{b c" 3 4} msg] $msg
  1098. X} {1 {unmatched open brace in list}}
  1099. Xtest lrange-2.6 {error conditions} {
  1100. X    list [catch {lrange "a b c \{ d e" 1 4} msg] $msg
  1101. X} {1 {unmatched open brace in list}}
  1102. END_OF_FILE
  1103. if test 2523 -ne `wc -c <'tcl6.1/tests/lrange.test'`; then
  1104.     echo shar: \"'tcl6.1/tests/lrange.test'\" unpacked with wrong size!
  1105. fi
  1106. # end of 'tcl6.1/tests/lrange.test'
  1107. fi
  1108. if test -f 'tcl6.1/tests/lreplace.test' -a "${1}" != "-c" ; then 
  1109.   echo shar: Will not clobber existing file \"'tcl6.1/tests/lreplace.test'\"
  1110. else
  1111. echo shar: Extracting \"'tcl6.1/tests/lreplace.test'\" \(2951 characters\)
  1112. sed "s/^X//" >'tcl6.1/tests/lreplace.test' <<'END_OF_FILE'
  1113. X# Commands covered:  lreplace
  1114. X#
  1115. X# This file contains a collection of tests for one or more of the Tcl
  1116. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1117. X# generates output for errors.  No output means no errors were found.
  1118. X#
  1119. X# Copyright 1991 Regents of the University of California
  1120. X# Permission to use, copy, modify, and distribute this
  1121. X# software and its documentation for any purpose and without
  1122. X# fee is hereby granted, provided that this copyright notice
  1123. X# appears in all copies.  The University of California makes no
  1124. X# representations about the suitability of this software for any
  1125. X# purpose.  It is provided "as is" without express or implied
  1126. X# warranty.
  1127. X#
  1128. X# $Header: /sprite/src/lib/tcl/tests/RCS/lreplace.test,v 1.2 91/08/21 13:59:19 ouster Exp $ (Berkeley)
  1129. X
  1130. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1131. X
  1132. Xtest lreplace-1.1 {lreplace command} {
  1133. X    lreplace {1 2 3 4 5} 0 0 a
  1134. X} {a 2 3 4 5}
  1135. Xtest lreplace-1.2 {lreplace command} {
  1136. X    lreplace {1 2 3 4 5} 1 1 a
  1137. X} {1 a 3 4 5}
  1138. Xtest lreplace-1.3 {lreplace command} {
  1139. X    lreplace {1 2 3 4 5} 2 2 a
  1140. X} {1 2 a 4 5}
  1141. Xtest lreplace-1.4 {lreplace command} {
  1142. X    lreplace {1 2 3 4 5} 3 3 a
  1143. X} {1 2 3 a 5}
  1144. Xtest lreplace-1.5 {lreplace command} {
  1145. X    lreplace {1 2 3 4 5} 4 4 a
  1146. X} {1 2 3 4 a}
  1147. Xtest lreplace-1.6 {lreplace command} {
  1148. X    lreplace {1 2 3 4 5} 4 5 a
  1149. X} {1 2 3 4 a}
  1150. Xtest lreplace-1.7 {lreplace command} {
  1151. X    lreplace {1 2 3 4 5} -1 -1 a
  1152. X} {a 2 3 4 5}
  1153. Xtest lreplace-1.8 {lreplace command} {
  1154. X    lreplace {1 2 3 4 5} 2 end a b c d
  1155. X} {1 2 a b c d}
  1156. Xtest lreplace-1.9 {lreplace command} {
  1157. X    lreplace {1 2 3 4 5} 0 3
  1158. X} {5}
  1159. Xtest lreplace-1.10 {lreplace command} {
  1160. X    lreplace {1 2 3 4 5} 0 4
  1161. X} {}
  1162. Xtest lreplace-1.11 {lreplace command} {
  1163. X    lreplace {1 2 3 4 5} 0 1
  1164. X} {3 4 5}
  1165. Xtest lreplace-1.12 {lreplace command} {
  1166. X    lreplace {1 2 3 4 5} 2 3
  1167. X} {1 2 5}
  1168. Xtest lreplace-1.13 {lreplace command} {
  1169. X    lreplace {1 2 3 4 5} 3 end
  1170. X} {1 2 3}
  1171. Xtest lreplace-1.14 {lreplace command} {
  1172. X    lreplace {1 2 3 4 5} -1 4 a b c
  1173. X} {a b c}
  1174. X
  1175. Xtest lreplace-2.1 {lreplace errors} {
  1176. X    list [catch lreplace msg] $msg
  1177. X} {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  1178. Xtest lreplace-2.2 {lreplace errors} {
  1179. X    list [catch {lreplace a b} msg] $msg
  1180. X} {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  1181. Xtest lreplace-2.3 {lreplace errors} {
  1182. X    list [catch {lreplace x a 10} msg] $msg
  1183. X} {1 {expected integer but got "a"}}
  1184. Xtest lreplace-2.4 {lreplace errors} {
  1185. X    list [catch {lreplace x 10 x} msg] $msg
  1186. X} {1 {bad index "x": must be integer or "end"}}
  1187. Xtest lreplace-2.5 {lreplace errors} {
  1188. X    list [catch {lreplace x 10 1x} msg] $msg
  1189. X} {1 {expected integer but got "1x"}}
  1190. Xtest lreplace-2.6 {lreplace errors} {
  1191. X    list [catch {lreplace x 3 2} msg] $msg
  1192. X} {1 {first index must not be greater than second}}
  1193. Xtest lreplace-2.7 {lreplace errors} {
  1194. X    list [catch {lreplace x 1 1} msg] $msg
  1195. X} {1 {list doesn't contain element 1}}
  1196. END_OF_FILE
  1197. if test 2951 -ne `wc -c <'tcl6.1/tests/lreplace.test'`; then
  1198.     echo shar: \"'tcl6.1/tests/lreplace.test'\" unpacked with wrong size!
  1199. fi
  1200. # end of 'tcl6.1/tests/lreplace.test'
  1201. fi
  1202. if test -f 'tcl6.1/tests/rename.test' -a "${1}" != "-c" ; then 
  1203.   echo shar: Will not clobber existing file \"'tcl6.1/tests/rename.test'\"
  1204. else
  1205. echo shar: Extracting \"'tcl6.1/tests/rename.test'\" \(2522 characters\)
  1206. sed "s/^X//" >'tcl6.1/tests/rename.test' <<'END_OF_FILE'
  1207. X# Commands covered:  rename
  1208. X#
  1209. X# This file contains a collection of tests for one or more of the Tcl
  1210. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1211. X# generates output for errors.  No output means no errors were found.
  1212. X#
  1213. X# Copyright 1991 Regents of the University of California
  1214. X# Permission to use, copy, modify, and distribute this
  1215. X# software and its documentation for any purpose and without
  1216. X# fee is hereby granted, provided that this copyright notice
  1217. X# appears in all copies.  The University of California makes no
  1218. X# representations about the suitability of this software for any
  1219. X# purpose.  It is provided "as is" without express or implied
  1220. X# warranty.
  1221. X#
  1222. X# $Header: /sprite/src/lib/tcl/tests/RCS/rename.test,v 1.4 91/08/14 11:45:18 ouster Exp $ (Berkeley)
  1223. X
  1224. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1225. X
  1226. Xcatch {rename r2 {}}
  1227. Xproc r1 {} {return "procedure r1"}
  1228. Xrename r1 r2
  1229. Xtest rename-1.1 {simple renaming} {
  1230. X    r2
  1231. X} {procedure r1}
  1232. Xtest rename-1.2 {simple renaming} {
  1233. X    list [catch r1 msg] $msg
  1234. X} {1 {invalid command name: "r1"}}
  1235. Xrename r2 {}
  1236. Xtest rename-1.3 {simple renaming} {
  1237. X    list [catch r2 msg] $msg
  1238. X} {1 {invalid command name: "r2"}}
  1239. X
  1240. X# The test below is tricky because it renames a built-in command.
  1241. X# It's possible that the test procedure uses this command, so must
  1242. X# restore the command before calling test again.
  1243. X
  1244. Xrename list l.new
  1245. Xset a [catch list msg1]
  1246. Xset b [l.new a b c]
  1247. Xrename l.new list
  1248. Xset c [catch l.new msg2]
  1249. Xset d [list 111 222]
  1250. Xtest 2.1 {renaming built-in command} {
  1251. X    list $a $msg1 $b $c $msg2 $d
  1252. X} {1 {invalid command name: "list"} {a b c} 1 {invalid command name: "l.new"} {111 222}}
  1253. X
  1254. Xtest rename-3.1 {error conditions} {
  1255. X    list [catch {rename r1} msg] $msg $errorCode
  1256. X} {1 {wrong # args: should be "rename oldName newName"} NONE}
  1257. Xtest rename-3.2 {error conditions} {
  1258. X    list [catch {rename r1 r2 r3} msg] $msg $errorCode
  1259. X} {1 {wrong # args: should be "rename oldName newName"} NONE}
  1260. Xtest rename-3.3 {error conditions} {
  1261. X    proc r1 {} {}
  1262. X    proc r2 {} {}
  1263. X    list [catch {rename r1 r2} msg] $msg
  1264. X} {1 {can't rename to "r2": command already exists}}
  1265. Xtest rename-3.4 {error conditions} {
  1266. X    catch {rename r1 {}}
  1267. X    catch {rename r2 {}}
  1268. X    list [catch {rename r1 r2} msg] $msg
  1269. X} {1 {can't rename "r1":  command doesn't exist}}
  1270. Xtest rename-3.5 {error conditions} {
  1271. X    catch {rename _non_existent_command {}}
  1272. X    list [catch {rename _non_existent_command {}} msg] $msg
  1273. X} {1 {can't delete "_non_existent_command": command doesn't exist}}
  1274. END_OF_FILE
  1275. if test 2522 -ne `wc -c <'tcl6.1/tests/rename.test'`; then
  1276.     echo shar: \"'tcl6.1/tests/rename.test'\" unpacked with wrong size!
  1277. fi
  1278. # end of 'tcl6.1/tests/rename.test'
  1279. fi
  1280. if test -f 'tcl6.1/tests/source.test' -a "${1}" != "-c" ; then 
  1281.   echo shar: Will not clobber existing file \"'tcl6.1/tests/source.test'\"
  1282. else
  1283. echo shar: Extracting \"'tcl6.1/tests/source.test'\" \(2609 characters\)
  1284. sed "s/^X//" >'tcl6.1/tests/source.test' <<'END_OF_FILE'
  1285. X# Commands covered:  source
  1286. X#
  1287. X# This file contains a collection of tests for one or more of the Tcl
  1288. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1289. X# generates output for errors.  No output means no errors were found.
  1290. X#
  1291. X# Copyright 1991 Regents of the University of California
  1292. X# Permission to use, copy, modify, and distribute this
  1293. X# software and its documentation for any purpose and without
  1294. X# fee is hereby granted, provided that this copyright notice
  1295. X# appears in all copies.  The University of California makes no
  1296. X# representations about the suitability of this software for any
  1297. X# purpose.  It is provided "as is" without express or implied
  1298. X# warranty.
  1299. X#
  1300. X# $Header: /sprite/src/lib/tcl/tests/RCS/source.test,v 1.6 91/09/11 17:30:17 ouster Exp $ (Berkeley)
  1301. X
  1302. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1303. X
  1304. Xtest source-1.1 {source command} {
  1305. X    set x "old x value"
  1306. X    set y "old y value"
  1307. X    set z "old z value"
  1308. X    exec cat << {
  1309. X    set x 22
  1310. X    set y 33
  1311. X    set z 44
  1312. X    } > source.file
  1313. X    source source.file
  1314. X    list $x $y $z
  1315. X} {22 33 44}
  1316. Xtest source-1.2 {source command} {
  1317. X    exec cat << {list result} > source.file
  1318. X    source source.file
  1319. X} result
  1320. X
  1321. Xtest source-2.1 {source error conditions} {
  1322. X    list [catch {source} msg] $msg
  1323. X} {1 {wrong # args: should be "source fileName"}}
  1324. Xtest source-2.2 {source error conditions} {
  1325. X    list [catch {source a b} msg] $msg
  1326. X} {1 {wrong # args: should be "source fileName"}}
  1327. Xtest source-2.3 {source error conditions} {
  1328. X    exec cat << {
  1329. X    set x 146
  1330. X    error "error in sourced file"
  1331. X    set y $x
  1332. X    } > source.file
  1333. X    list [catch {source source.file} msg] $msg $errorInfo
  1334. X} {1 {error in sourced file} {error in sourced file
  1335. X    while executing
  1336. X"error "error in sourced file""
  1337. X    (file "source.file" line 3)
  1338. X    invoked from within
  1339. X"source source.file"}}
  1340. Xtest source-2.4 {source error conditions} {
  1341. X    exec cat << {break} > source.file
  1342. X    catch {source source.file}
  1343. X} 3
  1344. Xtest source-2.5 {source error conditions} {
  1345. X    exec cat << {continue} > source.file
  1346. X    catch {source source.file}
  1347. X} 4
  1348. Xtest source-2.6 {source error conditions} {
  1349. X    string tolower [list [catch {source _non_existent_} msg] $msg $errorCode]
  1350. X} {1 {couldn't read file "_non_existent_": no such file or directory} {unix enoent {no such file or directory}}}
  1351. X
  1352. Xtest source-3.1 {return in middle of source file} {
  1353. X    exec cat << {
  1354. X    set x new-x
  1355. X    return allDone
  1356. X    set y new-y
  1357. X    } > source.file
  1358. X    set x old-x
  1359. X    set y old-y
  1360. X    set z [source source.file]
  1361. X    list $x $y $z
  1362. X} {new-x old-y allDone}
  1363. X
  1364. Xcatch {exec rm source.file}
  1365. X
  1366. X# Generate null final value
  1367. X
  1368. Xconcat {}
  1369. END_OF_FILE
  1370. if test 2609 -ne `wc -c <'tcl6.1/tests/source.test'`; then
  1371.     echo shar: \"'tcl6.1/tests/source.test'\" unpacked with wrong size!
  1372. fi
  1373. # end of 'tcl6.1/tests/source.test'
  1374. fi
  1375. if test -f 'tcl6.1/tests/uplevel.test' -a "${1}" != "-c" ; then 
  1376.   echo shar: Will not clobber existing file \"'tcl6.1/tests/uplevel.test'\"
  1377. else
  1378. echo shar: Extracting \"'tcl6.1/tests/uplevel.test'\" \(2665 characters\)
  1379. sed "s/^X//" >'tcl6.1/tests/uplevel.test' <<'END_OF_FILE'
  1380. X# Commands covered:  uplevel
  1381. X#
  1382. X# This file contains a collection of tests for one or more of the Tcl
  1383. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1384. X# generates output for errors.  No output means no errors were found.
  1385. X#
  1386. X# Copyright 1991 Regents of the University of California
  1387. X# Permission to use, copy, modify, and distribute this
  1388. X# software and its documentation for any purpose and without
  1389. X# fee is hereby granted, provided that this copyright notice
  1390. X# appears in all copies.  The University of California makes no
  1391. X# representations about the suitability of this software for any
  1392. X# purpose.  It is provided "as is" without express or implied
  1393. X# warranty.
  1394. X#
  1395. X# $Header: /sprite/src/lib/tcl/tests/RCS/uplevel.test,v 1.8 91/09/30 16:59:26 ouster Exp $ (Berkeley)
  1396. X
  1397. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1398. X
  1399. Xproc a {x y} {
  1400. X    newset z [expr $x+$y]
  1401. X    return $z
  1402. X}
  1403. Xproc newset {name value} {
  1404. X    uplevel set $name $value
  1405. X    uplevel 1 {uplevel 1 {set xyz 22}}
  1406. X}
  1407. X
  1408. Xtest uplevel-1.1 {simple operation} {
  1409. X    set xyz 0
  1410. X    a 22 33
  1411. X} 55
  1412. Xtest uplevel-1.2 {command is another uplevel command} {
  1413. X    set xyz 0
  1414. X    a 22 33
  1415. X    set xyz
  1416. X} 22
  1417. X
  1418. Xproc a1 {} {
  1419. X    b1
  1420. X    global a a1
  1421. X    set a $x
  1422. X    set a1 $y
  1423. X}
  1424. Xproc b1 {} {
  1425. X    c1
  1426. X    global b b1
  1427. X    set b $x
  1428. X    set b1 $y
  1429. X}
  1430. Xproc c1 {} {
  1431. X    uplevel 1 set x 111
  1432. X    uplevel #2 set y 222
  1433. X    uplevel 2 set x 333
  1434. X    uplevel #1 set y 444
  1435. X    uplevel 3 set x 555
  1436. X    uplevel #0 set y 666
  1437. X}
  1438. Xa1
  1439. Xtest uplevel-2.1 {relative and absolute uplevel} {set a} 333
  1440. Xtest uplevel-2.2 {relative and absolute uplevel} {set a1} 444
  1441. Xtest uplevel-2.3 {relative and absolute uplevel} {set b} 111
  1442. Xtest uplevel-2.4 {relative and absolute uplevel} {set b1} 222
  1443. Xtest uplevel-2.5 {relative and absolute uplevel} {set x} 555
  1444. Xtest uplevel-2.6 {relative and absolute uplevel} {set y} 666
  1445. X
  1446. Xtest uplevel-3.1 {error: non-existent level} {
  1447. X    list [catch c1 msg] $msg
  1448. X} {1 {bad level "#2"}}
  1449. Xtest uplevel-3.2 {error: non-existent level} {
  1450. X    proc c2 {} {uplevel 3 {set a b}}
  1451. X    list [catch c2 msg] $msg
  1452. X} {1 {bad level "3"}}
  1453. Xtest uplevel-3.3 {error: already at global level} {
  1454. X    list [catch {uplevel gorp} msg] $msg
  1455. X} {1 {already at top level}}
  1456. Xtest uplevel-3.4 {error: already at global level} {
  1457. X    list [catch {uplevel 1 gorp} msg] $msg
  1458. X} {1 {already at top level}}
  1459. Xtest uplevel-3.5 {error: not enough args} {
  1460. X    list [catch uplevel msg] $msg
  1461. X} {1 {wrong # args: should be "uplevel ?level? command ?command ...?"}}
  1462. X
  1463. Xproc a2 {} {
  1464. X    uplevel a3
  1465. X}
  1466. Xproc a3 {} {
  1467. X    global x y
  1468. X    set x [info level]
  1469. X    set y [info level 1]
  1470. X}
  1471. Xa2
  1472. Xtest uplevel-4.1 {info level} {set x} 1
  1473. Xtest uplevel-4.2 {info level} {set y} a3
  1474. END_OF_FILE
  1475. if test 2665 -ne `wc -c <'tcl6.1/tests/uplevel.test'`; then
  1476.     echo shar: \"'tcl6.1/tests/uplevel.test'\" unpacked with wrong size!
  1477. fi
  1478. # end of 'tcl6.1/tests/uplevel.test'
  1479. fi
  1480. if test -f 'tcl6.1/tests/while.test' -a "${1}" != "-c" ; then 
  1481.   echo shar: Will not clobber existing file \"'tcl6.1/tests/while.test'\"
  1482. else
  1483. echo shar: Extracting \"'tcl6.1/tests/while.test'\" \(2870 characters\)
  1484. sed "s/^X//" >'tcl6.1/tests/while.test' <<'END_OF_FILE'
  1485. X# Commands covered:  while
  1486. X#
  1487. X# This file contains a collection of tests for one or more of the Tcl
  1488. X# built-in commands.  Sourcing this file into Tcl runs the tests and
  1489. X# generates output for errors.  No output means no errors were found.
  1490. X#
  1491. X# Copyright 1991 Regents of the University of California
  1492. X# Permission to use, copy, modify, and distribute this
  1493. X# software and its documentation for any purpose and without
  1494. X# fee is hereby granted, provided that this copyright notice
  1495. X# appears in all copies.  The University of California makes no
  1496. X# representations about the suitability of this software for any
  1497. X# purpose.  It is provided "as is" without express or implied
  1498. X# warranty.
  1499. X#
  1500. X# $Header: /sprite/src/lib/tcl/tests/RCS/while.test,v 1.5 91/09/08 13:43:30 ouster Exp $ (Berkeley)
  1501. X
  1502. Xif {[string compare test [info procs test]] == 1} then {source defs}
  1503. X
  1504. Xtest while-1.1 {basic while loops} {
  1505. X    set count 0
  1506. X    while {$count < 10} {set count [expr $count+1]}
  1507. X    set count
  1508. X} 10
  1509. Xtest while-1.2 {basic while loops} {
  1510. X    set value xxx
  1511. X    while {2 > 3} {set value yyy}
  1512. X    set value
  1513. X} xxx
  1514. X
  1515. Xtest while-2.1 {continue in while loop} {
  1516. X    set list {1 2 3 4 5}
  1517. X    set index 0
  1518. X    set result {}
  1519. X    while {$index < 5} {
  1520. X    if {$index == 2} {set index [expr $index+1]; continue}
  1521. X    set result [concat $result [lindex $list $index]]
  1522. X    set index [expr $index+1]
  1523. X    }
  1524. X    set result
  1525. X} {1 2 4 5}
  1526. X
  1527. Xtest while-3.1 {break in while loop} {
  1528. X    set list {1 2 3 4 5}
  1529. X    set index 0
  1530. X    set result {}
  1531. X    while {$index < 5} {
  1532. X    if {$index == 3} break
  1533. X    set result [concat $result [lindex $list $index]]
  1534. X    set index [expr $index+1]
  1535. X    }
  1536. X    set result
  1537. X} {1 2 3}
  1538. X
  1539. Xtest while-4.1 {errors in while loops} {
  1540. X    set err [catch {while} msg]
  1541. X    list $err $msg
  1542. X} {1 {wrong # args: should be "while test command"}}
  1543. Xtest while-4.2 {errors in while loops} {
  1544. X    set err [catch {while 1} msg]
  1545. X    list $err $msg
  1546. X} {1 {wrong # args: should be "while test command"}}
  1547. Xtest while-4.3 {errors in while loops} {
  1548. X    set err [catch {while 1 2 3} msg]
  1549. X    list $err $msg
  1550. X} {1 {wrong # args: should be "while test command"}}
  1551. Xtest while-4.4 {errors in while loops} {
  1552. X    set err [catch {while {"a"+"b"} {error "loop aborted"}} msg]
  1553. X    list $err $msg
  1554. X} {1 {can't use non-numeric string as operand of "+"}}
  1555. Xtest while-4.5 {errors in while loops} {
  1556. X    set x 1
  1557. X    set err [catch {while {$x} {set x foo}} msg]
  1558. X    list $err $msg
  1559. X} {1 {expression didn't have numeric value}}
  1560. Xtest while-4.6 {errors in while loops} {
  1561. X    set err [catch {while {1} {error "loop aborted"}} msg]
  1562. X    list $err $msg $errorInfo
  1563. X} {1 {loop aborted} {loop aborted
  1564. X    while executing
  1565. X"error "loop aborted""
  1566. X    ("while" body line 1)
  1567. X    invoked from within
  1568. X"while {1} {error "loop aborted"}"}}
  1569. X
  1570. Xtest while-5.1 {while return result} {
  1571. X    while {0} {set a 400}
  1572. X} {}
  1573. Xtest while-5.2 {while return result} {
  1574. X    set x 1
  1575. X    while {$x} {set x 0}
  1576. X} {}
  1577. END_OF_FILE
  1578. if test 2870 -ne `wc -c <'tcl6.1/tests/while.test'`; then
  1579.     echo shar: \"'tcl6.1/tests/while.test'\" unpacked with wrong size!
  1580. fi
  1581. # end of 'tcl6.1/tests/while.test'
  1582. fi
  1583. echo shar: End of archive 2 \(of 33\).
  1584. cp /dev/null ark2isdone
  1585. MISSING=""
  1586. 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
  1587.     if test ! -f ark${I}isdone ; then
  1588.     MISSING="${MISSING} ${I}"
  1589.     fi
  1590. done
  1591. if test "${MISSING}" = "" ; then
  1592.     echo You have unpacked all 33 archives.
  1593.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1594. else
  1595.     echo You still need to unpack the following archives:
  1596.     echo "        " ${MISSING}
  1597. fi
  1598. ##  End of shell archive.
  1599. exit 0
  1600.  
  1601. exit 0 # Just in case...
  1602. -- 
  1603. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1604. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1605. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1606. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1607.