Tcl Source Code

Artifact [31a9337f8f]
Login

Artifact 31a9337f8ff6b7fd8d042ffdaf6f25e8d59aed08:

Attachment "tip157.patch" to ticket [827119ffff] added by dgp 2003-10-29 04:45:36.
Index: doc/ParseCmd.3
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/ParseCmd.3,v
retrieving revision 1.11
diff -u -r1.11 ParseCmd.3
--- doc/ParseCmd.3	19 Mar 2003 20:07:17 -0000	1.11
+++ doc/ParseCmd.3	28 Oct 2003 21:35:50 -0000
@@ -286,6 +286,16 @@
 This token has the same meaning as \fBTCL_TOKEN_WORD\fR, except that
 the word is guaranteed to consist of a single \fBTCL_TOKEN_TEXT\fR
 sub-token.  The \fInumComponents\fR field is always 1.
+.VS 8.5
+.TP
+\fBTCL_TOKEN_EXPAND_WORD\fR
+This token has the same meaning as \fBTCL_TOKEN_WORD\fR, except that
+the command parser notes this word began with the expansion
+prefix \fB{expand}\fR, indicating that after substitution,
+the list value of this word should be expanded to form multiple
+arguments in command evaluation.  This
+token type can only be created by Tcl_ParseCommand.
+.VE
 .TP
 \fBTCL_TOKEN_TEXT\fR
 The token describes a range of literal text that is part of a word.
@@ -375,12 +385,16 @@
 After \fBTcl_ParseCommand\fR returns, the first token pointed to by
 the \fItokenPtr\fR field of the
 Tcl_Parse structure always has type \fBTCL_TOKEN_WORD\fR or
-\fBTCL_TOKEN_SIMPLE_WORD\fR.  It is followed by the sub-tokens
+.VS 8.5
+\fBTCL_TOKEN_SIMPLE_WORD\fR or \fBTCL_TOKEN_EXPAND_WORD\fR.  
+It is followed by the sub-tokens
 that must be concatenated to produce the value of that word.
 The next token is the \fBTCL_TOKEN_WORD\fR or \fBTCL_TOKEN_SIMPLE_WORD\fR
-token for the second word, followed by sub-tokens for that
+of \fBTCL_TOKEN_EXPAND_WORD\fR token for the second word,
+followed by sub-tokens for that
 word, and so on until all \fInumWords\fR have been accounted
 for.
+.VE 8.5
 .PP
 After \fBTcl_ParseExpr\fR returns, the first token pointed to by
 the \fItokenPtr\fR field of the
Index: generic/tcl.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tcl.h,v
retrieving revision 1.166
diff -u -r1.166 tcl.h
--- generic/tcl.h	13 Oct 2003 16:48:06 -0000	1.166
+++ generic/tcl.h	28 Oct 2003 21:35:53 -0000
@@ -2078,6 +2078,7 @@
 #define TCL_TOKEN_VARIABLE	32
 #define TCL_TOKEN_SUB_EXPR	64
 #define TCL_TOKEN_OPERATOR	128
+#define TCL_TOKEN_EXPAND_WORD	256
 
 /*
  * Parsing error types.  On any parsing error, one of these values
Index: generic/tclBasic.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBasic.c,v
retrieving revision 1.92
diff -u -r1.92 tclBasic.c
--- generic/tclBasic.c	14 Oct 2003 15:44:52 -0000	1.92
+++ generic/tclBasic.c	28 Oct 2003 21:35:57 -0000
@@ -3499,9 +3499,10 @@
     CONST char *p, *next;
     Tcl_Parse parse;
 #define NUM_STATIC_OBJS 20
-    Tcl_Obj *staticObjArray[NUM_STATIC_OBJS], **objv;
+    Tcl_Obj *staticObjArray[NUM_STATIC_OBJS], **objv, **objvSpace;
+    int expandStatic[NUM_STATIC_OBJS], *expand;
     Tcl_Token *tokenPtr;
-    int i, code, commandLength, bytesLeft;
+    int i, code, commandLength, bytesLeft, expandRequested;
     CallFrame *savedVarFramePtr;   /* Saves old copy of iPtr->varFramePtr
 				    * in case TCL_EVAL_GLOBAL was set. */
     int allowExceptions = (iPtr->evalFlags & TCL_ALLOW_EXCEPTIONS);
@@ -3529,7 +3530,8 @@
      * command from the script and then executes it.
      */
 
-    objv = staticObjArray;
+    objv = objvSpace = staticObjArray;
+    expand = expandStatic;
     p = script;
     bytesLeft = numBytes;
     iPtr->evalFlags = 0;
@@ -3544,24 +3546,88 @@
 	    /*
 	     * Generate an array of objects for the words of the command.
 	     */
+	    int objectsNeeded = 0;
     
-	    if (parse.numWords <= NUM_STATIC_OBJS) {
-		objv = staticObjArray;
-	    } else {
-		objv = (Tcl_Obj **) ckalloc((unsigned)
+	    if (parse.numWords > NUM_STATIC_OBJS) {
+		expand = (int *) ckalloc((unsigned)
+		    (parse.numWords * sizeof (int)));
+		objvSpace = (Tcl_Obj **) ckalloc((unsigned)
 		    (parse.numWords * sizeof (Tcl_Obj *)));
 	    }
+	    expandRequested = 0;
+	    objv = objvSpace;
 	    for (objectsUsed = 0, tokenPtr = parse.tokenPtr;
 		    objectsUsed < parse.numWords;
 		    objectsUsed++, tokenPtr += (tokenPtr->numComponents + 1)) {
 		code = TclSubstTokens(interp, tokenPtr+1, 
 		            tokenPtr->numComponents, NULL);
-		if (code == TCL_OK) {
-		    objv[objectsUsed] = Tcl_GetObjResult(interp);
-		    Tcl_IncrRefCount(objv[objectsUsed]);
-		} else {
+		if (code != TCL_OK) {
 		    goto error;
 		}
+		objv[objectsUsed] = Tcl_GetObjResult(interp);
+		Tcl_IncrRefCount(objv[objectsUsed]);
+		if (tokenPtr->type == TCL_TOKEN_EXPAND_WORD) {
+		    int numElements;
+
+		    code = Tcl_ListObjLength(interp,
+			    objv[objectsUsed], &numElements);
+		    if (code == TCL_ERROR) {
+			/* Attempt to expand a non-list */
+			Tcl_Obj *msg = 
+				Tcl_NewStringObj("\n    (expanding word ", -1);
+			Tcl_Obj *wordNum = Tcl_NewIntObj(objectsUsed);
+			Tcl_IncrRefCount(wordNum);
+			Tcl_IncrRefCount(msg);
+			Tcl_AppendObjToObj(msg, wordNum);
+			Tcl_DecrRefCount(wordNum);
+			Tcl_AppendToObj(msg, ")", -1);
+			TclAppendObjToErrorInfo(interp, msg);
+			Tcl_DecrRefCount(msg);
+			goto error;
+		    }
+		    expandRequested = 1;
+		    expand[objectsUsed] = 1;
+		    objectsNeeded += (numElements ? numElements : 1);
+		} else {
+		    expand[objectsUsed] = 0;
+		    objectsNeeded++;
+		}
+	    }
+	    if (expandRequested) {
+		/* Some word expansion was requested.  Check for objv resize */
+		Tcl_Obj **copy = objvSpace;
+		int wordIdx = parse.numWords;
+		int objIdx = objectsNeeded - 1;
+
+		if ((parse.numWords > NUM_STATIC_OBJS)
+			|| (objectsNeeded > NUM_STATIC_OBJS)) {
+		    objv = objvSpace = (Tcl_Obj **) ckalloc((unsigned)
+			    (objectsNeeded * sizeof (Tcl_Obj *)));
+		}
+
+		objectsUsed = 0;
+		while (wordIdx--) {
+		    if (expand[wordIdx]) {
+			int numElements;
+			Tcl_Obj **elements, *temp = copy[wordIdx];
+			Tcl_ListObjGetElements(interp, temp,
+				&numElements, &elements);
+			objectsUsed += numElements;
+			while (numElements--) {
+			    objv[objIdx--] = elements[numElements];
+			    Tcl_IncrRefCount(elements[numElements]);
+			}
+			Tcl_DecrRefCount(temp);
+		    } else {
+			objv[objIdx--] = copy[wordIdx];
+			objectsUsed++;
+		    }
+		}
+		objv += objIdx+1;
+
+		if (copy != staticObjArray) {
+		    ckfree((char *) copy);
+		}
 	    }
     
 	    /*
@@ -3589,9 +3655,17 @@
 		Tcl_DecrRefCount(objv[i]);
 	    }
 	    objectsUsed = 0;
-	    if (objv != staticObjArray) {
-		ckfree((char *) objv);
-		objv = staticObjArray;
+	    if (objvSpace != staticObjArray) {
+		ckfree((char *) objvSpace);
+		objvSpace = staticObjArray;
+	    }
+	    /* 
+	     * Free expand separately since objvSpace could have been
+	     * reallocated above. 
+	     */
+	    if (expand != expandStatic) {
+		ckfree((char *) expand);
+		expand = expandStatic;
 	    }
 	}
 
@@ -3637,8 +3711,11 @@
     if (gotParse) {
 	Tcl_FreeParse(&parse);
     }
-    if (objv != staticObjArray) {
-	ckfree((char *) objv);
+    if (objvSpace != staticObjArray) {
+	ckfree((char *) objvSpace);
+    }
+    if (expand != expandStatic) {
+	ckfree((char *) expand);
     }
     iPtr->varFramePtr = savedVarFramePtr;
     return code;
Index: generic/tclCompile.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompile.c,v
retrieving revision 1.51
diff -u -r1.51 tclCompile.c
--- generic/tclCompile.c	14 Oct 2003 15:44:52 -0000	1.51
+++ generic/tclCompile.c	28 Oct 2003 21:36:02 -0000
@@ -273,6 +273,10 @@
 	/* return TCL_RETURN code. */
     {"expon",		  1,   -1,	    0,	 {OPERAND_NONE}},
 	/* Binary exponentiation operator: push (stknext ** stktop) */
+    {"lconcat",           2,    INT_MIN,    1,   {OPERAND_UINT1}},
+	/* Concatenate as lists the top op1 items and push result */
+    {"listverify",	  1,    0,	    0,   {OPERAND_NONE}},
+	/* Test that top of stack is a valid list; error if not */
     {0}
 };
 
@@ -843,6 +847,8 @@
 	}
 	gotParse = 1;
 	if (parse.numWords > 0) {
+	    int expand = 0;
+
 	    /*
 	     * If not the first command, pop the previous command's result
 	     * and, if we're compiling a top level command, update the last
@@ -883,17 +889,78 @@
 		fprintf(stdout, "\n");
 	    }
 #endif
+
 	    /*
-	     * Each iteration of the following loop compiles one word
-	     * from the command.
+	     * Check whether expansion has been requested for any of
+	     * the words
 	     */
-	    
+
+	    for (wordIdx = 0, tokenPtr = parse.tokenPtr;
+		    wordIdx < parse.numWords;
+		    wordIdx++, tokenPtr += (tokenPtr->numComponents + 1)) {
+		if (tokenPtr->type == TCL_TOKEN_EXPAND_WORD) {
+		    expand = 1;
+		    break;
+		}
+	    }
+
 	    envPtr->numCommands++;
 	    currCmdIndex = (envPtr->numCommands - 1);
 	    lastTopLevelCmdIndex = currCmdIndex;
 	    startCodeOffset = (envPtr->codeNext - envPtr->codeStart);
 	    EnterCmdStartData(envPtr, currCmdIndex,
 	            (parse.commandStart - envPtr->source), startCodeOffset);
+
+	    /* 
+	     * Handle separately the compilation of commands that include
+	     * any expanding words .
+	     */
+
+	    if (expand) {
+		int listCount = 0, concatCount = 0;
+		for (wordIdx = 0, tokenPtr = parse.tokenPtr;
+			wordIdx < parse.numWords;
+			wordIdx++, tokenPtr += (tokenPtr->numComponents + 1)) {
+
+		    if (listCount
+			    && (tokenPtr->type == TCL_TOKEN_EXPAND_WORD)) {
+		        TclEmitInstInt4(INST_LIST, listCount, envPtr);
+		        concatCount++;
+		        listCount = 0;
+		    }
+		    code = TclCompileTokens(interp, tokenPtr+1,
+			    tokenPtr->numComponents, envPtr);
+		    if (code != TCL_OK) {
+			goto log;
+		    }
+		    if (tokenPtr->type == TCL_TOKEN_EXPAND_WORD) {
+			/*
+			 * Include runtime check that value to be
+			 * expanded is a valid list
+			 */
+			TclEmitOpcode(INST_LIST_VERIFY, envPtr);
+			concatCount++;
+		    } else {
+			listCount++;
+		    }
+		}
+		if (listCount) {
+		    TclEmitInstInt4(INST_LIST, listCount, envPtr);
+		    concatCount++;
+		}
+		while (concatCount > 255) {
+		    TclEmitInstInt1(INST_LCONCAT1, 255, envPtr);
+		    concatCount -= 254;	/* concat pushes 1 obj, the result */
+		}
+		TclEmitInstInt1(INST_LCONCAT1, concatCount, envPtr);
+		TclEmitOpcode(INST_EVAL_STK, envPtr);
+		goto finishCommand;
+	    }
+
+	    /*
+	     * Each iteration of the following loop compiles one word
+	     * from the command.
+	     */
 	    
 	    for (wordIdx = 0, tokenPtr = parse.tokenPtr;
 		    wordIdx < parse.numWords;
Index: generic/tclCompile.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCompile.h,v
retrieving revision 1.38
diff -u -r1.38 tclCompile.h
--- generic/tclCompile.h	15 Sep 2003 09:46:22 -0000	1.38
+++ generic/tclCompile.h	28 Oct 2003 21:36:04 -0000
@@ -526,8 +526,11 @@
 
 #define INST_EXPON			99 /* TIP#123 - exponentiation */
 
+#define INST_LCONCAT1			100
+#define INST_LIST_VERIFY		101
+
 /* The last opcode */
-#define LAST_INST_OPCODE        	99
+#define LAST_INST_OPCODE        	101
 
 /*
  * Table describing the Tcl bytecode instructions: their name (for
Index: generic/tclExecute.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclExecute.c,v
retrieving revision 1.112
diff -u -r1.112 tclExecute.c
--- generic/tclExecute.c	21 Oct 2003 20:42:04 -0000	1.112
+++ generic/tclExecute.c	28 Oct 2003 21:36:15 -0000
@@ -1304,6 +1304,44 @@
 	    TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
 	    NEXT_INST_V(2, opnd, 1);
 	}
+
+    case INST_LIST_VERIFY:
+	{  
+	    int numElements = 0;
+	    valuePtr = *tosPtr;
+
+	    result = Tcl_ListObjLength(interp, valuePtr, &numElements);
+	    if (result != TCL_OK) {
+		TRACE_WITH_OBJ(("%.30s => ERROR: ", O2S(valuePtr)),
+	        	Tcl_GetObjResult(interp));
+		goto checkForCatch;
+	    }
+	    NEXT_INST_F(1, 0, 0);
+	}
+
+    case INST_LCONCAT1:
+	opnd = TclGetUInt1AtPtr(pc+1);
+	{
+	    int totalElements = 0;
+	    Tcl_Obj **currPtr;
+	    
+	    /*
+	     * Concatenate lists from the top opnd items on the stack
+	     * starting with the deepest item.
+	     *
+	     * NOTE: It is assumed that each operand is a valid list,
+	     * and prior bytecodes have already checked for this.
+	     */
+
+	    TclNewObj(objResultPtr);
+	    for (currPtr = tosPtr - (opnd-1); currPtr <= tosPtr; 
+		     currPtr++) {
+		Tcl_ListObjAppendList(NULL, objResultPtr, *currPtr);
+	    }
+
+	    TRACE_WITH_OBJ(("%u => ", opnd), objResultPtr);
+	    NEXT_INST_V(2, opnd, 1);
+	}
 	    
     case INST_INVOKE_STK4:
 	opnd = TclGetUInt4AtPtr(pc+1);
Index: generic/tclParse.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclParse.c,v
retrieving revision 1.27
diff -u -r1.27 tclParse.c
--- generic/tclParse.c	2 Apr 2003 19:31:23 -0000	1.27
+++ generic/tclParse.c	28 Oct 2003 21:36:17 -0000
@@ -287,6 +287,8 @@
 
     parsePtr->commandStart = src;
     while (1) {
+	int expandWord = 0;
+
 	/*
 	 * Create the token for the word.
 	 */
@@ -319,11 +321,12 @@
 	parsePtr->numWords++;
 
 	/*
-	 * At this point the word can have one of three forms: something
-	 * enclosed in quotes, something enclosed in braces, or an
-	 * unquoted word (anything else).
+	 * At this point the word can have one of four forms: something
+	 * enclosed in quotes, something enclosed in braces, and
+	 * expanding word, or an unquoted word (anything else).
 	 */
 
+parseWord:
 	if (*src == '"') {
 	    if (Tcl_ParseQuotedString(interp, src, numBytes,
 		    parsePtr, 1, &termPtr) != TCL_OK) {
@@ -331,11 +334,39 @@
 	    }
 	    src = termPtr; numBytes = parsePtr->end - src;
 	} else if (*src == '{') {
+	    static char expPfx[] = "expand";
+	    CONST size_t expPfxLen = sizeof(expPfx) - 1;
+	    int expIdx = wordIndex + 1;
+	    Tcl_Token *expPtr;
+
 	    if (Tcl_ParseBraces(interp, src, numBytes,
 		    parsePtr, 1, &termPtr) != TCL_OK) {
 		goto error;
 	    }
 	    src = termPtr; numBytes = parsePtr->end - src;
+
+	    /* 
+	     * Check whether the braces contained
+	     * the word expansion prefix.
+	     */
+
+	    expPtr = &parsePtr->tokenPtr[expIdx];
+	    if ( (expPfxLen == expPtr->size)
+					/* Same length as prefix */
+		    && (0 == expandWord)
+		    			/* Haven't seen prefix already */
+		    && (1 == parsePtr->numTokens - expIdx)
+	    				/* Only one token */
+		    && (0 == strncmp(expPfx,expPtr->start,expPfxLen))
+					/* Is the prefix */
+		    && (numBytes > 0)
+		    && (0 == TclParseWhiteSpace(termPtr, 1, parsePtr, &type))
+					/* Non-whitespace follows */
+		    ) {
+		expandWord = 1;
+		parsePtr->numTokens--;
+		goto parseWord;
+	    }
 	} else {
 	    /*
 	     * This is an unquoted word.  Call ParseTokens and let it do
@@ -361,6 +392,9 @@
 	if ((tokenPtr->numComponents == 1)
 		&& (tokenPtr[1].type == TCL_TOKEN_TEXT)) {
 	    tokenPtr->type = TCL_TOKEN_SIMPLE_WORD;
+	}
+	if (expandWord) {
+	    tokenPtr->type = TCL_TOKEN_EXPAND_WORD;
 	}
 
 	/*
Index: generic/tclTest.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTest.c,v
retrieving revision 1.69
diff -u -r1.69 tclTest.c
--- generic/tclTest.c	13 Oct 2003 16:48:06 -0000	1.69
+++ generic/tclTest.c	28 Oct 2003 21:36:27 -0000
@@ -3045,6 +3045,9 @@
     for (i = 0; i < parsePtr->numTokens; i++) {
 	tokenPtr = &parsePtr->tokenPtr[i];
 	switch (tokenPtr->type) {
+	    case TCL_TOKEN_EXPAND_WORD:
+		typeString = "expand";
+		break;
 	    case TCL_TOKEN_WORD:
 		typeString = "word";
 		break;
Index: library/auto.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/auto.tcl,v
retrieving revision 1.13
diff -u -r1.13 auto.tcl
--- library/auto.tcl	19 Mar 2003 21:57:40 -0000	1.13
+++ library/auto.tcl	28 Oct 2003 21:36:28 -0000
@@ -178,12 +178,12 @@
     append index "# sets an element in the auto_index array, where the\n"
     append index "# element name is the name of a command and the value is\n"
     append index "# a script that loads the command.\n\n"
-    if {$args == ""} {
+    if {[llength $args] == 0} {
 	set args *.tcl
     }
 
     auto_mkindex_parser::init
-    foreach file [eval glob $args] {
+    foreach file [glob {expand}$args] {
         if {[catch {auto_mkindex_parser::mkindex $file} msg] == 0} {
             append index $msg
         } else {
@@ -216,10 +216,10 @@
     append index "# sets an element in the auto_index array, where the\n"
     append index "# element name is the name of a command and the value is\n"
     append index "# a script that loads the command.\n\n"
-    if {[string equal $args ""]} {
+    if {[llength $args] == 0} {
 	set args *.tcl
     }
-    foreach file [eval glob $args] {
+    foreach file [glob {expand}$args] {
 	set f ""
 	set error [catch {
 	    set f [open $file]
Index: library/package.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/package.tcl,v
retrieving revision 1.26
diff -u -r1.26 package.tcl
--- library/package.tcl	24 Sep 2003 18:07:45 -0000	1.26
+++ library/package.tcl	28 Oct 2003 21:36:31 -0000
@@ -140,7 +140,7 @@
     set oldDir [pwd]
     cd $dir
 
-    if {[catch {eval glob $patternList} fileList]} {
+    if {[catch {glob {expand}$patternList} fileList]} {
 	global errorCode errorInfo
 	cd $oldDir
 	return -code error -errorcode $errorCode -errorinfo $errorInfo $fileList
@@ -206,7 +206,7 @@
 	    proc package {what args} {
 		switch -- $what {
 		    require { return ; # ignore transitive requires }
-		    default { eval __package_orig {$what} $args }
+		    default { __package_orig $what {expand}$args }
 		}
 	    }
 	    proc tclPkgUnknown args {}
@@ -261,7 +261,7 @@
 		proc ::tcl::GetAllNamespaces {{root ::}} {
 		    set list $root
 		    foreach ns [namespace children $root] {
-			eval lappend list [::tcl::GetAllNamespaces $ns]
+			lappend list {expand}[::tcl::GetAllNamespaces $ns]
 		    }
 		    return $list
 		}
Index: library/safe.tcl
===================================================================
RCS file: /cvsroot/tcl/tcl/library/safe.tcl,v
retrieving revision 1.11
diff -u -r1.11 safe.tcl
--- library/safe.tcl	16 Jul 2003 22:49:12 -0000	1.11
+++ library/safe.tcl	28 Oct 2003 21:36:31 -0000
@@ -525,7 +525,7 @@
 		# remove the hook now, otherwise if the hook
 		# calls us somehow, we'll loop
 		Unset $hookname
-		if {[catch {eval $hook [list $slave]} err]} {
+		if {[catch {{expand}$hook $slave} err]} {
 		    Log $slave "Delete hook error ($err)"
 		}
 	    }
@@ -636,15 +636,15 @@
     }
     # set/get values
     proc Set {args} {
-	eval [list Toplevel set] $args
+	Toplevel set {expand}$args
     }
     # lappend on toplevel vars
     proc Lappend {args} {
-	eval [list Toplevel lappend] $args
+	Toplevel lappend {expand}$args
     }
     # unset a var/token (currently just an global level eval)
     proc Unset {args} {
-	eval [list Toplevel unset] $args
+	Toplevel unset {expand}$args
     }
     # test existance 
     proc Exists {varname} {
@@ -691,7 +691,7 @@
     proc Log {slave msg {type ERROR}} {
 	variable Log
 	if {[info exists Log] && [llength $Log]} {
-	    eval $Log [list "$type for slave $slave : $msg"]
+	    {expand}$Log "$type for slave $slave : $msg"
 	}
     }
 
@@ -856,7 +856,7 @@
     proc Subset {slave command okpat args} {
 	set subcommand [lindex $args 0]
 	if {[regexp $okpat $subcommand]} {
-	    return [eval [list $command $subcommand] [lrange $args 1 end]]
+	    return [$command $subcommand {expand}[lrange $args 1 end]]
 	}
 	set msg "not allowed to invoke subcommand $subcommand of $command"
 	Log $slave $msg
@@ -891,8 +891,8 @@
 	set subcommand [lindex $args 0]
 
 	if {[regexp $okpat $subcommand]} {
-	    return [eval ::interp invokehidden $slave encoding $subcommand \
-		    [lrange $args 1 end]]
+	    return [::interp invokehidden $slave encoding $subcommand \
+		    {expand}[lrange $args 1 end]]
 	}
 
 	if {[string match $subcommand system]} {
Index: tests/basic.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/basic.test,v
retrieving revision 1.29
diff -u -r1.29 basic.test
--- tests/basic.test	24 Jul 2003 16:05:24 -0000	1.29
+++ tests/basic.test	28 Oct 2003 21:36:32 -0000
@@ -21,6 +21,7 @@
 package require tcltest 2
 namespace import -force ::tcltest::*
 
+testConstraint testevalex [llength [info commands testevalex]]
 testConstraint testcmdtoken [llength [info commands testcmdtoken]]
 testConstraint testcreatecommand [llength [info commands testcreatecommand]]
 testConstraint exec [llength [info commands exec]]
@@ -201,13 +202,13 @@
 } {42 {} {} Hello {} {} 42}
 
 test basic-14.1 {Tcl_CreateCommand, new cmd goes into a namespace specified in its name, if any} {testcreatecommand} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [testcreatecommand create] \
 	 [test_ns_basic::createdcommand] \
 	 [testcreatecommand delete]
 } {{} {CreatedCommandProc in ::test_ns_basic} {}}
 test basic-14.2 {Tcl_CreateCommand, namespace code ignore single ":"s in middle or end of names} {testcreatecommand} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename value:at: ""}
     list [testcreatecommand create2] \
 	 [value:at:] \
@@ -215,7 +216,7 @@
 } {{} {CreatedCommandProc2 in ::} {}}
 
 test basic-15.1 {Tcl_CreateObjCommand, new cmd goes into a namespace specified in its name, if any} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_basic {}
     proc test_ns_basic::cmd {} {  ;# proc requires that ns already exist
         return [namespace current]
@@ -231,7 +232,7 @@
 } {}
 
 test basic-18.1 {TclRenameCommand, name of existing cmd can have namespace qualifiers} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename cmd ""}
     namespace eval test_ns_basic {
         proc p {} {
@@ -243,11 +244,11 @@
          [test_ns_basic::q] 
 } {{p in ::test_ns_basic} {} {p in ::test_ns_basic}}
 test basic-18.2 {TclRenameCommand, existing cmd must be found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {rename test_ns_basic::p test_ns_basic::q} msg] $msg
 } {1 {can't rename "test_ns_basic::p": command doesn't exist}}
 test basic-18.3 {TclRenameCommand, delete cmd if new name is empty} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_basic {
         proc p {} {
             return "p in [namespace current]"
@@ -258,7 +259,7 @@
          [info commands test_ns_basic::*]
 } {::test_ns_basic::p {} {}}
 test basic-18.4 {TclRenameCommand, bad new name} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_basic {
         proc p {} {
             return "p in [namespace current]"
@@ -275,7 +276,7 @@
     list [catch {rename test_ns_basic::q :::george::martha} msg] $msg
 } {1 {can't rename to ":::george::martha": command already exists}}
 test basic-18.6 {TclRenameCommand, check for command shadowing by newly renamed cmd} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     catch {rename q ""}
     proc p {} {
@@ -298,7 +299,7 @@
 } {}
 
 test basic-20.1 {Tcl_GetCommandInfo, names for commands created inside namespaces} {testcmdtoken} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     catch {rename q ""}
     catch {unset x}
@@ -317,7 +318,7 @@
          [rename test_ns_basic::test_ns_basic2::p q] \
          [testcmdtoken name $x]
 } {{p ::test_ns_basic::test_ns_basic2::p} {} {q ::q}}
-test basic-20.3 {Tcl_GetCommandInfo, #-quoting} {
+test basic-20.3 {Tcl_GetCommandInfo, #-quoting} testcmdtoken {
     catch {rename \# ""}
     set x [testcmdtoken create \#]
     testcmdtoken name $x
@@ -327,7 +328,7 @@
 } {}
 
 test basic-22.1 {Tcl_GetCommandFullName} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_basic1 {
         namespace export cmd*
         proc cmd1 {} {}
@@ -373,7 +374,7 @@
          [interp delete test_interp]
 } {123 {set called with a 123} {}}
 test basic-24.2 {Tcl_DeleteCommandFromToken, deleting commands changes command epoch} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     proc p {} {
         return "global p"
@@ -391,7 +392,7 @@
          [test_ns_basic::callP]
 } {{namespace p} {} {global p}}
 test basic-24.3 {Tcl_DeleteCommandFromToken, delete imported cmds that refer to a deleted cmd} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     namespace eval test_ns_basic {
         namespace export p
@@ -459,7 +460,7 @@
 } {}
 
 test basic-36.1 {TclObjInvoke, lookup of "unknown" command} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {interp delete test_interp}
     interp create test_interp
     interp eval test_interp {
@@ -587,9 +588,326 @@
     subst {a[set b [format cd]}
 } -returnCodes error -result {missing close-bracket}
 
+# Some lists for expansion tests to work with
+set l1 [list a {b b} c d]
+set l2 [list e f {g g} h]
+proc l3 {} {
+    list i j k {l l}
+}
+
+# Do all tests once byte compiled and once with direct string evaluation
+for {set noComp 0} {$noComp <= 1} {incr noComp} {
+
+if $noComp {
+    interp alias {} run {} testevalex
+    set constraints testevalex
+} else {
+    interp alias {} run {} if 1
+    set constraints {}
+}
+
+test basic-47.2.$noComp {Tcl_EvalEx: error during word expansion} $constraints {
+    list [catch {run {{expand}\{}}] $::errorInfo
+} {1 {unmatched open brace in list
+    (expanding word 0)
+    invoked from within
+"{expand}\{"
+    invoked from within
+"run {{expand}\{}"}}
+
+test basic-47.3.$noComp {Tcl_EvalEx, error during substitution} $constraints {
+    list [catch {run {{expand}[error foo]}}] $::errorInfo
+} {1 {foo
+    while executing
+"error foo"
+    invoked from within
+"{expand}[error foo]"
+    invoked from within
+"run {{expand}[error foo]}"}}
+
+test basic-47.4.$noComp {Tcl_EvalEx: no expansion} $constraints {
+    run {list {expand} {expand}	{expand}}
+} {expand expand expand}
+
+test basic-47.5.$noComp {Tcl_EvalEx: expansion} $constraints {
+    run {list {expand}{} {expand}	{expand}x {expand}"y z"}
+} {expand x y z}
+
+test basic-47.6.$noComp {Tcl_EvalEx: expansion to zero args} $constraints {
+    run {list {expand}{}}
+} {}
+
+test basic-47.7.$noComp {Tcl_EvalEx: expansion to one arg} $constraints {
+    run {list {expand}x}
+} x
+
+test basic-47.8.$noComp {Tcl_EvalEx: expansion to many args} $constraints {
+    run {list {expand}"y z"}
+} {y z}
+
+test basic-47.9.$noComp {Tcl_EvalEx: expansion and subst order} $constraints {
+    set x 0
+    run {list [incr x] {expand}[incr x] [incr x] \
+		{expand}[list [incr x] [incr x]] [incr x]}
+} {1 2 3 4 5 6}
+
+test basic-47.10.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}{} a b c d e f g h i j k l m n o p q r}
+} {a b c d e f g h i j k l m n o p q r}
+
+test basic-47.11.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}1 a b c d e f g h i j k l m n o p q r}
+} {1 a b c d e f g h i j k l m n o p q r}
+
+test basic-47.12.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}{1 2} a b c d e f g h i j k l m n o p q r}
+} {1 2 a b c d e f g h i j k l m n o p q r}
+
+test basic-47.13.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}{} {expand}{1 2} a b c d e f g h i j k l m n o p q}
+} {1 2 a b c d e f g h i j k l m n o p q}
+
+test basic-47.14.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}{} a b c d e f g h i j k l m n o p q r s}
+} {a b c d e f g h i j k l m n o p q r s}
+
+test basic-47.15.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}1 a b c d e f g h i j k l m n o p q r s}
+} {1 a b c d e f g h i j k l m n o p q r s}
+
+test basic-47.16.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}{1 2} a b c d e f g h i j k l m n o p q r s}
+} {1 2 a b c d e f g h i j k l m n o p q r s}
+
+test basic-47.17.$noComp {Tcl_EvalEx: expand and memory management} $constraints {
+    run {concat {expand}{} {expand}{1 2} a b c d e f g h i j k l m n o p q r}
+} {1 2 a b c d e f g h i j k l m n o p q r}
+
+test basic-48.1.$noComp {expansion: parsing} $constraints {
+	run { # A comment
+
+		# Another comment
+		list 1  2\
+			3   {expand}$::l1
+            
+		# Comment again
+	}
+} {1 2 3 a {b b} c d}
+
+test basic-48.2.$noComp {no expansion} $constraints {
+        run {list $::l1 $::l2 [l3]}
+} {{a {b b} c d} {e f {g g} h} {i j k {l l}}}
+
+test basic-48.3.$noComp {expansion} $constraints {
+        run {list {expand}$::l1 $::l2 {expand}[l3]}
+} {a {b b} c d {e f {g g} h} i j k {l l}}
+
+test basic-48.4.$noComp {expansion: really long cmd} $constraints {
+        set cmd [list list]
+        for {set t 0} {$t < 500} {incr t} {
+            lappend cmd {{expand}$::l1}
+        }
+        llength [run [join $cmd]]
+} 2000
+
+test basic-48.5.$noComp {expansion: error detection} -setup {
+	set l "a {a b}x y"
+} -constraints $constraints -body {
+	run {list $::l1 {expand}$l}
+} -cleanup {
+	unset l
+} -returnCodes 1 -result {list element in braces followed by "x" instead of space}
+
+test basic-48.6.$noComp {expansion: odd usage} $constraints {
+        run {list {expand}$::l1$::l2}
+} {a {b b} c de f {g g} h}
+
+test basic-48.7.$noComp {expansion: odd usage} -constraints $constraints -body {
+        run {list {expand}[l3]$::l1}
+} -returnCodes 1 -result {list element in braces followed by "a" instead of space}
+
+test basic-48.8.$noComp {expansion: odd usage} $constraints {
+        run {list {expand}hej$::l1}
+} {heja {b b} c d}
+
+test basic-48.9.$noComp {expansion: Not all {expand} should trigger} $constraints {
+	run {list {expand}$::l1 \{expand\}$::l2 "{expand}$::l1" {{expand} i j k}}
+} {a {b b} c d {{expand}e f {g g} h} {{expand}a {b b} c d} {{expand} i j k}}
+
+test basic-48.10.$noComp {expansion: expansion of command word} -setup {
+	set cmd [list string range jultomte]
+} -constraints $constraints -body {
+	run {{expand}$cmd 2 6}
+} -cleanup {
+	unset cmd
+} -result ltomt
+
+test basic-48.11.$noComp {expansion: expansion into nothing} -setup {
+        set cmd {}
+        set bar {}
+} -constraints $constraints -body {
+        run {{expand}$cmd {expand}$bar}
+} -cleanup {
+	unset cmd bar
+} -result {}
+
+test basic-48.12.$noComp {expansion: odd usage} $constraints {
+	run {list {expand}$::l1 {expand}"hej hopp" {expand}$::l2}
+} {a {b b} c d hej hopp e f {g g} h}
+
+test basic-48.13.$noComp {expansion: odd usage} $constraints {
+	run {list {expand}$::l1 {expand}{hej hopp} {expand}$::l2}
+} {a {b b} c d hej hopp e f {g g} h}
+
+test basic-48.14.$noComp {expansion: hash command} -setup {
+        catch {rename \# ""}
+        set cmd "#"
+    } -constraints $constraints -body { 
+           run { {expand}$cmd apa bepa }
+    } -cleanup {
+	unset cmd
+} -returnCodes 1 -result {invalid command name "#"}
+
+test basic-48.15.$noComp {expansion: complex words} -setup {
+            set a(x) [list a {b c} d e]
+            set b x
+            set c [list {f\ g h\ i j k} x y]
+            set d {0\ 1 2 3}
+    } -constraints $constraints -body {
+            run { lappend d {expand}$a($b) {expand}[lindex $c 0] }
+    } -cleanup {
+	unset a b c d
+} -result {{0 1} 2 3 a {b c} d e {f g} {h i} j k}
+
+testConstraint memory [llength [info commands memory]]
+test basic-48.16.$noComp {expansion: testing for leaks} -setup {
+        proc getbytes {} {
+            set lines [split [memory info] "\n"]
+            lindex [lindex $lines 3] 3
+        }
+        # This test is made to stress the allocation, reallocation and
+        # object reference management in Tcl_EvalEx.
+        proc stress {} {
+            set a x
+            # Create free objects that should disappear
+            set l [list 1$a 2$a 3$a 4$a 5$a 6$a 7$a]
+            # A short number of words and a short result (8)
+            set l [run {list {expand}$l $a$a}]
+            # A short number of words and a longer result (27)
+            set l [run {list {expand}$l $a$a {expand}$l $a$a {expand}$l $a$a}]
+            # A short number of words and a longer result, with an error
+            # This is to stress the cleanup in the error case
+            if {![catch {run {_moo_ {expand}$l $a$a {expand}$l $a$a {expand}$l}}]} {
+                error "An error was expected in the previous statement"
+            }
+            # Many words
+            set l [run {list {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a {expand}$l $a$a \
+                                 {expand}$l $a$a}]
+
+            if {[llength $l] != 19*28} {
+                error "Bad Length: [llength $l] should be [expr {19*28}]"
+            }
+        }
+    } -constraints [linsert $constraints 0 memory] -body {
+        set end [getbytes]
+        for {set i 0} {$i < 5} {incr i} {
+            stress
+            set tmp $end
+            set end [getbytes]
+        }    
+        set leak [expr {$end - $tmp}]
+    } -cleanup {
+	unset end i tmp
+	rename getbytes {}
+	rename stress {}
+} -result 0
+
+test basic-48.17.$noComp {expansion: object safety} -setup {
+        set old_precision $::tcl_precision
+        set ::tcl_precision 4
+    } -constraints $constraints -body { 
+            set third [expr {1.0/3.0}]
+            set l [list $third $third]
+            set x [run {list $third {expand}$l $third}]
+	    set res [list]
+            foreach t $x {
+                lappend res [expr {$t * 3.0}]
+            }
+            set res
+    } -cleanup {
+        set ::tcl_precision $old_precision
+        unset old_precision res t l x third
+} -result {1.0 1.0 1.0 1.0}
+
+test basic-48.18.$noComp {expansion: list semantics} -constraints $constraints -body {
+        set badcmd {
+            list a b
+            set apa 10
+        }
+        set apa 0
+        list [llength [run { {expand}$badcmd }]] $apa
+    } -cleanup {
+	unset apa badcmd
+} -result {5 0}
+
+test basic-48.19.$noComp {expansion: error checking order} -body {
+        set badlist "a {}x y"
+        set a 0
+        set b 0
+        catch {run {list [incr a] {expand}$badlist [incr b]}}
+        list $a $b
+    } -constraints $constraints -cleanup {
+	unset badlist a b
+} -result {1 0}
+
+test basic-48.20.$noComp {expansion: odd case with word boundaries} $constraints {
+    run {list {expand}$::l1 {expand}"hej hopp" {expand}$::l2}
+} {a {b b} c d hej hopp e f {g g} h}
+
+test basic-48.21.$noComp {expansion: odd case with word boundaries} $constraints {
+    run {list {expand}$::l1 {expand}{hej hopp} {expand}$::l2}
+} {a {b b} c d hej hopp e f {g g} h}
+
+test basic-48.22.$noComp {expansion: odd case with word boundaries} -body {
+    run {list {expand}$::l1 {expand}"hej hopp {expand}$::l2}
+} -constraints $constraints -returnCodes error -result {missing "}
+
+test basic-48.23.$noComp {expansion: handle return codes} -constraints $constraints -body {
+        set res {}
+        for {set t 0} {$t < 10} {incr t} {
+            run { {expand}break }
+        }
+        lappend res $t
+
+        for {set t 0} {$t < 10} {incr t} {
+            run { {expand}continue }
+            set t 20
+        }
+        lappend res $t
+
+        lappend res [catch { run { {expand}{error Hejsan} } } err]
+        lappend res $err
+    } -cleanup {
+	unset res t
+} -result {0 10 1 Hejsan}
+
+} ;# End of noComp loop
+
+# Clean up after expand tests
+unset noComp l1 l2 constraints
+rename l3 {}
+rename run {}
 
-# cleanup
-catch {eval namespace delete [namespace children :: test_ns_*]}
+ #cleanup
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 catch {namespace delete george}
 catch {interp delete test_interp}
 catch {rename p ""}
Index: tests/cmdInfo.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/cmdInfo.test,v
retrieving revision 1.7
diff -u -r1.7 cmdInfo.test
--- tests/cmdInfo.test	22 Jun 2002 04:19:47 -0000	1.7
+++ tests/cmdInfo.test	28 Oct 2003 21:36:32 -0000
@@ -71,7 +71,7 @@
     rename x1 newName
     set y [testcmdtoken name $x]
     rename newName x1
-    eval lappend y [testcmdtoken name $x]
+    lappend y {expand}[testcmdtoken name $x]
 } {newName ::newName x1 ::x1}
 
 catch {rename newTestCmd {}}
@@ -88,7 +88,7 @@
     }]
     set y [testcmdtoken name $x]
     rename ::testCmd newTestCmd
-    eval lappend y [testcmdtoken name $x]
+    lappend y {expand}[testcmdtoken name $x]
 } {testCmd ::testCmd newTestCmd ::newTestCmd}
 
 test cmdinfo-6.1 {Names for commands created when outside namespaces} \
@@ -96,7 +96,7 @@
     set x [testcmdtoken create cmdInfoNs1::cmdInfoNs2::testCmd]
     set y [testcmdtoken name $x]
     rename cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2
-    eval lappend y [testcmdtoken name $x]
+    lappend y {expand}[testcmdtoken name $x]
 } {testCmd ::cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2 ::newTestCmd2}
 
 # cleanup
Index: tests/compile.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/compile.test,v
retrieving revision 1.27
diff -u -r1.27 compile.test
--- tests/compile.test	9 May 2003 13:42:40 -0000	1.27
+++ tests/compile.test	28 Oct 2003 21:36:33 -0000
@@ -274,9 +274,9 @@
 #
 # Special test for leak on interp delete [Bug 467523]. 
 ::tcltest::testConstraint exec [llength [info commands exec]]
-::tcltest::testConstraint memDebug [llength [info commands memory]]
+::tcltest::testConstraint memory [llength [info commands memory]]
 
-test compile-12.1 {testing literal leak on interp delete} {memDebug} {
+test compile-12.1 {testing literal leak on interp delete} {memory} {
     proc getbytes {} {
 	set lines [split [memory info] "\n"]
 	lindex [lindex $lines 3] 3
@@ -298,7 +298,7 @@
 # Special test for a memory error in a preliminary fix of [Bug 467523]. 
 # It requires executing a helpfile.  Presumably the child process is
 # used because when this test fails, it crashes.
-test compile-12.2 {testing error on literal deletion} {memDebug exec} {
+test compile-12.2 {testing error on literal deletion} {memory exec} {
     makeFile {
 	for {set i 0} {$i < 5} {incr i} {
 	    namespace eval bar {}
@@ -373,6 +373,137 @@
     set result
 } ""
 
+testConstraint testevalex [llength [info commands testevalex]]
+for {set noComp 1} {$noComp <= 1} {incr noComp} {
+
+if $noComp {
+    interp alias {} run {} testevalex
+    set constraints testevalex
+} else {
+    interp alias {} run {} if 1
+    set constraints {}
+}
+
+test compile-16.1.$noComp {TclCompileScript: word expansion} $constraints {
+    run "list [string repeat {{expand}a } 255]"
+} [lrepeat 255 a]
+
+test compile-16.2.$noComp {TclCompileScript: word expansion} $constraints {
+    run "list [string repeat {{expand}a } 256]"
+} [lrepeat 256 a]
+
+test compile-16.3.$noComp {TclCompileScript: word expansion} $constraints {
+    run "list [string repeat {{expand}a } 257]"
+} [lrepeat 257 a]
+
+test compile-16.4.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list}
+} {}
+
+test compile-16.5.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list {expand}{x y z}}
+} {x y z}
+
+test compile-16.6.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list {expand}[list x y z]}
+} {x y z}
+
+test compile-16.7.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list {expand}[list x y z][list x y z]}
+} {x y zx y z}
+
+test compile-16.8.$noComp {TclCompileScript: word expansion} -body {
+    set l {x y z}
+    run {{expand}list {expand}$l}
+} -constraints $constraints -cleanup {
+    unset l
+} -result {x y z}
+
+test compile-16.9.$noComp {TclCompileScript: word expansion} -body {
+    set l {x y z}
+    run {{expand}list {expand}$l$l}
+} -constraints $constraints -cleanup {
+    unset l
+} -result {x y zx y z}
+
+test compile-16.10.$noComp {TclCompileScript: word expansion} -body {
+    run {{expand}\{}
+} -constraints $constraints -returnCodes error \
+-result {unmatched open brace in list}
+
+test compile-16.11.$noComp {TclCompileScript: word expansion} -body {
+    proc badList {} {return \{}
+    run {{expand}[badList]}
+} -constraints $constraints -cleanup {
+    rename badList {}
+} -returnCodes error  -result {unmatched open brace in list}
+
+test compile-16.12.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list x y z}
+} {x y z}
+
+test compile-16.13.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list x y {expand}z}
+} {x y z}
+
+test compile-16.14.$noComp {TclCompileScript: word expansion} $constraints {
+    run {{expand}list x {expand}y z}
+} {x y z}
+
+test compile-16.15.$noComp {TclCompileScript: word expansion} $constraints {
+    run {list x y {expand}z}
+} {x y z}
+
+test compile-16.16.$noComp {TclCompileScript: word expansion} $constraints {
+    run {list x {expand}y z}
+} {x y z}
+
+test compile-16.17.$noComp {TclCompileScript: word expansion} $constraints {
+    run {list {expand}x y z}
+} {x y z}
+
+# These tests note that expansion can in theory cause the number of
+# arguments to a command to exceed INT_MAX, which is as big as objc
+# is allowed to get.
+#
+# In practice, it seems we will run out of memory before we confront
+# this issue.  Note that compiled operations run out of memory at
+# smaller objc values than direct string evaluation.
+#
+# These tests are constrained as knownBug because they are likely
+# to cause memory allocation panics somewhere, and we don't want
+# panics in the test suite.
+#
+test compile-16.18.$noComp {TclCompileScript: word expansion} -body {
+    proc LongList {} {return [lrepeat [expr {1<<10}] x]}
+    llength [run "list [string repeat {{expand}[LongList] } [expr {1<<10}]]"]
+} -constraints [linsert $constraints 0 knownBug] -cleanup {
+    rename LongList {}
+} -returnCodes ok  -result [expr {1<<20}]
+
+test compile-16.19.$noComp {TclCompileScript: word expansion} -body {
+    proc LongList {} {return [lrepeat [expr {1<<11}] x]}
+    llength [run "list [string repeat {{expand}[LongList] } [expr {1<<11}]]"]
+} -constraints [linsert $constraints 0 knownBug] -cleanup {
+    rename LongList {}
+} -returnCodes ok  -result [expr {1<<22}]
+
+test compile-16.20.$noComp {TclCompileScript: word expansion} -body {
+    proc LongList {} {return [lrepeat [expr {1<<12}] x]}
+    llength [run "list [string repeat {{expand}[LongList] } [expr {1<<12}]]"]
+} -constraints [linsert $constraints 0 knownBug] -cleanup {
+    rename LongList {}
+} -returnCodes ok  -result [expr {1<<24}]
+
+# This is the one that should cause overflow
+test compile-16.21.$noComp {TclCompileScript: word expansion} -body {
+    proc LongList {} {return [lrepeat [expr {1<<16}] x]}
+    llength [run "list [string repeat {{expand}[LongList] } [expr {1<<16}]]"]
+} -constraints [linsert $constraints 0 knownBug] -cleanup {
+    rename LongList {}
+} -returnCodes ok  -result [expr {wide(1)<<32}]
+
+}	;# End of noComp loop
 
 # cleanup
 catch {rename p ""}
Index: tests/encoding.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/encoding.test,v
retrieving revision 1.18
diff -u -r1.18 encoding.test
--- tests/encoding.test	27 Mar 2003 21:44:05 -0000	1.18
+++ tests/encoding.test	28 Oct 2003 21:36:33 -0000
@@ -541,7 +541,7 @@
     }
 }
 
-eval [list file delete] [glob -directory [temporaryDirectory] *.chars *.tcltestout]
+file delete {expand}[glob -directory [temporaryDirectory] *.chars *.tcltestout]
 # ===> Cut here <===
 
 # EscapeFreeProc, GetTableEncoding, unilen
Index: tests/execute.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/execute.test,v
retrieving revision 1.15
diff -u -r1.15 execute.test
--- tests/execute.test	4 Oct 2003 16:12:12 -0000	1.15
+++ tests/execute.test	28 Oct 2003 21:36:35 -0000
@@ -21,7 +21,7 @@
     namespace import -force ::tcltest::*
 }
 
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 catch {rename foo ""}
 catch {unset x}
 catch {unset y}
@@ -507,7 +507,7 @@
 # INST_PUSH_RETURN_CODE not tested
 
 test execute-4.1 {Tcl_GetCommandFromObj, convert to tclCmdNameType} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {unset x}
     catch {unset y}
     namespace eval test_ns_1 {
@@ -525,7 +525,7 @@
          [catch {namespace which -command ${x}${y}:cmd2} msg] $msg
 } {::test_ns_1::test_ns_2::cmd1 0 {} 0 {}}
 test execute-4.2 {Tcl_GetCommandFromObj, check if cached tclCmdNameType is invalid} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename foo ""}
     catch {unset l}
     proc foo {} {
@@ -547,7 +547,7 @@
     set l
 } {::foo ::test_ns_1::foo}
 test execute-4.3 {Tcl_GetCommandFromObj, command never found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename foo ""}
     namespace eval test_ns_1 {
         proc foo {} {
@@ -565,7 +565,7 @@
 } {::test_ns_1::foo {} 0 {}}
 
 test execute-5.1 {SetCmdNameFromAny, set cmd name to empty heap string if NULL} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {unset l}
     proc {} {} {return {}}
     {}
@@ -734,7 +734,7 @@
 if {[info commands testobj] != {}} {
    testobj freeallvars
 }
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 catch {rename foo ""}
 catch {rename p ""}
 catch {rename {} ""}
Index: tests/fCmd.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/fCmd.test,v
retrieving revision 1.31
diff -u -r1.31 fCmd.test
--- tests/fCmd.test	7 Oct 2003 16:00:33 -0000	1.31
+++ tests/fCmd.test	28 Oct 2003 21:36:52 -0000
@@ -2194,7 +2194,7 @@
     catch {file delete -force -- foo.tmp}
     createfile foo.tmp
     set attrs [file attributes foo.tmp]
-    list [catch {eval file attributes foo.tmp [lindex $attrs 0]}] [file delete -force -- foo.tmp]
+    list [catch {file attributes foo.tmp {expand}[lindex $attrs 0]}] [file delete -force -- foo.tmp]
 } {0 {}}
 
 # Find a group that exists on this Unix system, or else skip tests that
@@ -2214,13 +2214,13 @@
     catch {file delete -force -- foo.tmp}
     createfile foo.tmp
     set attrs [file attributes foo.tmp]
-    list [catch {eval file attributes foo.tmp [lrange $attrs 0 1]} msg] $msg [file delete -force -- foo.tmp]
+    list [catch {file attributes foo.tmp {expand}[lrange $attrs 0 1]} msg] $msg [file delete -force -- foo.tmp]
 } {0 {} {}}
 test fCmd-27.6 {TclFileAttrsCmd - setting more than one option} {foundGroup} {
     catch {file delete -force -- foo.tmp}
     createfile foo.tmp
     set attrs [file attributes foo.tmp]
-    list [catch {eval file attributes foo.tmp [lrange $attrs 0 3]} msg] $msg [file delete -force -- foo.tmp]
+    list [catch {file attributes foo.tmp {expand}[lrange $attrs 0 3]} msg] $msg [file delete -force -- foo.tmp]
 } {0 {} {}}
 
 if {[string equal $tcl_platform(platform) "windows"]} {
Index: tests/http.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/http.test,v
retrieving revision 1.35
diff -u -r1.35 http.test
--- tests/http.test	18 Jul 2003 19:36:40 -0000	1.35
+++ tests/http.test	28 Oct 2003 21:36:52 -0000
@@ -100,7 +100,7 @@
     set savedconf [http::config]
     http::config -proxyhost nowhere.come -proxyport 8080 -proxyfilter myFilter -useragent "Tcl Test Suite"
     set x [http::config]
-    eval http::config $savedconf
+    http::config {expand}$savedconf
     set x
 } {-accept */* -proxyfilter myFilter -proxyhost nowhere.come -proxyport 8080 -useragent {Tcl Test Suite}}
 
Index: tests/init.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/init.test,v
retrieving revision 1.11
diff -u -r1.11 init.test
--- tests/init.test	27 Jun 2003 17:22:41 -0000	1.11
+++ tests/init.test	28 Oct 2003 21:36:53 -0000
@@ -18,7 +18,7 @@
 }
 
 # Clear out any namespaces called test_ns_*
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 
 # Six cases - white box testing
 
Index: tests/interp.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/interp.test,v
retrieving revision 1.24
diff -u -r1.24 interp.test
--- tests/interp.test	4 Sep 2003 17:36:56 -0000	1.24
+++ tests/interp.test	28 Oct 2003 21:36:57 -0000
@@ -2084,7 +2084,7 @@
     proc MyTestAlias {interp args} {
 	global aliasTrace;
 	lappend aliasTrace $args;
-	eval interp invokehidden [list $interp] $args
+	interp invokehidden $interp {expand}$args
     }
     foreach c {return} {
 	interp hide $interp  $c;
Index: tests/io.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/io.test,v
retrieving revision 1.47
diff -u -r1.47 io.test
--- tests/io.test	7 Oct 2003 21:45:39 -0000	1.47
+++ tests/io.test	28 Oct 2003 21:37:02 -0000
@@ -2147,7 +2147,7 @@
     close $f
     lappend l [lsort [testchannel open]]
     set x [list $consoleFileNames \
-		[lsort [eval list $consoleFileNames $f]] \
+		[lsort [list {expand}$consoleFileNames $f]] \
 		$consoleFileNames]
     string compare $l $x
 } 0
Index: tests/ioUtil.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/ioUtil.test,v
retrieving revision 1.14
diff -u -r1.14 ioUtil.test
--- tests/ioUtil.test	11 Apr 2003 16:00:00 -0000	1.14
+++ tests/ioUtil.test	28 Oct 2003 21:37:03 -0000
@@ -191,7 +191,7 @@
 cd [temporaryDirectory]
 
 test ioUtil-3.1 {TclOpenFileChannel: Check that none of the test procs are there.} {testopenfilechannelproc} {
-    catch {eval [list file delete -force] [glob *testOpenFileChannel*]}
+    catch {file delete -force {expand}[glob *testOpenFileChannel*]}
     catch {file exists testOpenFileChannel1%.fil} err1
     catch {file exists testOpenFileChannel2%.fil} err2
     catch {file exists testOpenFileChannel3%.fil} err3
Index: tests/iogt.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/iogt.test,v
retrieving revision 1.7
diff -u -r1.7 iogt.test
--- tests/iogt.test	4 Jul 2002 15:46:55 -0000	1.7
+++ tests/iogt.test	28 Oct 2003 21:37:04 -0000
@@ -147,8 +147,8 @@
     # fixed port, not so good. lets hope for the best, for now.
     set port 4000
 
-    eval exec tclsh __echo_srv__.tcl \
-	    $port $fdelay $idelay $blocks >@stdout &
+    exec tclsh __echo_srv__.tcl \
+	    $port $fdelay $idelay {expand}$blocks >@stdout &
 
     after 500
 
Index: tests/lindex.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/lindex.test,v
retrieving revision 1.10
diff -u -r1.10 lindex.test
--- tests/lindex.test	19 Apr 2002 13:08:56 -0000	1.10
+++ tests/lindex.test	28 Oct 2003 21:37:04 -0000
@@ -19,68 +19,68 @@
     namespace import -force ::tcltest::*
 }
 
-set lindex lindex
 set minus -
+testConstraint testevalex [llength [info commands testevalex]]
 
 # Tests of Tcl_LindexObjCmd, NOT COMPILED
 
-test lindex-1.1 {wrong # args} {
-    list [catch {eval $lindex} result] $result
+test lindex-1.1 {wrong # args} testevalex {
+    list [catch {testevalex lindex} result] $result
 } "1 {wrong # args: should be \"lindex list ?index...?\"}"
 
 # Indices that are lists or convertible to lists
 
-test lindex-2.1 {empty index list} {
+test lindex-2.1 {empty index list} testevalex {
     set x {}
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {{a b c} {a b c}}
 
-test lindex-2.2 {singleton index list} {
+test lindex-2.2 {singleton index list} testevalex {
     set x { 1 }
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {b b}
 
-test lindex-2.3 {multiple indices in list} {
+test lindex-2.3 {multiple indices in list} testevalex {
     set x {1 2}
-    list [eval [list $lindex {{a b c} {d e f}} $x]] \
-	[eval [list $lindex {{a b c} {d e f}} $x]]
+    list [testevalex {lindex {{a b c} {d e f}} $x}] \
+	[testevalex {lindex {{a b c} {d e f}} $x}]
 } {f f}
 
-test lindex-2.4 {malformed index list} {
+test lindex-2.4 {malformed index list} testevalex {
     set x \{
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } {1 bad\ index\ \"\{\":\ must\ be\ integer\ or\ end?-integer?}
 
 # Indices that are integers or convertible to integers
 
-test lindex-3.1 {integer -1} {
+test lindex-3.1 {integer -1} testevalex {
     set x ${minus}1
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {{} {}}
 
-test lindex-3.2 {integer 0} {
+test lindex-3.2 {integer 0} testevalex {
     set x [string range 00 0 0]
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {a a}
 
-test lindex-3.3 {integer 2} {
+test lindex-3.3 {integer 2} testevalex {
     set x [string range 22 0 0]
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {c c}
 
-test lindex-3.4 {integer 3} {
+test lindex-3.4 {integer 3} testevalex {
     set x [string range 33 0 0]
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {{} {}}
 
-test lindex-3.5 {bad octal} {
+test lindex-3.5 {bad octal} testevalex {
     set x 08
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } "1 {bad index \"08\": must be integer or end?-integer? (looks like invalid octal number)}"
 
-test lindex-3.6 {bad octal} {
+test lindex-3.6 {bad octal} testevalex {
     set x -09
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } "1 {bad index \"-09\": must be integer or end?-integer? (looks like invalid octal number)}"
 
 test lindex-3.7 {indexes don't shimmer wide ints} {
@@ -90,122 +90,122 @@
 
 # Indices relative to end
 
-test lindex-4.1 {index = end} {
+test lindex-4.1 {index = end} testevalex {
     set x end
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {c c}
 
-test lindex-4.2 {index = end--1} {
+test lindex-4.2 {index = end--1} testevalex {
     set x end--1
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {{} {}}
 
-test lindex-4.3 {index = end-0} {
+test lindex-4.3 {index = end-0} testevalex {
     set x end-0
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {c c}
 
-test lindex-4.4 {index = end-2} {
+test lindex-4.4 {index = end-2} testevalex {
     set x end-2
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {a a}
 
-test lindex-4.5 {index = end-3} {
+test lindex-4.5 {index = end-3} testevalex {
     set x end-3
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {{} {}}
 
-test lindex-4.6 {bad octal} {
+test lindex-4.6 {bad octal} testevalex {
     set x end-08
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } "1 {bad index \"end-08\": must be integer or end?-integer? (looks like invalid octal number)}"
 
-test lindex-4.7 {bad octal} {
+test lindex-4.7 {bad octal} testevalex {
     set x end--09
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } "1 {bad index \"end--09\": must be integer or end?-integer?}"
 
-test lindex-4.8 {bad integer, not octal} {
+test lindex-4.8 {bad integer, not octal} testevalex {
     set x end-0a2
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } "1 {bad index \"end-0a2\": must be integer or end?-integer?}"
 
-test lindex-4.9 {incomplete end} {
+test lindex-4.9 {incomplete end} testevalex {
     set x en
-    list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+    list [testevalex {lindex {a b c} $x}] [testevalex {lindex {a b c} $x}]
 } {c c}
 
-test lindex-4.10 {incomplete end-} {
+test lindex-4.10 {incomplete end-} testevalex {
     set x end-
-    list [catch { eval [list $lindex {a b c} $x] } result] $result
+    list [catch { testevalex {lindex {a b c} $x} } result] $result
 } "1 {bad index \"end-\": must be integer or end?-integer?}"
 
-test lindex-5.1 {bad second index} {
-    list [catch { eval [list $lindex {a b c} 0 0a2] } result] $result
+test lindex-5.1 {bad second index} testevalex {
+    list [catch { testevalex {lindex {a b c} 0 0a2} } result] $result
 } "1 {bad index \"0a2\": must be integer or end?-integer?}"
 
-test lindex-5.2 {good second index} {
-    eval [list $lindex {{a b c} {d e f} {g h i}} 1 2]
+test lindex-5.2 {good second index} testevalex {
+    testevalex {lindex {{a b c} {d e f} {g h i}} 1 2}
 } f
 
-test lindex-5.3 {three indices} {
-    eval [list $lindex {{{a b} {c d}} {{e f} {g h}}} 1 0 1]
+test lindex-5.3 {three indices} testevalex {
+    testevalex {lindex {{{a b} {c d}} {{e f} {g h}}} 1 0 1}
 } f
-test lindex-6.1 {error conditions in parsing list} {
-    list [catch {eval [list $lindex "a \{" 2]} msg] $msg
+test lindex-6.1 {error conditions in parsing list} testevalex {
+    list [catch {testevalex {lindex "a \{" 2}} msg] $msg
 } {1 {unmatched open brace in list}}
-test lindex-6.2 {error conditions in parsing list} {
-    list [catch {eval [list $lindex {a {b c}d e} 2]} msg] $msg
+test lindex-6.2 {error conditions in parsing list} testevalex {
+    list [catch {testevalex {lindex {a {b c}d e} 2}} msg] $msg
 } {1 {list element in braces followed by "d" instead of space}}
-test lindex-6.3 {error conditions in parsing list} {
-    list [catch {eval [list $lindex {a "b c"def ghi} 2]} msg] $msg
+test lindex-6.3 {error conditions in parsing list} testevalex {
+    list [catch {testevalex {lindex {a "b c"def ghi} 2}} msg] $msg
 } {1 {list element in quotes followed by "def" instead of space}}
 
-test lindex-7.1 {quoted elements} {
-    eval [list $lindex {a "b c" d} 1]
+test lindex-7.1 {quoted elements} testevalex {
+    testevalex {lindex {a "b c" d} 1}
 } {b c}
-test lindex-7.2 {quoted elements} {
-    eval [list $lindex {"{}" b c} 0]
+test lindex-7.2 {quoted elements} testevalex {
+    testevalex {lindex {"{}" b c} 0}
 } {{}}
-test lindex-7.3 {quoted elements} {
-    eval [list $lindex {ab "c d \" x" y} 1]
+test lindex-7.3 {quoted elements} testevalex {
+    testevalex {lindex {ab "c d \" x" y} 1}
 } {c d " x}
 test lindex-7.4 {quoted elements} {
     lindex {a b {c d "e} {f g"}} 2
 } {c d "e}
 
-test lindex-8.1 {data reuse} {
+test lindex-8.1 {data reuse} testevalex {
     set x 0
-    eval [list $lindex $x $x]
+    testevalex {lindex $x $x}
 } {0}
 
-test lindex-8.2 {data reuse} {
+test lindex-8.2 {data reuse} testevalex {
     set a 0
-    eval [list $lindex $a $a $a]
+    testevalex {lindex $a $a $a}
 } 0
-test lindex-8.3 {data reuse} {
+test lindex-8.3 {data reuse} testevalex {
     set a 1
-    eval [list $lindex $a $a $a]
+    testevalex {lindex $a $a $a}
 } {}
 
-test lindex-8.4 {data reuse} {
+test lindex-8.4 {data reuse} testevalex {
     set x [list 0 0]
-    eval [list $lindex $x $x]
+    testevalex {lindex $x $x}
 } {0}
 
-test lindex-8.5 {data reuse} {
+test lindex-8.5 {data reuse} testevalex {
     set x 0
-    eval [list $lindex $x [list $x $x]]
+    testevalex {lindex $x [list $x $x]}
 } {0}
 
-test lindex-8.6 {data reuse} {
+test lindex-8.6 {data reuse} testevalex {
     set x [list 1 1]
-    eval [list $lindex $x $x]
+    testevalex {lindex $x $x}
 } {}
 
-test lindex-8.7 {data reuse} {
+test lindex-8.7 {data reuse} testevalex {
     set x 1
-    eval [list lindex $x [list $x $x]]
+    testevalex {lindex $x [list $x $x]}
 } {}
 
 #----------------------------------------------------------------------
@@ -469,7 +469,6 @@
     set result
 } {}
 
-catch { unset lindex}
 catch { unset minus }
 
 # cleanup
Index: tests/lset.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/lset.test,v
retrieving revision 1.3
diff -u -r1.3 lset.test
--- tests/lset.test	23 Nov 2001 01:26:10 -0000	1.3
+++ tests/lset.test	28 Oct 2003 21:37:05 -0000
@@ -22,427 +22,427 @@
     error "trace failed"
 }
 
-set lset lset
+testConstraint testevalex [llength [info commands testevalex]]
 
 set noRead {}
 trace add variable noRead read failTrace
 set noWrite {a b c}
 trace add variable noWrite write failTrace
 
-test lset-1.1 {lset, not compiled, arg count} {
-    list [catch {eval $lset} msg] $msg
+test lset-1.1 {lset, not compiled, arg count} testevalex {
+    list [catch {testevalex lset} msg] $msg
 } "1 {wrong \# args: should be \"lset listVar index ?index...? value\"}"
 
-test lset-1.2 {lset, not compiled, no such var} {
-    list [catch {eval [list $lset noSuchVar 0 {}]} msg] $msg
+test lset-1.2 {lset, not compiled, no such var} testevalex {
+    list [catch {testevalex {lset noSuchVar 0 {}}} msg] $msg
 } "1 {can't read \"noSuchVar\": no such variable}"
 
-test lset-1.3 {lset, not compiled, var not readable} {
-    list [catch {eval [list $lset noRead 0 {}]} msg] $msg
+test lset-1.3 {lset, not compiled, var not readable} testevalex {
+    list [catch {testevalex {lset noRead 0 {}}} msg] $msg
 } "1 {can't read \"noRead\": trace failed}"
 
-test lset-2.1 {lset, not compiled, 3 args, second arg a plain index} {
+test lset-2.1 {lset, not compiled, 3 args, second arg a plain index} testevalex {
     set x {0 1 2}
-    list [eval [list $lset x 0 3]] $x
+    list [testevalex {lset x 0 3}] $x
 } {{3 1 2} {3 1 2}}
 
-test lset-2.2 {lset, not compiled, 3 args, second arg neither index nor list} {
+test lset-2.2 {lset, not compiled, 3 args, second arg neither index nor list} testevalex {
     set x {0 1 2}
     list [catch {
-	eval [list $lset x {{bad}1} 3]
+	testevalex {lset x {{bad}1} 3}
     } msg] $msg
 } "1 {bad index \"{bad}1\": must be integer or end?-integer?}"
 
-test lset-3.1 {lset, not compiled, 3 args, data duplicated} {
+test lset-3.1 {lset, not compiled, 3 args, data duplicated} testevalex {
     set x {0 1 2}
-    list [eval [list $lset x 0 $x]] $x
+    list [testevalex {lset x 0 $x}] $x
 } {{{0 1 2} 1 2} {{0 1 2} 1 2}}
 
-test lset-3.2 {lset, not compiled, 3 args, data duplicated} {
+test lset-3.2 {lset, not compiled, 3 args, data duplicated} testevalex {
     set x {0 1}
     set y $x
-    list [eval [list $lset x 0 2]] $x $y
+    list [testevalex {lset x 0 2}] $x $y
 } {{2 1} {2 1} {0 1}}
 
-test lset-3.3 {lset, not compiled, 3 args, data duplicated} {
+test lset-3.3 {lset, not compiled, 3 args, data duplicated} testevalex {
     set x {0 1}
     set y $x
-    list [eval [list $lset x 0 $x]] $x $y
+    list [testevalex {lset x 0 $x}] $x $y
 } {{{0 1} 1} {{0 1} 1} {0 1}}
 
-test lset-3.4 {lset, not compiled, 3 args, data duplicated} {
+test lset-3.4 {lset, not compiled, 3 args, data duplicated} testevalex {
     set x {0 1 2}
-    list [eval [list $lset x [list 0] $x]] $x
+    list [testevalex {lset x [list 0] $x}] $x
 } {{{0 1 2} 1 2} {{0 1 2} 1 2}}
 
-test lset-3.5 {lset, not compiled, 3 args, data duplicated} {
+test lset-3.5 {lset, not compiled, 3 args, data duplicated} testevalex {
     set x {0 1}
     set y $x
-    list [eval [list $lset x [list 0] 2]] $x $y
+    list [testevalex {lset x [list 0] 2}] $x $y
 } {{2 1} {2 1} {0 1}}
 
-test lset-3.6 {lset, not compiled, 3 args, data duplicated} {
+test lset-3.6 {lset, not compiled, 3 args, data duplicated} testevalex {
     set x {0 1}
     set y $x
-    list [eval [list $lset x [list 0] $x]] $x $y
+    list [testevalex {lset x [list 0] $x}] $x $y
 } {{{0 1} 1} {{0 1} 1} {0 1}}
 
-test lset-4.1 {lset, not compiled, 3 args, not a list} {
+test lset-4.1 {lset, not compiled, 3 args, not a list} testevalex {
     set a "x \{"
     list [catch {
-	eval [list $lset a [list 0] y]
+	testevalex {lset a [list 0] y}
     } msg] $msg
 } {1 {unmatched open brace in list}}
 
-test lset-4.2 {lset, not compiled, 3 args, bad index} {
+test lset-4.2 {lset, not compiled, 3 args, bad index} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a [list 2a2] w]
+	testevalex {lset a [list 2a2] w}
     } msg] $msg
 } {1 {bad index "2a2": must be integer or end?-integer?}}
 
-test lset-4.3 {lset, not compiled, 3 args, index out of range} {
+test lset-4.3 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a [list -1] w]
+	testevalex {lset a [list -1] w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.4 {lset, not compiled, 3 args, index out of range} {
+test lset-4.4 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a [list 3] w]
+	testevalex {lset a [list 3] w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.5 {lset, not compiled, 3 args, index out of range} {
+test lset-4.5 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a [list end--1] w]
+	testevalex {lset a [list end--1] w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.6 {lset, not compiled, 3 args, index out of range} {
+test lset-4.6 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a [list end-3] w]
+	testevalex {lset a [list end-3] w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.7 {lset, not compiled, 3 args, not a list} {
+test lset-4.7 {lset, not compiled, 3 args, not a list} testevalex {
     set a "x \{"
     list [catch {
-	eval [list $lset a 0 y]
+	testevalex {lset a 0 y}
     } msg] $msg
 } {1 {unmatched open brace in list}}
 
-test lset-4.8 {lset, not compiled, 3 args, bad index} {
+test lset-4.8 {lset, not compiled, 3 args, bad index} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a 2a2 w]
+	testevalex {lset a 2a2 w}
     } msg] $msg
 } {1 {bad index "2a2": must be integer or end?-integer?}}
 
-test lset-4.9 {lset, not compiled, 3 args, index out of range} {
+test lset-4.9 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a -1 w]
+	testevalex {lset a -1 w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.10 {lset, not compiled, 3 args, index out of range} {
+test lset-4.10 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a 3 w]
+	testevalex {lset a 3 w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.11 {lset, not compiled, 3 args, index out of range} {
+test lset-4.11 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a end--1 w]
+	testevalex {lset a end--1 w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-4.12 {lset, not compiled, 3 args, index out of range} {
+test lset-4.12 {lset, not compiled, 3 args, index out of range} testevalex {
     set a {x y z}
     list [catch {
-	eval [list $lset a end-3 w]
+	testevalex {lset a end-3 w}
     } msg] $msg
 } {1 {list index out of range}}
 
-test lset-5.1 {lset, not compiled, 3 args, can't set variable} {
+test lset-5.1 {lset, not compiled, 3 args, can't set variable} testevalex {
     list [catch {
-	eval [list $lset noWrite 0 d]
+	testevalex {lset noWrite 0 d}
     } msg] $msg $noWrite
 } {1 {can't set "noWrite": trace failed} {d b c}}
 
-test lset-5.2 {lset, not compiled, 3 args, can't set variable} {
+test lset-5.2 {lset, not compiled, 3 args, can't set variable} testevalex {
     list [catch {
-	eval [list $lset noWrite [list 0] d]
+	testevalex {lset noWrite [list 0] d}
     } msg] $msg $noWrite
 } {1 {can't set "noWrite": trace failed} {d b c}}
 
-test lset-6.1 {lset, not compiled, 3 args, 1-d list basics} {
+test lset-6.1 {lset, not compiled, 3 args, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a 0 a]] $a
+    list [testevalex {lset a 0 a}] $a
 } {{a y z} {a y z}}
 
-test lset-6.2 {lset, not compiled, 3 args, 1-d list basics} {
+test lset-6.2 {lset, not compiled, 3 args, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a [list 0] a]] $a
+    list [testevalex {lset a [list 0] a}] $a
 } {{a y z} {a y z}}
 
-test lset-6.3 {lset, not compiled, 1-d list basics} {
+test lset-6.3 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a 2 a]] $a
+    list [testevalex {lset a 2 a}] $a
 } {{x y a} {x y a}}
 
-test lset-6.4 {lset, not compiled, 1-d list basics} {
+test lset-6.4 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a [list 2] a]] $a
+    list [testevalex {lset a [list 2] a}] $a
 } {{x y a} {x y a}}
 
-test lset-6.5 {lset, not compiled, 1-d list basics} {
+test lset-6.5 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a end a]] $a
+    list [testevalex {lset a end a}] $a
 } {{x y a} {x y a}}
 
-test lset-6.6 {lset, not compiled, 1-d list basics} {
+test lset-6.6 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a [list end] a]] $a
+    list [testevalex {lset a [list end] a}] $a
 } {{x y a} {x y a}}
 
-test lset-6.7 {lset, not compiled, 1-d list basics} {
+test lset-6.7 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a end-0 a]] $a
+    list [testevalex {lset a end-0 a}] $a
 } {{x y a} {x y a}}
 
-test lset-6.8 {lset, not compiled, 1-d list basics} {
+test lset-6.8 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a [list end-0] a]] $a
+    list [testevalex {lset a [list end-0] a}] $a
 } {{x y a} {x y a}}
 
-test lset-6.9 {lset, not compiled, 1-d list basics} {
+test lset-6.9 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a end-2 a]] $a
+    list [testevalex {lset a end-2 a}] $a
 } {{a y z} {a y z}}
 
-test lset-6.10 {lset, not compiled, 1-d list basics} {
+test lset-6.10 {lset, not compiled, 1-d list basics} testevalex {
     set a {x y z}
-    list [eval [list $lset a [list end-2] a]] $a
+    list [testevalex {lset a [list end-2] a}] $a
 } {{a y z} {a y z}}
 
-test lset-7.1 {lset, not compiled, data sharing} {
+test lset-7.1 {lset, not compiled, data sharing} testevalex {
     set a 0
-    list [eval [list $lset a $a {gag me}]] $a
+    list [testevalex {lset a $a {gag me}}] $a
 } {{{gag me}} {{gag me}}}
 
-test lset-7.2 {lset, not compiled, data sharing} {
+test lset-7.2 {lset, not compiled, data sharing} testevalex {
     set a [list 0]
-    list [eval [list $lset a $a {gag me}]] $a
+    list [testevalex {lset a $a {gag me}}] $a
 } {{{gag me}} {{gag me}}}
 
-test lset-7.3 {lset, not compiled, data sharing} {
+test lset-7.3 {lset, not compiled, data sharing} testevalex {
     set a {x y}
-    list [eval [list $lset a 0 $a]] $a
+    list [testevalex {lset a 0 $a}] $a
 } {{{x y} y} {{x y} y}}
 
-test lset-7.4 {lset, not compiled, data sharing} {
+test lset-7.4 {lset, not compiled, data sharing} testevalex {
     set a {x y}
-    list [eval [list $lset a [list 0] $a]] $a
+    list [testevalex {lset a [list 0] $a}] $a
 } {{{x y} y} {{x y} y}}
 
-test lset-7.5 {lset, not compiled, data sharing} {
+test lset-7.5 {lset, not compiled, data sharing} testevalex {
     set n 0
     set a {x y}
-    list [eval [list $lset a $n $n]] $a $n
+    list [testevalex {lset a $n $n}] $a $n
 } {{0 y} {0 y} 0}
 
-test lset-7.6 {lset, not compiled, data sharing} {
+test lset-7.6 {lset, not compiled, data sharing} testevalex {
     set n [list 0]
     set a {x y}
-    list [eval [list $lset a $n $n]] $a $n
+    list [testevalex {lset a $n $n}] $a $n
 } {{0 y} {0 y} 0}
 
-test lset-7.7 {lset, not compiled, data sharing} {
+test lset-7.7 {lset, not compiled, data sharing} testevalex {
     set n 0
     set a [list $n $n]
-    list [eval [list $lset a $n 1]] $a $n
+    list [testevalex {lset a $n 1}] $a $n
 } {{1 0} {1 0} 0}
 
-test lset-7.8 {lset, not compiled, data sharing} {
+test lset-7.8 {lset, not compiled, data sharing} testevalex {
     set n [list 0]
     set a [list $n $n]
-    list [eval [list $lset a $n 1]] $a $n
+    list [testevalex {lset a $n 1}] $a $n
 } {{1 0} {1 0} 0}
 
-test lset-7.9 {lset, not compiled, data sharing} {
+test lset-7.9 {lset, not compiled, data sharing} testevalex {
     set a 0
-    list [eval [list $lset a $a $a]] $a
+    list [testevalex {lset a $a $a}] $a
 } {0 0}
 
-test lset-7.10 {lset, not compiled, data sharing} {
+test lset-7.10 {lset, not compiled, data sharing} testevalex {
     set a [list 0]
-    list [eval [list $lset a $a $a]] $a
+    list [testevalex {lset a $a $a}] $a
 } {0 0}
 
-test lset-8.1 {lset, not compiled, malformed sublist} {
+test lset-8.1 {lset, not compiled, malformed sublist} testevalex {
     set a [list "a \{" b]
-    list [catch {eval [list $lset a 0 1 c]} msg] $msg
+    list [catch {testevalex {lset a 0 1 c}} msg] $msg
 } {1 {unmatched open brace in list}}
 
-test lset-8.2 {lset, not compiled, malformed sublist} {
+test lset-8.2 {lset, not compiled, malformed sublist} testevalex {
     set a [list "a \{" b]
-    list [catch {eval [list $lset a {0 1} c]} msg] $msg
+    list [catch {testevalex {lset a {0 1} c}} msg] $msg
 } {1 {unmatched open brace in list}}
 
-test lset-8.3 {lset, not compiled, bad second index} {
+test lset-8.3 {lset, not compiled, bad second index} testevalex {
     set a {{b c} {d e}}
-    list [catch {eval [list $lset a 0 2a2 f]} msg] $msg
+    list [catch {testevalex {lset a 0 2a2 f}} msg] $msg
 } {1 {bad index "2a2": must be integer or end?-integer?}}
 
-test lset-8.4 {lset, not compiled, bad second index} {
+test lset-8.4 {lset, not compiled, bad second index} testevalex {
     set a {{b c} {d e}}
-    list [catch {eval [list $lset a {0 2a2} f]} msg] $msg
+    list [catch {testevalex {lset a {0 2a2} f}} msg] $msg
 } {1 {bad index "2a2": must be integer or end?-integer?}}
 
-test lset-8.5 {lset, not compiled, second index out of range} {
+test lset-8.5 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a 2 -1 h]} msg] $msg
+    list [catch {testevalex {lset a 2 -1 h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.6 {lset, not compiled, second index out of range} {
+test lset-8.6 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a {2 -1} h]} msg] $msg
+    list [catch {testevalex {lset a {2 -1} h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.7 {lset, not compiled, second index out of range} {
+test lset-8.7 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a 2 2 h]} msg] $msg
+    list [catch {testevalex {lset a 2 2 h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.8 {lset, not compiled, second index out of range} {
+test lset-8.8 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a {2 2} h]} msg] $msg
+    list [catch {testevalex {lset a {2 2} h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.9 {lset, not compiled, second index out of range} {
+test lset-8.9 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a 2 end--1 h]} msg] $msg
+    list [catch {testevalex {lset a 2 end--1 h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.10 {lset, not compiled, second index out of range} {
+test lset-8.10 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a {2 end--1} h]} msg] $msg
+    list [catch {testevalex {lset a {2 end--1} h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.11 {lset, not compiled, second index out of range} {
+test lset-8.11 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a 2 end-2 h]} msg] $msg
+    list [catch {testevalex {lset a 2 end-2 h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-8.12 {lset, not compiled, second index out of range} {
+test lset-8.12 {lset, not compiled, second index out of range} testevalex {
     set a {{b c} {d e} {f g}}
-    list [catch {eval [list $lset a {2 end-2} h]} msg] $msg
+    list [catch {testevalex {lset a {2 end-2} h}} msg] $msg
 } {1 {list index out of range}}
 
-test lset-9.1 {lset, not compiled, entire variable} {
+test lset-9.1 {lset, not compiled, entire variable} testevalex {
     set a x
-    list [eval [list $lset a y]] $a
+    list [testevalex {lset a y}] $a
 } {y y}
 
-test lset-9.2 {lset, not compiled, entire variable} {
+test lset-9.2 {lset, not compiled, entire variable} testevalex {
     set a x
-    list [eval [list $lset a {} y]] $a
+    list [testevalex {lset a {} y}] $a
 } {y y}
 
-test lset-10.1 {lset, not compiled, shared data} {
+test lset-10.1 {lset, not compiled, shared data} testevalex {
     set row {p q}
     set a [list $row $row]
-    list [eval [list $lset a 0 0 x]] $a
+    list [testevalex {lset a 0 0 x}] $a
 } {{{x q} {p q}} {{x q} {p q}}}
 
-test lset-10.2 {lset, not compiled, shared data} {
+test lset-10.2 {lset, not compiled, shared data} testevalex {
     set row {p q}
     set a [list $row $row]
-    list [eval [list $lset a {0 0} x]] $a
+    list [testevalex {lset a {0 0} x}] $a
 } {{{x q} {p q}} {{x q} {p q}}}
 
-test lset-11.1 {lset, not compiled, 2-d basics} {
+test lset-11.1 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a 0 0 f]] $a
+    list [testevalex {lset a 0 0 f}] $a
 } {{{f c} {d e}} {{f c} {d e}}}
 
-test lset-11.2 {lset, not compiled, 2-d basics} {
+test lset-11.2 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a {0 0} f]] $a
+    list [testevalex {lset a {0 0} f}] $a
 } {{{f c} {d e}} {{f c} {d e}}}
 
-test lset-11.3 {lset, not compiled, 2-d basics} {
+test lset-11.3 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a 0 1 f]] $a
+    list [testevalex {lset a 0 1 f}] $a
 } {{{b f} {d e}} {{b f} {d e}}}
 
-test lset-11.4 {lset, not compiled, 2-d basics} {
+test lset-11.4 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a {0 1} f]] $a
+    list [testevalex {lset a {0 1} f}] $a
 } {{{b f} {d e}} {{b f} {d e}}}
 
-test lset-11.5 {lset, not compiled, 2-d basics} {
+test lset-11.5 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a 1 0 f]] $a
+    list [testevalex {lset a 1 0 f}] $a
 } {{{b c} {f e}} {{b c} {f e}}}
 
-test lset-11.6 {lset, not compiled, 2-d basics} {
+test lset-11.6 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a {1 0} f]] $a
+    list [testevalex {lset a {1 0} f}] $a
 } {{{b c} {f e}} {{b c} {f e}}}
 
-test lset-11.7 {lset, not compiled, 2-d basics} {
+test lset-11.7 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a 1 1 f]] $a
+    list [testevalex {lset a 1 1 f}] $a
 } {{{b c} {d f}} {{b c} {d f}}}
 
-test lset-11.8 {lset, not compiled, 2-d basics} {
+test lset-11.8 {lset, not compiled, 2-d basics} testevalex {
     set a {{b c} {d e}}
-    list [eval [list $lset a {1 1} f]] $a
+    list [testevalex {lset a {1 1} f}] $a
 } {{{b c} {d f}} {{b c} {d f}}}
 
-test lset-12.0 {lset, not compiled, typical sharing pattern} {
+test lset-12.0 {lset, not compiled, typical sharing pattern} testevalex {
     set zero 0
     set row [list $zero $zero $zero $zero]
     set ident [list $row $row $row $row]
     for { set i 0 } { $i < 4 } { incr i } {
-	eval [list $lset ident $i $i 1]
+	testevalex {lset ident $i $i 1}
     }
     set ident
 } {{1 0 0 0} {0 1 0 0} {0 0 1 0} {0 0 0 1}}
 
-test lset-13.0 {lset, not compiled, shimmering hell} {
+test lset-13.0 {lset, not compiled, shimmering hell} testevalex {
     set a 0
-    list [eval [list $lset a $a $a $a $a {gag me}]] $a
+    list [testevalex {lset a $a $a $a $a {gag me}}] $a
 } {{{{{{gag me}}}}} {{{{{gag me}}}}}}
 
-test lset-13.1 {lset, not compiled, shimmering hell} {
+test lset-13.1 {lset, not compiled, shimmering hell} testevalex {
     set a [list 0]
-    list [eval [list $lset a $a $a $a $a {gag me}]] $a
+    list [testevalex {lset a $a $a $a $a {gag me}}] $a
 } {{{{{{gag me}}}}} {{{{{gag me}}}}}}
 
-test lset-13.2 {lset, not compiled, shimmering hell} {
+test lset-13.2 {lset, not compiled, shimmering hell} testevalex {
     set a [list 0 0 0 0]
-    list [eval [list $lset a $a {gag me}]] $a
+    list [testevalex {lset a $a {gag me}}] $a
 } {{{{{{gag me}}}} 0 0 0} {{{{{gag me}}}} 0 0 0}}
 
-test lset-14.1 {lset, not compiled, list args, is string rep preserved?} {
+test lset-14.1 {lset, not compiled, list args, is string rep preserved?} testevalex {
     set a { { 1 2 } { 3 4 } }
-    catch { eval [list $lset a {1 5} 5] }
+    catch { testevalex {lset a {1 5} 5} }
     list $a [lindex $a 1]
 } "{ { 1 2 } { 3 4 } } { 3 4 }"
 
-test lset-14.2 {lset, not compiled, flat args, is string rep preserved?} {
+test lset-14.2 {lset, not compiled, flat args, is string rep preserved?} testevalex {
     set a { { 1 2 } { 3 4 } }
-    catch { eval [list $lset a 1 5 5] }
+    catch { testevalex {lset a 1 5 5} }
     list $a [lindex $a 1]
 } "{ { 1 2 } { 3 4 } } { 3 4 }"
 
Index: tests/namespace-old.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/namespace-old.test,v
retrieving revision 1.6
diff -u -r1.6 namespace-old.test
--- tests/namespace-old.test	7 Apr 2001 02:11:19 -0000	1.6
+++ tests/namespace-old.test	28 Oct 2003 21:37:05 -0000
@@ -22,7 +22,7 @@
 }
 
 # Clear out any namespaces called test_ns_*
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 
 test namespace-old-1.1 {usage for "namespace" command} {
     list [catch {namespace} msg] $msg
@@ -251,8 +251,8 @@
 test namespace-old-4.4 {command "namespace delete" handles multiple args} {
     set cmd {
         namespace eval test_ns_delete {
-            eval namespace delete \
-                [namespace children [namespace current] ns?]
+            namespace delete \
+                {expand}[namespace children [namespace current] ns?]
         }
     }
     list [catch $cmd msg] $msg [namespace children test_ns_delete]
Index: tests/namespace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/namespace.test,v
retrieving revision 1.22
diff -u -r1.22 namespace.test
--- tests/namespace.test	29 Sep 2003 14:37:14 -0000	1.22
+++ tests/namespace.test	28 Oct 2003 21:37:06 -0000
@@ -19,7 +19,7 @@
 }
 
 # Clear out any namespaces called test_ns_*
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 
 test namespace-1.1 {TclInitNamespaces, GetNamespaceFromObj, NamespaceChildrenCmd} {
     namespace children :: test_ns_*
@@ -79,7 +79,7 @@
 } {123}
 
 test namespace-6.1 {Tcl_CreateNamespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [lsort [namespace children :: test_ns_*]] \
         [namespace eval test_ns_1 {namespace current}] \
 	[namespace eval test_ns_2 {namespace current}] \
@@ -98,7 +98,7 @@
     list [catch {namespace eval test_ns_7::: {namespace current}} msg] $msg 
 } {0 ::test_ns_7}
 test namespace-6.4 {Tcl_CreateNamespace, trailing ::s in ns name are ignored} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1:: {
         namespace eval test_ns_2:: {}
         namespace eval test_ns_3:: {}
@@ -116,7 +116,7 @@
 } {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_2}
 
 test namespace-7.1 {Tcl_DeleteNamespace, active call frames in ns} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         proc p {} {
             namespace delete [namespace current]
@@ -161,7 +161,7 @@
          [interp delete test_interp]
 } {{::test_ns_1 27} {} 1 {invalid command name "set"} {}}
 test namespace-8.2 {TclTeardownNamespace, remove deleted ns from parent} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::test_ns_2::test_ns_3a {proc p {} {}}
     namespace eval test_ns_1::test_ns_2::test_ns_3b {proc q {} {}}
     list [namespace children test_ns_1] \
@@ -169,7 +169,7 @@
          [namespace children test_ns_1]
 } {::test_ns_1::test_ns_2 {} {}}
 test namespace-8.3 {TclTeardownNamespace, delete child namespaces} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::test_ns_2::test_ns_3a {proc p {} {}}
     namespace eval test_ns_1::test_ns_2::test_ns_3b {proc q {} {}}
     list [namespace children test_ns_1] \
@@ -179,7 +179,7 @@
          [info commands test_ns_1::test_ns_2::test_ns_3a::*]
 } {::test_ns_1::test_ns_2 {} {} 1 {unknown namespace "test_ns_1::test_ns_2" in namespace children command} {}}
 test namespace-8.4 {TclTeardownNamespace, cmds imported from deleted ns go away} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_export {
         namespace export cmd1 cmd2
         proc cmd1 {args} {return "cmd1: $args"}
@@ -195,7 +195,7 @@
 } [list [lsort {::test_ns_import::p ::test_ns_import::cmd1 ::test_ns_import::cmd2}] {} ::test_ns_import::p]
 
 test namespace-9.1 {Tcl_Import, empty import pattern} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace eval test_ns_import {namespace import {}}} msg] $msg
 } {1 {empty import pattern}}
 test namespace-9.2 {Tcl_Import, unknown namespace in import pattern} {
@@ -205,7 +205,7 @@
     list [catch {namespace eval test_ns_import {namespace import ::test_ns_import::puts}} msg] $msg
 } {1 {import pattern "::test_ns_import::puts" tries to import from namespace "test_ns_import" into itself}}
 test namespace-9.4 {Tcl_Import, simple import} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_export {
         namespace export cmd1
         proc cmd1 {args} {return "cmd1: $args"}
@@ -227,7 +227,7 @@
     }
 } {cmd1: 555}
 test namespace-9.7 {Tcl_Import, links are preserved if cmd is redefined} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_export {
         namespace export cmd1
         proc cmd1 {args} {return "cmd1: $args"}
@@ -245,7 +245,7 @@
 } {{cmd1: a b c} {cmd1: d e f} {} ::test_ns_export::cmd1 ::test_ns_export::cmd1 {new1: g h i} {new1: j k l}}
 
 test namespace-10.1 {Tcl_ForgetImport, check for valid namespaces} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace forget xyzzy::*} msg] $msg
 } {1 {unknown namespace in namespace forget pattern "xyzzy::*"}}
 test namespace-10.2 {Tcl_ForgetImport, ignores patterns that don't match} {
@@ -271,7 +271,7 @@
 } [list [lsort {::test_ns_import::p ::test_ns_import::cmd1}] ::test_ns_import::p 1 {invalid command name "cmd1"}]
 
 test namespace-11.1 {TclGetOriginalCommand, check if not imported cmd} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_export {
         namespace export cmd1
         proc cmd1 {args} {return "cmd1: $args"}
@@ -295,7 +295,7 @@
 } {{cmd1: 123} ::test_ns_export::cmd1}
 
 test namespace-12.1 {InvokeImportedCmd} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_export {
         namespace export cmd1
         proc cmd1 {args} {namespace current}
@@ -316,7 +316,7 @@
 } {::test_ns_import::cmd1 {}}
 
 test namespace-14.1 {TclGetNamespaceForQualName, absolute names} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     variable v 10
     namespace eval test_ns_1::test_ns_2 {
         variable v 20
@@ -394,7 +394,7 @@
     lappend l [test_ns_1::test_ns_2:: hello]
 } {1 {invalid command name "test_ns_1::test_ns_2::"} {{}: hello}}
 test namespace-14.12 {TclGetNamespaceForQualName, extra ::s are significant for vars} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         variable {}
         set test_ns_1::(x) y
@@ -402,12 +402,12 @@
     set test_ns_1::(x)
 } y
 test namespace-14.13 {TclGetNamespaceForQualName, namespace other than global ns can't have empty name} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace eval test_ns_1 {proc {} {} {}; namespace eval {} {}; {}}} msg] $msg
 } {1 {can't create namespace "": only global namespace can have empty name}}
 
 test namespace-15.1 {Tcl_FindNamespace, absolute name found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_delete {
         namespace eval test_ns_delete2 {}
         proc cmd {args} {namespace current}
@@ -434,7 +434,7 @@
 } {1 {unknown namespace "test_ns_delete2" in namespace delete command}}
 
 test namespace-16.1 {Tcl_FindCommand, absolute name found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         proc cmd {args} {return "[namespace current]::cmd: $args"}
         variable v "::test_ns_1::cmd"
@@ -502,7 +502,7 @@
 
 catch {unset x}
 test namespace-17.1 {Tcl_FindNamespaceVar, absolute name found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     set x 314159
     namespace eval test_ns_1 {
         set ::x
@@ -565,7 +565,7 @@
 catch {unset l}
 catch {rename foo {}}
 test namespace-18.1 {TclResetShadowedCmdRefs, one-level check for command shadowing} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     proc foo {} {return "global foo"}
     namespace eval test_ns_1 {
         proc trigger {} {
@@ -606,7 +606,7 @@
 catch {rename foo {}}
 
 test namespace-19.1 {GetNamespaceFromObj, global name found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::test_ns_2 {}
     namespace children ::test_ns_1
 } {::test_ns_1::test_ns_2}
@@ -636,7 +636,7 @@
 } {{} ::test_ns_1::test_ns_2::test_ns_3}
 
 test namespace-20.1 {Tcl_NamespaceObjCmd, bad subcommand} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace} msg] $msg
 } {1 {wrong # args: should be "namespace subcommand ?arg ...?"}}
 test namespace-20.2 {Tcl_NamespaceObjCmd, bad subcommand} {
@@ -647,7 +647,7 @@
 } {}
 
 test namespace-21.1 {NamespaceChildrenCmd, no args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::test_ns_2 {}
     expr {[string first ::test_ns_1 [namespace children]] != -1}
 } {1}
@@ -679,7 +679,7 @@
 } [lsort {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_foo}]
 
 test namespace-22.1 {NamespaceCodeCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace code} msg] $msg \
          [catch {namespace code xxx yyy} msg] $msg
 } {1 {wrong # args: should be "namespace code arg"} 1 {wrong # args: should be "namespace code arg"}}
@@ -713,7 +713,7 @@
 } {42} 
 
 test namespace-23.1 {NamespaceCurrentCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace current xxx} msg] $msg \
          [catch {namespace current xxx yyy} msg] $msg
 } {1 {wrong # args: should be "namespace current"} 1 {wrong # args: should be "namespace current"}}
@@ -727,7 +727,7 @@
 } {::test_ns_1::test_ns_2}
 
 test namespace-24.1 {NamespaceDeleteCmd, no args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace delete
 } {}
 test namespace-24.2 {NamespaceDeleteCmd, one arg} {
@@ -743,7 +743,7 @@
 } {1 {unknown namespace "::test_ns_foo" in namespace delete command}}
 
 test namespace-25.1 {NamespaceEvalCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace eval} msg] $msg
 } {1 {wrong # args: should be "namespace eval name arg ?arg...?"}}
 test namespace-25.2 {NamespaceEvalCmd, bad args} {
@@ -781,7 +781,7 @@
 catch {unset v}
 
 test namespace-26.1 {NamespaceExportCmd, no args and new ns} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace export
 } {}
 test namespace-26.2 {NamespaceExportCmd, just -clear arg} {
@@ -830,7 +830,7 @@
 } [list [lsort {::test_ns_2::cmd4 ::test_ns_2::cmd1 ::test_ns_2::cmd3}] {cmd4: hello}]
 
 test namespace-27.1 {NamespaceForgetCmd, no args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace forget
 } {}
 test namespace-27.2 {NamespaceForgetCmd, args must be valid namespaces} {
@@ -850,7 +850,7 @@
 } {::test_ns_2::cmd2}
 
 test namespace-28.1 {NamespaceImportCmd, no args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace import
 } {}
 test namespace-28.2 {NamespaceImportCmd, no args and just "-force"} {
@@ -870,7 +870,7 @@
 } {::test_ns_2::cmd2}
 
 test namespace-29.1 {NamespaceInscopeCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace inscope} msg] $msg
 } {1 {wrong # args: should be "namespace inscope name arg ?arg...?"}}
 test namespace-29.2 {NamespaceInscopeCmd, bad args} {
@@ -895,7 +895,7 @@
 } {{::test_ns_1::cmd: v=747, args=x y z} {::test_ns_1::cmd: v=747, args=x y z}}
 
 test namespace-30.1 {NamespaceOriginCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace origin} msg] $msg
 } {1 {wrong # args: should be "namespace origin name"}}
 test namespace-30.2 {NamespaceOriginCmd, bad args} {
@@ -928,7 +928,7 @@
 } {::foreach ::test_ns_2::p ::test_ns_1::cmd1 ::test_ns_1::cmd2}
 
 test namespace-31.1 {NamespaceParentCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace parent a b} msg] $msg
 } {1 {wrong # args: should be "namespace parent ?name?"}}
 test namespace-31.2 {NamespaceParentCmd, no args} {
@@ -949,7 +949,7 @@
 } {1 {unknown namespace "test_ns_1::test_ns_foo" in namespace parent command}}
 
 test namespace-32.1 {NamespaceQualifiersCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace qualifiers} msg] $msg
 } {1 {wrong # args: should be "namespace qualifiers string"}}
 test namespace-32.2 {NamespaceQualifiersCmd, bad args} {
@@ -975,7 +975,7 @@
 } {foo}
 
 test namespace-33.1 {NamespaceTailCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace tail} msg] $msg
 } {1 {wrong # args: should be "namespace tail string"}}
 test namespace-33.2 {NamespaceTailCmd, bad args} {
@@ -1001,7 +1001,7 @@
 } {}
 
 test namespace-34.1 {NamespaceWhichCmd, bad args} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {namespace which} msg] $msg
 } {1 {wrong # args: should be "namespace which ?-command? ?-variable? name"}}
 test namespace-34.2 {NamespaceWhichCmd, bad args} {
@@ -1054,7 +1054,7 @@
 } {::env ::test_ns_3::v3 ::test_ns_2::v2 0 {}}
 
 test namespace-35.1 {FreeNsNameInternalRep, resulting ref count > 0} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         proc p {} {
             namespace delete [namespace current]
@@ -1077,7 +1077,7 @@
 catch {unset x}
 catch {unset y}
 test namespace-36.1 {DupNsNameInternalRep} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {}
     set x "::test_ns_1"
     list [namespace parent $x] [set y $x] [namespace parent $y]
@@ -1086,7 +1086,7 @@
 catch {unset y}
 
 test namespace-37.1 {SetNsNameFromAny, ns name found} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::test_ns_2 {}
     namespace eval test_ns_1 {
         namespace children ::test_ns_1
@@ -1099,14 +1099,14 @@
 } {1 {unknown namespace "::test_ns_1::test_ns_foo" in namespace children command}}
 
 test namespace-38.1 {UpdateStringOfNsName} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     ;# Tcl_NamespaceObjCmd calls UpdateStringOfNsName to get subcmd name
     list [namespace eval {} {namespace current}] \
          [namespace eval {} {namespace current}]
 } {:: ::}
 
 test namespace-39.1 {NamespaceExistsCmd} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval ::test_ns_z::test_me { variable foo }
     list [namespace exists ::] \
 	    [namespace exists ::bogus_namespace] \
@@ -1309,10 +1309,9 @@
 	namespace ensemble create -subcommands {b c}
     }
 }
-test namespace-43.3 {ensembles: list-driven} {
-    eval $SETUP
+test namespace-43.3 {ensembles: list-driven} -setup $SETUP -body {
     namespace delete ns
-} {}
+} -result {}
 test namespace-43.4 {ensembles: list-driven} -setup $SETUP -body {
     ns a foo bar boo spong wibble
 } -cleanup {namespace delete ns} -returnCodes error -result {unknown or ambiguous subcommand "a": must be b, or c}
@@ -1335,10 +1334,9 @@
 	namespace ensemble create -subcommands {b c} -map {c ::ns::d}
     }
 }
-test namespace-43.8 {ensembles: list-and-map-driven} {
-    eval $SETUP
+test namespace-43.8 {ensembles: list-and-map-driven} -setup $SETUP -body {
     namespace delete ns
-} {}
+} -result {}
 test namespace-43.9 {ensembles: list-and-map-driven} -setup $SETUP -body {
     ns a foo bar boo spong wibble
 } -cleanup {namespace delete ns} -returnCodes error -result {unknown or ambiguous subcommand "a": must be b, or c}
@@ -1359,10 +1357,9 @@
 	namespace ensemble create -prefixes off
     }
 }
-test namespace-43.13 {ensembles: turn off prefixes} {
-    eval $SETUP
+test namespace-43.13 {ensembles: turn off prefixes} -setup $SETUP -body {
     namespace delete ns
-} {}
+} -result {}
 test namespace-43.14 {ensembles: turn off prefixes} -setup $SETUP -body {
     ns fo
 } -cleanup {namespace delete ns} -returnCodes error -result {unknown subcommand "fo": must be foo, or spong}
@@ -1636,6 +1633,6 @@
 catch {unset l}
 catch {unset msg}
 catch {unset trigger}
-eval namespace delete [namespace children :: test_ns_*]
+namespace delete {expand}[namespace children :: test_ns_*]
 ::tcltest::cleanupTests
 return
Index: tests/parse.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/parse.test,v
retrieving revision 1.16
diff -u -r1.16 parse.test
--- tests/parse.test	24 Jul 2003 16:05:24 -0000	1.16
+++ tests/parse.test	28 Oct 2003 21:37:07 -0000
@@ -10,139 +10,146 @@
 #
 # RCS: @(#) $Id: parse.test,v 1.16 2003/07/24 16:05:24 dgp Exp $
 
-if {[lsearch [namespace children] ::tcltest] == -1} {
-    package require tcltest
-    namespace import -force ::tcltest::*
+if {[catch {package require tcltest 2.0.2}]} {
+    puts stderr "Skipping tests in [info script]. tcltest 2.0.2 required."
+    return
 }
 
-if {[info commands testparser] == {}} {
-    puts "This application hasn't been compiled with the \"testparser\""
-    puts "command, so I can't test the Tcl parser."
-    ::tcltest::cleanupTests
-    return 
-}
+namespace eval ::tcl::test::parse {
+    namespace import ::tcltest::test
+    namespace import ::tcltest::testConstraint
+    namespace import ::tcltest::cleanupTests
+    namespace import ::tcltest::bytestring
+
+    testConstraint testparser [llength [info commands testparser]]
+    testConstraint testevalobjv [llength [info commands testevalobjv]]
+    testConstraint testevalex [llength [info commands testevalex]]
+    testConstraint testparsevarname [llength [info commands testparsevarname]]
+    testConstraint testparsevar [llength [info commands testparsevar]]
+    testConstraint testasync [llength [info commands testasync]]
+    testConstraint testcmdtrace [llength [info commands testcmdtrace]]
 
-test parse-1.1 {Tcl_ParseCommand procedure, computing string length} {
+test parse-1.1 {Tcl_ParseCommand procedure, computing string length} testparser {
     testparser [bytestring "foo\0 bar"] -1
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.2 {Tcl_ParseCommand procedure, computing string length} {
+test parse-1.2 {Tcl_ParseCommand procedure, computing string length} testparser {
     testparser "foo bar" -1
 } {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-1.3 {Tcl_ParseCommand procedure, leading space} {
+test parse-1.3 {Tcl_ParseCommand procedure, leading space} testparser {
     testparser "  \n\t   foo" 0
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.4 {Tcl_ParseCommand procedure, leading space} {
+test parse-1.4 {Tcl_ParseCommand procedure, leading space} testparser {
     testparser "\f\r\vfoo" 0
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.5 {Tcl_ParseCommand procedure, backslash-newline in leading space} {
+test parse-1.5 {Tcl_ParseCommand procedure, backslash-newline in leading space} testparser {
     testparser "  \\\n foo" 0
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-1.6 {Tcl_ParseCommand procedure, backslash-newline in leading space} {
+test parse-1.6 {Tcl_ParseCommand procedure, backslash-newline in leading space} testparser {
     testparser {  \a foo} 0
 } {- {\a foo} 2 word {\a} 1 backslash {\a} 0 simple foo 1 text foo 0 {}}
-test parse-1.7 {Tcl_ParseCommand procedure, missing continuation line in leading space} {
+test parse-1.7 {Tcl_ParseCommand procedure, missing continuation line in leading space} testparser {
     testparser "   \\\n" 0
 } {- {} 0 {}}
-test parse-1.8 {Tcl_ParseCommand procedure, eof in leading space} {
+test parse-1.8 {Tcl_ParseCommand procedure, eof in leading space} testparser {
     testparser "      foo" 3
 } {- {} 0 {   foo}}
 
-test parse-2.1 {Tcl_ParseCommand procedure, comments} {
+test parse-2.1 {Tcl_ParseCommand procedure, comments} testparser {
     testparser "# foo bar\n foo" 0
 } {{# foo bar
 } foo 1 simple foo 1 text foo 0 {}}
-test parse-2.2 {Tcl_ParseCommand procedure, several comments} {
+test parse-2.2 {Tcl_ParseCommand procedure, several comments} testparser {
     testparser " # foo bar\n # another comment\n\n   foo" 0
 } {{# foo bar
  # another comment
 } foo 1 simple foo 1 text foo 0 {}}
-test parse-2.3 {Tcl_ParseCommand procedure, backslash-newline in comments} {
+test parse-2.3 {Tcl_ParseCommand procedure, backslash-newline in comments} testparser {
     testparser " # foo bar\\\ncomment on continuation line\nfoo" 0
 } {\#\ foo\ bar\\\ncomment\ on\ continuation\ line\n foo 1 simple foo 1 text foo 0 {}}
-test parse-2.4 {Tcl_ParseCommand procedure, missing continuation line in comment} {
+test parse-2.4 {Tcl_ParseCommand procedure, missing continuation line in comment} testparser {
     testparser "#   \\\n" 0
 } {\#\ \ \ \\\n {} 0 {}}
-test parse-2.5 {Tcl_ParseCommand procedure, eof in comment} {
+test parse-2.5 {Tcl_ParseCommand procedure, eof in comment} testparser {
     testparser " # foo bar\nfoo" 8
 } {{# foo b} {} 0 {ar
 foo}}
 
-test parse-3.1 {Tcl_ParseCommand procedure, parsing words, skipping space} {
+test parse-3.1 {Tcl_ParseCommand procedure, parsing words, skipping space} testparser {
     testparser "foo  bar\t\tx" 0
 } {- {foo  bar		x} 3 simple foo 1 text foo 0 simple bar 1 text bar 0 simple x 1 text x 0 {}}
-test parse-3.2 {Tcl_ParseCommand procedure, missing continuation line in leading space} {
+test parse-3.2 {Tcl_ParseCommand procedure, missing continuation line in leading space} testparser {
     testparser "abc  \\\n" 0
 } {- abc\ \ \\\n 1 simple abc 1 text abc 0 {}}
-test parse-3.3 {Tcl_ParseCommand procedure, parsing words, command ends in space} {
+test parse-3.3 {Tcl_ParseCommand procedure, parsing words, command ends in space} testparser {
     testparser "foo  ;  bar x" 0
 } {- {foo  ;} 1 simple foo 1 text foo 0 {  bar x}}
-test parse-3.4 {Tcl_ParseCommand procedure, parsing words, command ends in space} {
+test parse-3.4 {Tcl_ParseCommand procedure, parsing words, command ends in space} testparser {
     testparser "foo       " 5
 } {- {foo  } 1 simple foo 1 text foo 0 {     }}
-test parse-3.5 {Tcl_ParseCommand procedure, quoted words} {
+test parse-3.5 {Tcl_ParseCommand procedure, quoted words} testparser {
     testparser {foo "a b c" d "efg";} 0
 } {- {foo "a b c" d "efg";} 4 simple foo 1 text foo 0 simple {"a b c"} 1 text {a b c} 0 simple d 1 text d 0 simple {"efg"} 1 text efg 0 {}}
-test parse-3.6 {Tcl_ParseCommand procedure, words in braces} {
+test parse-3.6 {Tcl_ParseCommand procedure, words in braces} testparser {
     testparser {foo {a $b [concat foo]} {c d}} 0
 } {- {foo {a $b [concat foo]} {c d}} 3 simple foo 1 text foo 0 simple {{a $b [concat foo]}} 1 text {a $b [concat foo]} 0 simple {{c d}} 1 text {c d} 0 {}}
-test parse-3.7 {Tcl_ParseCommand procedure, error in unquoted word} {
+test parse-3.7 {Tcl_ParseCommand procedure, error in unquoted word} testparser {
     list [catch {testparser "foo \$\{abc" 0} msg] $msg $errorInfo
 } {1 {missing close-brace for variable name} missing\ close-brace\ for\ variable\ name\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"foo\ \\\$\\\{abc\"\ 0\"}
 
-test parse-4.1 {Tcl_ParseCommand procedure, simple words} {
+test parse-4.1 {Tcl_ParseCommand procedure, simple words} testparser {
     testparser {foo} 0
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-4.2 {Tcl_ParseCommand procedure, simple words} {
+test parse-4.2 {Tcl_ParseCommand procedure, simple words} testparser {
     testparser {{abc}} 0
 } {- {{abc}} 1 simple {{abc}} 1 text abc 0 {}}
-test parse-4.3 {Tcl_ParseCommand procedure, simple words} {
+test parse-4.3 {Tcl_ParseCommand procedure, simple words} testparser {
     testparser {"c d"} 0
 } {- {"c d"} 1 simple {"c d"} 1 text {c d} 0 {}}
-test parse-4.4 {Tcl_ParseCommand procedure, simple words} {
+test parse-4.4 {Tcl_ParseCommand procedure, simple words} testparser {
     testparser {x$d} 0
 } {- {x$d} 1 word {x$d} 3 text x 0 variable {$d} 1 text d 0 {}}
-test parse-4.5 {Tcl_ParseCommand procedure, simple words} {
+test parse-4.5 {Tcl_ParseCommand procedure, simple words} testparser {
     testparser {"a [foo] b"} 0
 } {- {"a [foo] b"} 1 word {"a [foo] b"} 3 text {a } 0 command {[foo]} 0 text { b} 0 {}}
-test parse-4.6 {Tcl_ParseCommand procedure, simple words} {
+test parse-4.6 {Tcl_ParseCommand procedure, simple words} testparser {
     testparser {$x} 0
 } {- {$x} 1 word {$x} 2 variable {$x} 1 text x 0 {}}
 
-test parse-5.1 {Tcl_ParseCommand procedure, backslash-newline terminates word} {
+test parse-5.1 {Tcl_ParseCommand procedure, backslash-newline terminates word} testparser {
     testparser "{abc}\\\n" 0
 } {- \{abc\}\\\n 1 simple {{abc}} 1 text abc 0 {}}
-test parse-5.2 {Tcl_ParseCommand procedure, backslash-newline terminates word} {
+test parse-5.2 {Tcl_ParseCommand procedure, backslash-newline terminates word} testparser {
     testparser "foo\\\nbar" 0
 } {- foo\\\nbar 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-5.3 {Tcl_ParseCommand procedure, word terminator is command terminator} {
+test parse-5.3 {Tcl_ParseCommand procedure, word terminator is command terminator} testparser {
     testparser "foo\n bar" 0
 } {- {foo
 } 1 simple foo 1 text foo 0 { bar}}
-test parse-5.4 {Tcl_ParseCommand procedure, word terminator is command terminator} {
+test parse-5.4 {Tcl_ParseCommand procedure, word terminator is command terminator} testparser {
     testparser "foo; bar" 0
 } {- {foo;} 1 simple foo 1 text foo 0 { bar}}
-test parse-5.5 {Tcl_ParseCommand procedure, word terminator is end of string} {
+test parse-5.5 {Tcl_ParseCommand procedure, word terminator is end of string} testparser {
     testparser "\"foo\" bar" 5
 } {- {"foo"} 1 simple {"foo"} 1 text foo 0 { bar}}
-test parse-5.6 {Tcl_ParseCommand procedure, junk after close quote} {
+test parse-5.6 {Tcl_ParseCommand procedure, junk after close quote} testparser {
     list [catch {testparser {foo "bar"x} 0} msg] $msg $errorInfo
 } {1 {extra characters after close-quote} {extra characters after close-quote
     (remainder of script: "x")
     invoked from within
 "testparser {foo "bar"x} 0"}}
-test parse-5.7 {Tcl_ParseCommand procedure, backslash-newline after close quote} {
+test parse-5.7 {Tcl_ParseCommand procedure, backslash-newline after close quote} testparser {
     testparser "foo \"bar\"\\\nx" 0
 } {- foo\ \"bar\"\\\nx 3 simple foo 1 text foo 0 simple {"bar"} 1 text bar 0 simple x 1 text x 0 {}}
-test parse-5.8 {Tcl_ParseCommand procedure, junk after close brace} {
+test parse-5.8 {Tcl_ParseCommand procedure, junk after close brace} testparser {
     list [catch {testparser {foo {bar}x} 0} msg] $msg $errorInfo
 } {1 {extra characters after close-brace} {extra characters after close-brace
     (remainder of script: "x")
     invoked from within
 "testparser {foo {bar}x} 0"}}
-test parse-5.9 {Tcl_ParseCommand procedure, backslash-newline after close brace} {
+test parse-5.9 {Tcl_ParseCommand procedure, backslash-newline after close brace} testparser {
     testparser "foo {bar}\\\nx" 0
 } {- foo\ \{bar\}\\\nx 3 simple foo 1 text foo 0 simple {{bar}} 1 text bar 0 simple x 1 text x 0 {}}
-test parse-5.10 {Tcl_ParseCommand procedure, multiple deletion of non-static buffer} {
+test parse-5.10 {Tcl_ParseCommand procedure, multiple deletion of non-static buffer} testparser {
     # This test is designed to catch bug 1681.
     list [catch {testparser "a \"\\1\\2\\3\\4\\5\\6\\7\\8\\9\\1\\2\\3\\4\\5\\6\\7\\8" 0} msg] $msg $errorInfo
 } "1 {missing \"} {missing \"
@@ -150,25 +157,84 @@
     invoked from within
 \"testparser \"a \\\"\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\7\\\\8\\\\9\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\7\\\\8\" 0\"}"
 
-test parse-6.1 {ParseTokens procedure, empty word} {
+test parse-5.11 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{expan}} 0
+} {- {{expan}} 1 simple {{expan}} 1 text expan 0 {}}
+test parse-5.12 {Tcl_ParseCommand: {expand} parsing} -constraints {
+    testparser
+} -body {
+    testparser {{expan}x} 0
+} -returnCodes error  -result {extra characters after close-brace}
+test parse-5.13 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{expandy}} 0
+} {- {{expandy}} 1 simple {{expandy}} 1 text expandy 0 {}}
+test parse-5.14 {Tcl_ParseCommand: {expand} parsing} -constraints {
+    testparser
+} -body {
+    testparser {{expandy}x} 0
+} -returnCodes error  -result {extra characters after close-brace}
+test parse-5.15 {Tcl_ParseCommand: {expand} parsing} -constraints {
+    testparser
+} -body {
+    testparser {{expand}{123456}x} 0
+} -returnCodes error  -result {extra characters after close-brace}
+test parse-5.16 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{123456\
+			}} 0
+} {- {{123456 }} 1 simple {{123456 }} 1 text {123456 } 0 {}}
+test parse-5.17 {Tcl_ParseCommand: {expand} parsing} -constraints {
+    testparser
+} -body {
+    testparser {{123456\
+			}x} 0
+} -returnCodes error  -result {extra characters after close-brace}
+test parse-5.18 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{expand\
+			}} 0
+} {- {{expand }} 1 simple {{expand }} 1 text {expand } 0 {}}
+test parse-5.19 {Tcl_ParseCommand: {expand} parsing} -constraints {
+    testparser
+} -body {
+    testparser {{expand\
+			}x} 0
+} -returnCodes error  -result {extra characters after close-brace}
+test parse-5.20 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{123456}} 0
+} {- {{123456}} 1 simple {{123456}} 1 text 123456 0 {}}
+test parse-5.21 {Tcl_ParseCommand: {expand} parsing} -constraints {
+    testparser
+} -body {
+    testparser {{123456}x} 0
+} -returnCodes error  -result {extra characters after close-brace}
+test parse-5.22 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{expand}} 0
+} {- {{expand}} 1 simple {{expand}} 1 text expand 0 {}}
+test parse-5.23 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{expand} } 0
+} {- {{expand} } 1 simple {{expand}} 1 text expand 0 {}}
+test parse-5.24 {Tcl_ParseCommand: {expand} parsing} testparser {
+    testparser {{expand}x} 0
+} {- {{expand}x} 1 expand {{expand}x} 1 text x 0 {}}
+
+test parse-6.1 {ParseTokens procedure, empty word} testparser {
     testparser {""} 0
 } {- {""} 1 simple {""} 1 text {} 0 {}}
-test parse-6.2 {ParseTokens procedure, simple range} {
+test parse-6.2 {ParseTokens procedure, simple range} testparser {
     testparser {"abc$x.e"} 0
 } {- {"abc$x.e"} 1 word {"abc$x.e"} 4 text abc 0 variable {$x} 1 text x 0 text .e 0 {}}
-test parse-6.3 {ParseTokens procedure, variable reference} {
+test parse-6.3 {ParseTokens procedure, variable reference} testparser {
     testparser {abc$x.e $y(z)} 0
 } {- {abc$x.e $y(z)} 2 word {abc$x.e} 4 text abc 0 variable {$x} 1 text x 0 text .e 0 word {$y(z)} 3 variable {$y(z)} 2 text y 0 text z 0 {}}
-test parse-6.4 {ParseTokens procedure, variable reference} {
+test parse-6.4 {ParseTokens procedure, variable reference} testparser {
     list [catch {testparser {$x([a )} 0} msg] $msg
 } {1 {missing close-bracket}}
-test parse-6.5 {ParseTokens procedure, command substitution} {
+test parse-6.5 {ParseTokens procedure, command substitution} testparser {
     testparser {[foo $x bar]z} 0
 } {- {[foo $x bar]z} 1 word {[foo $x bar]z} 2 command {[foo $x bar]} 0 text z 0 {}}
-test parse-6.6 {ParseTokens procedure, command substitution} {
+test parse-6.6 {ParseTokens procedure, command substitution} testparser {
     testparser {[foo \] [a b]]} 0
 } {- {[foo \] [a b]]} 1 word {[foo \] [a b]]} 1 command {[foo \] [a b]]} 0 {}}
-test parse-6.7 {ParseTokens procedure, error in command substitution} {
+test parse-6.7 {ParseTokens procedure, error in command substitution} testparser {
     list [catch {testparser {a [b {}c d] e} 0} msg] $msg $errorInfo
 } {1 {extra characters after close-brace} {extra characters after close-brace
     (remainder of script: "c d] e")
@@ -185,85 +251,94 @@
 	expr 1+1
 	#this is a comment ]}
 } {0}
-test parse-6.11 {ParseTokens procedure, memory allocation for big nested command} {
+test parse-6.11 {ParseTokens procedure, memory allocation for big nested command} testparser {
     testparser {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 0
 } {- {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 1 word {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 1 command {[$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b)]} 0 {}}
-test parse-6.12 {ParseTokens procedure, missing close bracket} {
+test parse-6.12 {ParseTokens procedure, missing close bracket} testparser {
     list [catch {testparser {[foo $x bar} 0} msg] $msg $errorInfo
 } {1 {missing close-bracket} {missing close-bracket
     (remainder of script: "[foo $x bar")
     invoked from within
 "testparser {[foo $x bar} 0"}}
-test parse-6.13 {ParseTokens procedure, backslash-newline without continuation line} {
+test parse-6.13 {ParseTokens procedure, backslash-newline without continuation line} testparser {
     list [catch {testparser "\"a b\\\n" 0} msg] $msg $errorInfo
 } {1 {missing "} missing\ \"\n\ \ \ \ (remainder\ of\ script:\ \"\"a\ b\\\n\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\\\"a\ b\\\\\\n\"\ 0\"}
-test parse-6.14 {ParseTokens procedure, backslash-newline} {
+test parse-6.14 {ParseTokens procedure, backslash-newline} testparser {
     testparser "b\\\nc" 0
 } {- b\\\nc 2 simple b 1 text b 0 simple c 1 text c 0 {}}
-test parse-6.15 {ParseTokens procedure, backslash-newline} {
+test parse-6.15 {ParseTokens procedure, backslash-newline} testparser {
     testparser "\"b\\\nc\"" 0
 } {- \"b\\\nc\" 1 word \"b\\\nc\" 3 text b 0 backslash \\\n 0 text c 0 {}}
-test parse-6.16 {ParseTokens procedure, backslash substitution} {
+test parse-6.16 {ParseTokens procedure, backslash substitution} testparser {
     testparser {\n\a\x7f} 0
 } {- {\n\a\x7f} 1 word {\n\a\x7f} 3 backslash {\n} 0 backslash {\a} 0 backslash {\x7f} 0 {}}
-test parse-6.17 {ParseTokens procedure, null characters} {
+test parse-6.17 {ParseTokens procedure, null characters} testparser {
     testparser [bytestring "foo\0zz"] 0
 } "- [bytestring foo\0zz] 1 word [bytestring foo\0zz] 3 text foo 0 text [bytestring \0] 0 text zz 0 {}"
-test parse-6.18 {ParseTokens procedure, seek past numBytes for close-bracket} {
+test parse-6.18 {ParseTokens procedure, seek past numBytes for close-bracket} testparser {
     # Test for Bug 681841
     list [catch {testparser {[a]} 2} msg] $msg
 } {1 {missing close-bracket}}
 
-test parse-7.1 {Tcl_FreeParse and ExpandTokenArray procedures} {
+test parse-7.1 {Tcl_FreeParse and ExpandTokenArray procedures} testparser {
     testparser {$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) } 0
 } {- {$a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) $a(b) } 16 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 word {$a(b)} 3 variable {$a(b)} 2 text a 0 text b 0 {}}
 
-test parse-8.1 {Tcl_EvalObjv procedure} {
+test parse-8.1 {Tcl_EvalObjv procedure} testevalobjv {
     testevalobjv 0 concat this is a test
 } {this is a test}
-test parse-8.2 {Tcl_EvalObjv procedure, unknown commands} {
-    rename unknown unknown.old
+test parse-8.2 {Tcl_EvalObjv procedure, unknown commands} testevalobjv {
+    rename ::unknown unknown.old
     set x [catch {testevalobjv 10 asdf poiu} msg]
-    rename unknown.old unknown
+    rename unknown.old ::unknown
     list $x $msg
 } {1 {invalid command name "asdf"}}
-test parse-8.3 {Tcl_EvalObjv procedure, unknown commands} {
-    rename unknown unknown.old
-    proc unknown args {
+test parse-8.3 {Tcl_EvalObjv procedure, unknown commands} testevalobjv {
+    rename ::unknown unknown.old
+    proc ::unknown args {
 	return "unknown $args"
     }
     set x [catch {testevalobjv 0 asdf poiu} msg]
-    rename unknown {}
-    rename unknown.old unknown
+    rename ::unknown {}
+    rename unknown.old ::unknown
     list $x $msg
 } {0 {unknown asdf poiu}}
-test parse-8.4 {Tcl_EvalObjv procedure, unknown commands} {
-    rename unknown unknown.old
-    proc unknown args {
+test parse-8.4 {Tcl_EvalObjv procedure, unknown commands} testevalobjv {
+    rename ::unknown unknown.old
+    proc ::unknown args {
 	error "I don't like that command"
     }
     set x [catch {testevalobjv 0 asdf poiu} msg]
-    rename unknown {}
-    rename unknown.old unknown
+    rename ::unknown {}
+    rename unknown.old ::unknown
     list $x $msg
 } {1 {I don't like that command}}
-test parse-8.5 {Tcl_EvalObjv procedure, command traces} {
+test parse-8.5 {Tcl_EvalObjv procedure, command traces} {testevalobjv testcmdtrace} {
     testevalobjv 0 set x 123
     testcmdtrace tracetest {testevalobjv 0 set x $x}
 } {{testevalobjv 0 set x $x} {testevalobjv 0 set x 123} {set x 123} {set x 123}}
-test parse-8.7 {Tcl_EvalObjv procedure, TCL_EVAL_GLOBAL flag} {
+test parse-8.7 {Tcl_EvalObjv procedure, TCL_EVAL_GLOBAL flag} -constraints {
+    testevalobjv
+} -setup {
     proc x {} {
 	set y 23
 	set z [testevalobjv 1 set y]
 	return [list $z $y]
     }
-    catch {unset y}
-    set y 16
+    set ::y 16
+} -cleanup {
+    unset ::y
+} -body {
     x
-} {16 23}
-test parse-8.8 {Tcl_EvalObjv procedure, async handlers} {
+} -result {16 23}
+test parse-8.8 {Tcl_EvalObjv procedure, async handlers} -constraints {
+    testevalobjv testasync
+} -setup {
+    variable ::aresult
+    variable ::acode
     proc async1 {result code} {
-	global aresult acode
+	variable ::aresult 
+	variable ::acode
 	set aresult $result
 	set acode $code
 	return "new result"
@@ -271,15 +346,16 @@
     set handler1 [testasync create async1]
     set aresult xxx
     set acode yyy
-    set x [list [catch [list testevalobjv 0 testasync mark $handler1 original 0] msg] $msg $acode $aresult]
+} -cleanup {
     testasync delete
-    set x
-} {0 {new result} 0 original}
-test parse-8.9 {Tcl_EvalObjv procedure, exceptional return} {
+} -body {
+    list [testevalobjv 0 testasync mark $handler1 original 0] $acode $aresult
+} -result {{new result} 0 original}
+test parse-8.9 {Tcl_EvalObjv procedure, exceptional return} testevalobjv {
     list [catch {testevalobjv 0 error message} msg] $msg
 } {1 message}
 
-test parse-9.1 {Tcl_LogCommandInfo, line numbers} {
+test parse-9.1 {Tcl_LogCommandInfo, line numbers} testevalex {
     catch {unset x}
     list [catch {testevalex {for {} 1 {} {
 
@@ -305,264 +381,268 @@
 	# asdf
 	set x
     }}"}}
-test parse-9.2 {Tcl_LogCommandInfo, truncating long commands} {
+test parse-9.2 {Tcl_LogCommandInfo, truncating long commands} testevalex {
     list [testevalex {catch {set a b 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 000000000 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd eeeeeeeee fffffffff ggggggggg}}] $errorInfo
 } {1 {wrong # args: should be "set varName ?newValue?"
     while executing
 "set a b 111111111 222222222 333333333 444444444 555555555 666666666 777777777 888888888 999999999 000000000 aaaaaaaaa bbbbbbbbb ccccccccc ddddddddd ee..."}}
 
-test parse-10.1 {Tcl_EvalTokens, simple text} {
+test parse-10.1 {Tcl_EvalTokens, simple text} testevalex {
     testevalex {concat test}
 } {test}
-test parse-10.2 {Tcl_EvalTokens, backslash sequences} {
+test parse-10.2 {Tcl_EvalTokens, backslash sequences} testevalex {
     testevalex {concat test\063\062test}
 } {test32test}
-test parse-10.3 {Tcl_EvalTokens, nested commands} {
+test parse-10.3 {Tcl_EvalTokens, nested commands} testevalex {
     testevalex {concat [expr 2 + 6]}
 } {8}
-test parse-10.4 {Tcl_EvalTokens, nested commands} {
+test parse-10.4 {Tcl_EvalTokens, nested commands} testevalex {
     catch {unset a}
     list [catch {testevalex {concat xxx[expr $a]}} msg] $msg
 } {1 {can't read "a": no such variable}}
-test parse-10.5 {Tcl_EvalTokens, simple variables} {
+test parse-10.5 {Tcl_EvalTokens, simple variables} testevalex {
     set a hello
     testevalex {concat $a}
 } {hello}
-test parse-10.6 {Tcl_EvalTokens, array variables} {
+test parse-10.6 {Tcl_EvalTokens, array variables} testevalex {
     catch {unset a}
     set a(12) 46
     testevalex {concat $a(12)}
 } {46}
-test parse-10.7 {Tcl_EvalTokens, array variables} {
+test parse-10.7 {Tcl_EvalTokens, array variables} testevalex {
     catch {unset a}
     set a(12) 46
     testevalex {concat $a(1[expr 3 - 1])}
 } {46}
-test parse-10.8 {Tcl_EvalTokens, array variables} {
+test parse-10.8 {Tcl_EvalTokens, array variables} testevalex {
     catch {unset a}
     list [catch {testevalex {concat $x($a)}} msg] $msg
 } {1 {can't read "a": no such variable}}
-test parse-10.9 {Tcl_EvalTokens, array variables} {
+test parse-10.9 {Tcl_EvalTokens, array variables} testevalex {
     catch {unset a}
     list [catch {testevalex {concat xyz$a(1)}} msg] $msg
 } {1 {can't read "a(1)": no such variable}}
-test parse-10.10 {Tcl_EvalTokens, object values} {
+test parse-10.10 {Tcl_EvalTokens, object values} testevalex {
     set a 123
     testevalex {concat $a}
 } {123}
-test parse-10.11 {Tcl_EvalTokens, object values} {
+test parse-10.11 {Tcl_EvalTokens, object values} testevalex {
     set a 123
     testevalex {concat $a$a$a}
 } {123123123}
-test parse-10.12 {Tcl_EvalTokens, object values} {
+test parse-10.12 {Tcl_EvalTokens, object values} testevalex {
     testevalex {concat [expr 2][expr 4][expr 6]}
 } {246}
-test parse-10.13 {Tcl_EvalTokens, string values} {
+test parse-10.13 {Tcl_EvalTokens, string values} testevalex {
     testevalex {concat {a" b"}}
 } {a" b"}
-test parse-10.14 {Tcl_EvalTokens, string values} {
+test parse-10.14 {Tcl_EvalTokens, string values} testevalex {
     set a 111
     testevalex {concat x$a.$a.$a}
 } {x111.111.111}
 
-test parse-11.1 {Tcl_EvalEx, TCL_EVAL_GLOBAL flag} {
+test parse-11.1 {Tcl_EvalEx, TCL_EVAL_GLOBAL flag} -constraints {
+    testevalex
+} -setup {
     proc x {} {
 	set y 777
 	set z [testevalex "set y" global]
 	return [list $z $y]
     }
-    catch {unset y}
-    set y 321
+    set ::y 321
+} -cleanup {
+    unset ::y
+} -body {
     x
-} {321 777}
-test parse-11.2 {Tcl_EvalEx, error while parsing} {
+} -result {321 777}
+test parse-11.2 {Tcl_EvalEx, error while parsing} testevalex {
     list [catch {testevalex {concat "abc}} msg] $msg
 } {1 {missing "}}
-test parse-11.3 {Tcl_EvalEx, error while collecting words} {
+test parse-11.3 {Tcl_EvalEx, error while collecting words} testevalex {
     catch {unset a}
     list [catch {testevalex {concat xyz $a}} msg] $msg
 } {1 {can't read "a": no such variable}}
-test parse-11.4 {Tcl_EvalEx, error in Tcl_EvalObjv call} {
+test parse-11.4 {Tcl_EvalEx, error in Tcl_EvalObjv call} testevalex {
     catch {unset a}
     list [catch {testevalex {_bogus_ a b c d}} msg] $msg
 } {1 {invalid command name "_bogus_"}}
-test parse-11.5 {Tcl_EvalEx, exceptional return} {
+test parse-11.5 {Tcl_EvalEx, exceptional return} testevalex {
     list [catch {testevalex {break}} msg] $msg
 } {3 {}}
-test parse-11.6 {Tcl_EvalEx, freeing memory} {
+test parse-11.6 {Tcl_EvalEx, freeing memory} testevalex {
     testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z}
 } {a b c d e f g h i j k l m n o p q r s t u v w x y z}
-test parse-11.7 {Tcl_EvalEx, multiple commands in script} {
+test parse-11.7 {Tcl_EvalEx, multiple commands in script} testevalex {
     list [testevalex {set a b; set c d}] $a $c
 } {d b d}
-test parse-11.8 {Tcl_EvalEx, multiple commands in script} {
+test parse-11.8 {Tcl_EvalEx, multiple commands in script} testevalex {
     list [testevalex {
 	set a b
 	set c d
     }] $a $c
 } {d b d}
-test parse-11.9 {Tcl_EvalEx, freeing memory after error} {
+test parse-11.9 {Tcl_EvalEx, freeing memory after error} testevalex {
     catch {unset a}
     list [catch {testevalex {concat a b c d e f g h i j k l m n o p q r s t u v w x y z $a}} msg] $msg
 } {1 {can't read "a": no such variable}}
-test parse-11.10 {Tcl_EvalTokens, empty commands} {
+test parse-11.10 {Tcl_EvalTokens, empty commands} testevalex {
     testevalex {concat xyz;   }
 } {xyz}
-test parse-11.11 {Tcl_EvalTokens, empty commands} {
+test parse-11.11 {Tcl_EvalTokens, empty commands} testevalex {
     testevalex "concat abc; ; # this is a comment\n"
 } {abc}
-test parse-11.12 {Tcl_EvalTokens, empty commands} {
+test parse-11.12 {Tcl_EvalTokens, empty commands} testevalex {
     testevalex {}
 } {}
 
-test parse-12.1 {Tcl_ParseVarName procedure, initialization} {
+test parse-12.1 {Tcl_ParseVarName procedure, initialization} testparsevarname {
     list [catch {testparsevarname {$a([first second])} 8 0} msg] $msg
 } {1 {missing close-bracket}}
-test parse-12.2 {Tcl_ParseVarName procedure, initialization} {
+test parse-12.2 {Tcl_ParseVarName procedure, initialization} testparsevarname {
     testparsevarname {$a([first second])} 0 0
 } {- {} 0 variable {$a([first second])} 2 text a 0 command {[first second]} 0 {}}
-test parse-12.3 {Tcl_ParseVarName procedure, initialization} {
+test parse-12.3 {Tcl_ParseVarName procedure, initialization} testparsevarname {
     list [catch {testparsevarname {$abcd} 3 0} msg] $msg
 } {0 {- {} 0 variable {$ab} 1 text ab 0 cd}}
-test parse-12.4 {Tcl_ParseVarName procedure, initialization} {
+test parse-12.4 {Tcl_ParseVarName procedure, initialization} testparsevarname {
     testparsevarname {$abcd} 0 0
 } {- {} 0 variable {$abcd} 1 text abcd 0 {}}
-test parse-12.5 {Tcl_ParseVarName procedure, just a dollar sign} {
+test parse-12.5 {Tcl_ParseVarName procedure, just a dollar sign} testparsevarname {
     testparsevarname {$abcd} 1 0
 } {- {} 0 text {$} 0 abcd}
-test parse-12.6 {Tcl_ParseVarName procedure, braced variable name} {
+test parse-12.6 {Tcl_ParseVarName procedure, braced variable name} testparser {
     testparser {${..[]b}cd} 0
 } {- {${..[]b}cd} 1 word {${..[]b}cd} 3 variable {${..[]b}} 1 text {..[]b} 0 text cd 0 {}}
-test parse-12.7 {Tcl_ParseVarName procedure, braced variable name} {
+test parse-12.7 {Tcl_ParseVarName procedure, braced variable name} testparser {
     testparser "\$\{\{\} " 0
 } {- \$\{\{\}\  1 word \$\{\{\} 2 variable \$\{\{\} 1 text \{ 0 {}}
-test parse-12.8 {Tcl_ParseVarName procedure, missing close brace} {
+test parse-12.8 {Tcl_ParseVarName procedure, missing close brace} testparser {
     list [catch {testparser "$\{abc" 0} msg] $msg $errorInfo
 } {1 {missing close-brace for variable name} missing\ close-brace\ for\ variable\ name\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\$\\\{abc\"\ 0\"}
-test parse-12.9 {Tcl_ParseVarName procedure, missing close brace} {
+test parse-12.9 {Tcl_ParseVarName procedure, missing close brace} testparsevarname {
     list [catch {testparsevarname {${bcd}} 4 0} msg] $msg
 } {1 {missing close-brace for variable name}}
-test parse-12.10 {Tcl_ParseVarName procedure, missing close brace} {
+test parse-12.10 {Tcl_ParseVarName procedure, missing close brace} testparsevarname {
     list [catch {testparsevarname {${bc}} 4 0} msg] $msg
 } {1 {missing close-brace for variable name}}
-test parse-12.11 {Tcl_ParseVarName procedure, simple variable name} {
+test parse-12.11 {Tcl_ParseVarName procedure, simple variable name} testparser {
     testparser {$az_AZ.} 0
 } {- {$az_AZ.} 1 word {$az_AZ.} 3 variable {$az_AZ} 1 text az_AZ 0 text . 0 {}}
-test parse-12.12 {Tcl_ParseVarName procedure, simple variable name} {
+test parse-12.12 {Tcl_ParseVarName procedure, simple variable name} testparser {
     testparser {$abcdefg} 4
 } {- {$abc} 1 word {$abc} 2 variable {$abc} 1 text abc 0 defg}
-test parse-12.13 {Tcl_ParseVarName procedure, simple variable name with ::} {
+test parse-12.13 {Tcl_ParseVarName procedure, simple variable name with ::} testparser {
     testparser {$xyz::ab:c} 0
 } {- {$xyz::ab:c} 1 word {$xyz::ab:c} 3 variable {$xyz::ab} 1 text xyz::ab 0 text :c 0 {}}
-test parse-12.14 {Tcl_ParseVarName procedure, variable names with many colons} {
+test parse-12.14 {Tcl_ParseVarName procedure, variable names with many colons} testparser {
     testparser {$xyz:::::c} 0
 } {- {$xyz:::::c} 1 word {$xyz:::::c} 2 variable {$xyz:::::c} 1 text xyz:::::c 0 {}}
-test parse-12.15 {Tcl_ParseVarName procedure, : vs. ::} {
+test parse-12.15 {Tcl_ParseVarName procedure, : vs. ::} testparsevarname {
     testparsevarname {$ab:cd} 0 0
 } {- {} 0 variable {$ab} 1 text ab 0 :cd}
-test parse-12.16 {Tcl_ParseVarName procedure, eof in ::} {
+test parse-12.16 {Tcl_ParseVarName procedure, eof in ::} testparsevarname {
     testparsevarname {$ab::cd} 4 0
 } {- {} 0 variable {$ab} 1 text ab 0 ::cd}
-test parse-12.17 {Tcl_ParseVarName procedure, eof in ::} {
+test parse-12.17 {Tcl_ParseVarName procedure, eof in ::} testparsevarname {
     testparsevarname {$ab:::cd} 5 0
 } {- {} 0 variable {$ab::} 1 text ab:: 0 :cd}
-test parse-12.18 {Tcl_ParseVarName procedure, no variable name} {
+test parse-12.18 {Tcl_ParseVarName procedure, no variable name} testparser {
     testparser {$$ $.} 0
 } {- {$$ $.} 2 word {$$} 2 text {$} 0 text {$} 0 word {$.} 2 text {$} 0 text . 0 {}}
-test parse-12.19 {Tcl_ParseVarName procedure, EOF before (} {
+test parse-12.19 {Tcl_ParseVarName procedure, EOF before (} testparsevarname {
     testparsevarname {$ab(cd)} 3 0
 } {- {} 0 variable {$ab} 1 text ab 0 (cd)}
-test parse-12.20 {Tcl_ParseVarName procedure, array reference} {
+test parse-12.20 {Tcl_ParseVarName procedure, array reference} testparser {
     testparser {$x(abc)} 0
 } {- {$x(abc)} 1 word {$x(abc)} 3 variable {$x(abc)} 2 text x 0 text abc 0 {}}
-test parse-12.21 {Tcl_ParseVarName procedure, array reference} {
+test parse-12.21 {Tcl_ParseVarName procedure, array reference} testparser {
     testparser {$x(ab$cde[foo bar])} 0
 } {- {$x(ab$cde[foo bar])} 1 word {$x(ab$cde[foo bar])} 6 variable {$x(ab$cde[foo bar])} 5 text x 0 text ab 0 variable {$cde} 1 text cde 0 command {[foo bar]} 0 {}}
-test parse-12.22 {Tcl_ParseVarName procedure, array reference} {
+test parse-12.22 {Tcl_ParseVarName procedure, array reference} testparser {
     testparser {$x([cmd arg]zz)} 0
 } {- {$x([cmd arg]zz)} 1 word {$x([cmd arg]zz)} 4 variable {$x([cmd arg]zz)} 3 text x 0 command {[cmd arg]} 0 text zz 0 {}}
-test parse-12.23 {Tcl_ParseVarName procedure, missing close paren in array reference} {
+test parse-12.23 {Tcl_ParseVarName procedure, missing close paren in array reference} testparser {
     list [catch {testparser {$x(poiu} 0} msg] $msg $errorInfo
 } {1 {missing )} {missing )
     (remainder of script: "(poiu")
     invoked from within
 "testparser {$x(poiu} 0"}}
-test parse-12.24 {Tcl_ParseVarName procedure, missing close paren in array reference} {
+test parse-12.24 {Tcl_ParseVarName procedure, missing close paren in array reference} testparsevarname {
     list [catch {testparsevarname {$ab(cd)} 6 0} msg] $msg $errorInfo
 } {1 {missing )} {missing )
     (remainder of script: "(cd)")
     invoked from within
 "testparsevarname {$ab(cd)} 6 0"}}
-test parse-12.25 {Tcl_ParseVarName procedure, nested array reference} {
+test parse-12.25 {Tcl_ParseVarName procedure, nested array reference} testparser {
     testparser {$x(a$y(b$z))} 0
 } {- {$x(a$y(b$z))} 1 word {$x(a$y(b$z))} 8 variable {$x(a$y(b$z))} 7 text x 0 text a 0 variable {$y(b$z)} 4 text y 0 text b 0 variable {$z} 1 text z 0 {}}
 
-test parse-13.1 {Tcl_ParseVar procedure} {
+test parse-13.1 {Tcl_ParseVar procedure} testparsevar {
     set abc 24
     testparsevar {$abc.fg}
 } {24 .fg}
-test parse-13.2 {Tcl_ParseVar procedure, no variable name} {
+test parse-13.2 {Tcl_ParseVar procedure, no variable name} testparsevar {
     testparsevar {$}
 } {{$} {}}
-test parse-13.3 {Tcl_ParseVar procedure, no variable name} {
+test parse-13.3 {Tcl_ParseVar procedure, no variable name} testparsevar {
     testparsevar {$.123}
 } {{$} .123}
-test parse-13.4 {Tcl_ParseVar procedure, error looking up variable} {
+test parse-13.4 {Tcl_ParseVar procedure, error looking up variable} testparsevar {
     catch {unset abc}
     list [catch {testparsevar {$abc}} msg] $msg
 } {1 {can't read "abc": no such variable}}
-test parse-13.5 {Tcl_ParseVar procedure, error looking up variable} {
+test parse-13.5 {Tcl_ParseVar procedure, error looking up variable} testparsevar {
     catch {unset abc}
     list [catch {testparsevar {$abc([bogus x y z])}} msg] $msg
 } {1 {invalid command name "bogus"}}
 
-test parse-14.1 {Tcl_ParseBraces procedure, computing string length} {
+test parse-14.1 {Tcl_ParseBraces procedure, computing string length} testparser {
     testparser [bytestring "foo\0 bar"] -1
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-14.2 {Tcl_ParseBraces procedure, computing string length} {
+test parse-14.2 {Tcl_ParseBraces procedure, computing string length} testparser {
     testparser "foo bar" -1
 } {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-14.3 {Tcl_ParseBraces procedure, words in braces} {
+test parse-14.3 {Tcl_ParseBraces procedure, words in braces} testparser {
     testparser {foo {a $b [concat foo]} {c d}} 0
 } {- {foo {a $b [concat foo]} {c d}} 3 simple foo 1 text foo 0 simple {{a $b [concat foo]}} 1 text {a $b [concat foo]} 0 simple {{c d}} 1 text {c d} 0 {}}
-test parse-14.4 {Tcl_ParseBraces procedure, empty nested braces} {
+test parse-14.4 {Tcl_ParseBraces procedure, empty nested braces} testparser {
     testparser {foo {{}}} 0
 } {- {foo {{}}} 2 simple foo 1 text foo 0 simple {{{}}} 1 text {{}} 0 {}}
-test parse-14.5 {Tcl_ParseBraces procedure, nested braces} {
+test parse-14.5 {Tcl_ParseBraces procedure, nested braces} testparser {
     testparser {foo {{a {b} c} {} {d e}}} 0
 } {- {foo {{a {b} c} {} {d e}}} 2 simple foo 1 text foo 0 simple {{{a {b} c} {} {d e}}} 1 text {{a {b} c} {} {d e}} 0 {}}
-test parse-14.6 {Tcl_ParseBraces procedure, backslashes in words in braces} {
+test parse-14.6 {Tcl_ParseBraces procedure, backslashes in words in braces} testparser {
     testparser "foo {a \\n\\\{}" 0
 } {- {foo {a \n\{}} 2 simple foo 1 text foo 0 simple {{a \n\{}} 1 text {a \n\{} 0 {}}
-test parse-14.7 {Tcl_ParseBraces procedure, missing continuation line in braces} {
+test parse-14.7 {Tcl_ParseBraces procedure, missing continuation line in braces} testparser {
     list [catch {testparser "\{abc\\\n" 0} msg] $msg $errorInfo
 } {1 {missing close-brace} missing\ close-brace\n\ \ \ \ (remainder\ of\ script:\ \"\{abc\\\n\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"\\\{abc\\\\\\n\"\ 0\"}
-test parse-14.8 {Tcl_ParseBraces procedure, backslash-newline in braces} {
+test parse-14.8 {Tcl_ParseBraces procedure, backslash-newline in braces} testparser {
     testparser "foo {\\\nx}" 0
 } {- foo\ \{\\\nx\} 2 simple foo 1 text foo 0 word \{\\\nx\} 2 backslash \\\n 0 text x 0 {}}
-test parse-14.9 {Tcl_ParseBraces procedure, backslash-newline in braces} {
+test parse-14.9 {Tcl_ParseBraces procedure, backslash-newline in braces} testparser {
     testparser "foo {a \\\n   b}" 0
 } {- foo\ \{a\ \\\n\ \ \ b\} 2 simple foo 1 text foo 0 word \{a\ \\\n\ \ \ b\} 3 text {a } 0 backslash \\\n\ \ \  0 text b 0 {}}
-test parse-14.10 {Tcl_ParseBraces procedure, backslash-newline in braces} {
+test parse-14.10 {Tcl_ParseBraces procedure, backslash-newline in braces} testparser {
     testparser "foo {xyz\\\n }" 0
 } {- foo\ \{xyz\\\n\ \} 2 simple foo 1 text foo 0 word \{xyz\\\n\ \} 2 text xyz 0 backslash \\\n\  0 {}}
-test parse-14.11 {Tcl_ParseBraces procedure, empty braced string} {
+test parse-14.11 {Tcl_ParseBraces procedure, empty braced string} testparser {
     testparser {foo {}} 0
 } {- {foo {}} 2 simple foo 1 text foo 0 simple {{}} 1 text {} 0 {}}
-test parse-14.12 {Tcl_ParseBraces procedure, missing close brace} {
+test parse-14.12 {Tcl_ParseBraces procedure, missing close brace} testparser {
     list [catch {testparser "foo \{xy\\\nz" 0} msg] $msg $errorInfo
 } {1 {missing close-brace} missing\ close-brace\n\ \ \ \ (remainder\ of\ script:\ \"\{xy\\\nz\")\n\ \ \ \ invoked\ from\ within\n\"testparser\ \"foo\ \\\{xy\\\\\\nz\"\ 0\"}
 
-test parse-15.1 {Tcl_ParseQuotedString procedure, computing string length} {
+test parse-15.1 {Tcl_ParseQuotedString procedure, computing string length} testparser {
     testparser [bytestring "foo\0 bar"] -1
 } {- foo 1 simple foo 1 text foo 0 {}}
-test parse-15.2 {Tcl_ParseQuotedString procedure, computing string length} {
+test parse-15.2 {Tcl_ParseQuotedString procedure, computing string length} testparser {
     testparser "foo bar" -1
 } {- {foo bar} 2 simple foo 1 text foo 0 simple bar 1 text bar 0 {}}
-test parse-15.3 {Tcl_ParseQuotedString procedure, word is quoted string} {
+test parse-15.3 {Tcl_ParseQuotedString procedure, word is quoted string} testparser {
     testparser {foo "a b c" d "efg";} 0
 } {- {foo "a b c" d "efg";} 4 simple foo 1 text foo 0 simple {"a b c"} 1 text {a b c} 0 simple d 1 text d 0 simple {"efg"} 1 text efg 0 {}}
-test parse-15.4 {Tcl_ParseQuotedString procedure, garbage after quoted string} {
+test parse-15.4 {Tcl_ParseQuotedString procedure, garbage after quoted string} testparser {
     list [catch {testparser {foo "a b c"d} 0} msg] $msg $errorInfo
 } {1 {extra characters after close-quote} {extra characters after close-quote
     (remainder of script: "d")
@@ -708,16 +788,16 @@
     info complete "abc\\\n"
 } 0
 test parse-15.51 {CommandComplete procedure} "
-    info complete \"\\{abc\\}\\{\"
+    info complete \"\\\{abc\\\}\\\{\"
 " 1
 test parse-15.52 {CommandComplete procedure} {
     info complete "\"abc\"("
 } 1
 test parse-15.53 {CommandComplete procedure} "
-    info complete \" # {\"
+    info complete \" # \{\"
 " 1
 test parse-15.54 {CommandComplete procedure} "
-    info complete \"foo bar;# {\"
+    info complete \"foo bar;# \{\"
 " 1
 test parse-15.55 {CommandComplete procedure} {
     info complete "set x [bytestring \0]; puts hi"
@@ -853,7 +933,8 @@
     set a
 } 1
 
-# cleanup
-catch {unset a}
-::tcltest::cleanupTests
+    cleanupTests
+}
+
+namespace delete ::tcl::test::parse
 return
Index: tests/pkg.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/pkg.test,v
retrieving revision 1.10
diff -u -r1.10 pkg.test
--- tests/pkg.test	27 Jun 2003 17:22:41 -0000	1.10
+++ tests/pkg.test	28 Oct 2003 21:37:08 -0000
@@ -25,7 +25,7 @@
 interp eval $i [list namespace import -force ::tcltest::*]
 interp eval $i {
 
-eval package forget [package names]
+package forget {expand}[package names]
 set oldPkgUnknown [package unknown]
 package unknown {}
 set oldPath $auto_path
Index: tests/pkgMkIndex.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/pkgMkIndex.test,v
retrieving revision 1.24
diff -u -r1.24 pkgMkIndex.test
--- tests/pkgMkIndex.test	24 Jul 2003 08:45:09 -0000	1.24
+++ tests/pkgMkIndex.test	28 Oct 2003 21:37:09 -0000
@@ -89,7 +89,7 @@
 		    set ver [lindex $args 2]
 		    set ::PKGS($pkg:$ver) [lindex $args 3]
 		} else {
-		    return [eval package_original $args]
+		    return [package_original {expand}$args]
 		}
 	    }
 	    array set ::PKGS {}
@@ -148,7 +148,7 @@
 #    1: the error result if element 0 was 1
 
 proc pkgtest::createIndex { args } {
-    set parsed [eval parseArgs $args]
+    set parsed [parseArgs {expand}$args]
     set options [lindex $parsed 0]
     set dirPath [lindex $parsed 1]
     set patternList [lindex $parsed 2]
@@ -157,7 +157,7 @@
 
     if {[catch {
 	file delete [file join $dirPath pkgIndex.tcl]
-	eval pkg_mkIndex $options [list $dirPath] $patternList
+	pkg_mkIndex {expand}$options $dirPath {expand}$patternList
     } err]} {
 	return [list 1 $err]
     }
@@ -231,7 +231,7 @@
 
 proc pkgtest::runCreatedIndex {rv args} {
     if {[lindex $rv 0] == 0} {
-	set parsed [eval parseArgs $args]
+	set parsed [parseArgs {expand}$args]
 	set dirPath [lindex $parsed 1]
 	set idxFile [file join $dirPath pkgIndex.tcl]
 
@@ -248,8 +248,8 @@
     return $result
 }
 proc pkgtest::runIndex { args } {
-    set rv [eval createIndex $args]
-    return [eval [list runCreatedIndex $rv] $args]
+    set rv [createIndex {expand}$args]
+    return [runCreatedIndex $rv {expand}$args]
 }
 
 # If there is no match to the patterns, make sure the directory hasn't
Index: tests/proc.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/proc.test,v
retrieving revision 1.11
diff -u -r1.11 proc.test
--- tests/proc.test	11 Dec 2002 21:29:52 -0000	1.11
+++ tests/proc.test	28 Oct 2003 21:37:11 -0000
@@ -20,13 +20,13 @@
     namespace import -force ::tcltest::*
 }
 
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 catch {rename p ""}
 catch {rename {} ""}
 catch {unset msg}
 
 test proc-1.1 {Tcl_ProcObjCmd, put proc in namespace specified in name, if any} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         namespace eval baz {}
     }
@@ -38,11 +38,11 @@
          [info commands test_ns_1::baz::*]
 } {{p in ::test_ns_1::baz} {p in ::test_ns_1::baz} ::test_ns_1::baz::p}
 test proc-1.2 {Tcl_ProcObjCmd, namespace specified in proc name must exist} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     list [catch {proc test_ns_1::baz::p {} {}} msg] $msg
 } {1 {can't create procedure "test_ns_1::baz::p": unknown namespace}}
 test proc-1.3 {Tcl_ProcObjCmd, empty proc name} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     proc :: {} {
         return "empty called"
     }
@@ -52,7 +52,7 @@
         return "empty called"
     }}
 test proc-1.4 {Tcl_ProcObjCmd, simple proc name and proc defined in namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         namespace eval baz {
             proc p {} {
@@ -64,7 +64,7 @@
          [info commands test_ns_1::baz::*]
 } {{p in ::test_ns_1::baz} ::test_ns_1::baz::p}
 test proc-1.5 {Tcl_ProcObjCmd, qualified proc name and proc defined in namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::baz {}
     namespace eval test_ns_1 {
         proc baz::p {} {
@@ -76,7 +76,7 @@
          [namespace eval test_ns_1::baz {namespace which p}]
 } {{p in ::test_ns_1::baz} ::test_ns_1::baz::p ::test_ns_1::baz::p}
 test proc-1.6 {Tcl_ProcObjCmd, namespace code ignores single ":"s in middle or end of command names} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         proc q: {} {return "q:"}
         proc value:at: {} {return "value:at:"}
@@ -103,13 +103,13 @@
 } {1 {procedure "p" has formal parameter "b::a" that is not a simple name}}
 
 test proc-2.1 {TclFindProc, simple proc name and proc not in namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     proc p {} {return "p in [namespace current]"}
     info body p
 } {return "p in [namespace current]"}
 test proc-2.2 {TclFindProc, simple proc name and proc defined in namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1 {
         namespace eval baz {
             proc p {} {return "p in [namespace current]"}
@@ -118,7 +118,7 @@
     namespace eval test_ns_1::baz {info body p}
 } {return "p in [namespace current]"}
 test proc-2.3 {TclFindProc, qualified proc name and proc defined in namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::baz {}
     namespace eval test_ns_1 {
         proc baz::p {} {return "p in [namespace current]"}
@@ -126,26 +126,26 @@
     namespace eval test_ns_1 {info body baz::p}
 } {return "p in [namespace current]"}
 test proc-2.4 {TclFindProc, global proc and executing in namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     proc p {} {return "global p"}
     namespace eval test_ns_1::baz {info body p}
 } {return "global p"}
 
 test proc-3.1 {TclObjInterpProc, proc defined and executing in same namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     proc p {} {return "p in [namespace current]"}
     p
 } {p in ::}
 test proc-3.2 {TclObjInterpProc, proc defined and executing in same namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     namespace eval test_ns_1::baz {
         proc p {} {return "p in [namespace current]"}
         p
     }
 } {p in ::test_ns_1::baz}
 test proc-3.3 {TclObjInterpProc, proc defined and executing in different namespaces} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     proc p {} {return "p in [namespace current]"}
     namespace eval test_ns_1::baz {
@@ -153,7 +153,7 @@
     }
 } {p in ::}
 test proc-3.4 {TclObjInterpProc, procs execute in the namespace in which they were defined unless renamed into new namespace} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename p ""}
     namespace eval test_ns_1::baz {
         proc p {} {return "p in [namespace current]"}
@@ -166,7 +166,7 @@
     list [catch {p} msg] $msg
 } {1 {wrong # args: should be "p x"}}
 
-catch {eval namespace delete [namespace children :: test_ns_*]}
+catch {namespace delete {expand}[namespace children :: test_ns_*]}
 catch {rename p ""}
 catch {rename {} ""}
 catch {unset msg}
Index: tests/reg.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/reg.test,v
retrieving revision 1.18
diff -u -r1.18 reg.test
--- tests/reg.test	6 Oct 2003 14:32:22 -0000	1.18
+++ tests/reg.test	28 Oct 2003 21:37:11 -0000
@@ -231,10 +231,8 @@
 	if {$amp >= 0} {
 		set f [string range $flags 0 [expr $amp - 1]]
 		append f [string range $flags [expr $amp + 1] end]
-		eval [linsert $args 0 f [linsert $testid end ARE] ${f} $re \
-								$target]
-		eval [linsert $args 0 f [linsert $testid end BRE] ${f}b $re \
-								$target]
+		f [linsert $testid end ARE] ${f} $re $target {expand}$args
+		f [linsert $testid end BRE] ${f}b $re $target {expand}$args
 		return
 	}
 
@@ -283,10 +281,12 @@
 	if {$amp >= 0} {
 		set f [string range $flags 0 [expr $amp - 1]]
 		append f [string range $flags [expr $amp + 1] end]
-		eval [concat [list matchexpected $opts \
-			[linsert $testid end ARE] ${f} $re $target] $args]
-		eval [concat [list matchexpected $opts \
-			[linsert $testid end BRE] ${f}b $re $target] $args]
+		matchexpected $opts [linsert $testid end ARE] \
+			${f} $re $target {expand}$args
+
+
+		matchexpected $opts [linsert $testid end BRE] \
+			${f}b $re $target {expand}$args
 		return
 	}
 
@@ -332,13 +332,13 @@
 # match expected (no missing, empty, or ambiguous submatches)
 # m testno flags re target mat submat ...
 proc m {args} {
-	eval matchexpected [linsert $args 0 [list]]
+	matchexpected {} {expand}$args
 }
 
 # match expected (full fanciness)
 # i testno flags re target mat submat ...
 proc i {args} {
-	eval matchexpected [linsert $args 0 [list "-indices"]]
+	matchexpected -indices {expand}$args 
 }
 
 # partial match expected
@@ -347,7 +347,7 @@
 proc p {args} {
 	set f [lindex $args 1]			;# add ! flag
 	set args [lreplace $args 1 1 "!$f"]
-	eval matchexpected [linsert $args 0 [list "-indices"]]
+	matchexpected -indices {expand}$args
 }
 
 # test is a knownBug
Index: tests/trace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/trace.test,v
retrieving revision 1.32
diff -u -r1.32 trace.test
--- tests/trace.test	29 Sep 2003 21:28:09 -0000	1.32
+++ tests/trace.test	28 Oct 2003 21:37:20 -0000
@@ -1346,7 +1346,7 @@
 } {}
 
 proc traceDelete {cmd old new op} {
-    eval trace remove command $cmd [lindex [trace info command $cmd] 0]
+    trace remove command $cmd {expand}[lindex [trace info command $cmd] 0]
     global info
     set info [list $old $new $op]
 }
@@ -1602,7 +1602,7 @@
 {factorial 3} 0 6 leave}
 
 proc traceDelete {cmd args} {
-    eval trace remove execution $cmd [lindex [trace info execution $cmd] 0]
+    trace remove execution $cmd {expand}[lindex [trace info execution $cmd] 0]
     global info
     set info $args
 }
Index: tests/upvar.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/upvar.test,v
retrieving revision 1.7
diff -u -r1.7 upvar.test
--- tests/upvar.test	10 Apr 2000 17:19:05 -0000	1.7
+++ tests/upvar.test	28 Oct 2003 21:37:45 -0000
@@ -320,7 +320,7 @@
     list [catch p1 msg] $msg
 } {1 {can't set "b(2)": variable isn't array}}
 test upvar-8.9 {upvar won't create namespace variable that refers to procedure variable} {
-    catch {eval namespace delete [namespace children :: test_ns_*]}
+    catch {namespace delete {expand}[namespace children :: test_ns_*]}
     catch {rename MakeLink ""}
     namespace eval ::test_ns_1 {}
     proc MakeLink {a} {
Index: tests/winConsole.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/winConsole.test,v
retrieving revision 1.5
diff -u -r1.5 winConsole.test
--- tests/winConsole.test	10 Apr 2000 17:19:06 -0000	1.5
+++ tests/winConsole.test	28 Oct 2003 21:37:45 -0000
@@ -39,7 +39,7 @@
 
     #cleanup the fileevent
     fileevent stdin readable {}
-    eval fconfigure stdin $oldmode
+    fconfigure stdin {expand}$oldmode
 
     set result
 
Index: tests/winFCmd.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/winFCmd.test,v
retrieving revision 1.22
diff -u -r1.22 winFCmd.test
--- tests/winFCmd.test	16 Sep 2003 14:56:08 -0000	1.22
+++ tests/winFCmd.test	28 Oct 2003 21:37:47 -0000
@@ -39,7 +39,7 @@
 	    set x [glob -directory $p tf* td*]
 	}
 	if {$x != ""} {
-	    catch {eval file delete -force -- $x}
+	    catch {file delete -force -- {expand}$x}
 	}
     }
 }