home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-14 | 39.7 KB | 1,075 lines |
- Newsgroups: comp.sources.misc
- From: karl@sugar.neosoft.com (Karl Lehenbauer)
- Subject: v25i082: tcl - tool command language, version 6.1, Part14/33
- Message-ID: <1991Nov14.203138.24209@sparky.imd.sterling.com>
- X-Md4-Signature: bc16ef153ac873ba9b22b57e656dcd86
- Date: Thu, 14 Nov 1991 20:31:38 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: karl@sugar.neosoft.com (Karl Lehenbauer)
- Posting-number: Volume 25, Issue 82
- Archive-name: tcl/part14
- Environment: UNIX
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 14 (of 33)."
- # Contents: tcl6.1/doc/TraceVar.man tcl6.1/tests/expr.test
- # Wrapped by karl@one on Tue Nov 12 19:44:22 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'tcl6.1/doc/TraceVar.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/doc/TraceVar.man'\"
- else
- echo shar: Extracting \"'tcl6.1/doc/TraceVar.man'\" \(17059 characters\)
- sed "s/^X//" >'tcl6.1/doc/TraceVar.man' <<'END_OF_FILE'
- X'\" Copyright 1989 Regents of the University of California
- X'\" Permission to use, copy, modify, and distribute this
- X'\" documentation for any purpose and without fee is hereby
- X'\" granted, provided that this notice appears in all copies.
- X'\" The University of California makes no representations about
- X'\" the suitability of this material for any purpose. It is
- X'\" provided "as is" without express or implied warranty.
- X'\"
- X'\" $Header: /user6/ouster/tcl/doc/RCS/TraceVar.man,v 1.6 91/08/27 13:46:37 ouster Exp $ SPRITE (Berkeley)
- X'\"
- X.\" The definitions below are for supplemental macros used in Sprite
- X.\" manual entries.
- X.\"
- X.\" .HS name section [date [version]]
- X.\" Replacement for .TH in other man pages. See below for valid
- X.\" section names.
- X.\"
- X.\" .AP type name in/out [indent]
- X.\" Start paragraph describing an argument to a library procedure.
- X.\" type is type of argument (int, etc.), in/out is either "in", "out",
- X.\" or "in/out" to describe whether procedure reads or modifies arg,
- X.\" and indent is equivalent to second arg of .IP (shouldn't ever be
- X.\" needed; use .AS below instead)
- X.\"
- X.\" .AS [type [name]]
- X.\" Give maximum sizes of arguments for setting tab stops. Type and
- X.\" name are examples of largest possible arguments that will be passed
- X.\" to .AP later. If args are omitted, default tab stops are used.
- X.\"
- X.\" .BS
- X.\" Start box enclosure. From here until next .BE, everything will be
- X.\" enclosed in one large box.
- X.\"
- X.\" .BE
- X.\" End of box enclosure.
- X.\"
- X.\" .VS
- X.\" Begin vertical sidebar, for use in marking newly-changed parts
- X.\" of man pages.
- X.\"
- X.\" .VE
- X.\" End of vertical sidebar.
- X.\"
- X.\" .DS
- X.\" Begin an indented unfilled display.
- X.\"
- X.\" .DE
- X.\" End of indented unfilled display.
- X.\"
- X' # Heading for Sprite man pages
- X.de HS
- X.if '\\$2'cmds' .TH \\$1 1 \\$3 \\$4
- X.if '\\$2'lib' .TH \\$1 3 \\$3 \\$4
- X.if '\\$2'tcl' .TH \\$1 3 \\$3 \\$4
- X.if '\\$2'tk' .TH \\$1 3 \\$3 \\$4
- X.if t .wh -1.3i ^B
- X.nr ^l \\n(.l
- X.ad b
- X..
- X' # Start an argument description
- X.de AP
- X.ie !"\\$4"" .TP \\$4
- X.el \{\
- X. ie !"\\$2"" .TP \\n()Cu
- X. el .TP 15
- X.\}
- X.ie !"\\$3"" \{\
- X.ta \\n()Au \\n()Bu
- X\&\\$1 \\fI\\$2\\fP (\\$3)
- X.\".b
- X.\}
- X.el \{\
- X.br
- X.ie !"\\$2"" \{\
- X\&\\$1 \\fI\\$2\\fP
- X.\}
- X.el \{\
- X\&\\fI\\$1\\fP
- X.\}
- X.\}
- X..
- X' # define tabbing values for .AP
- X.de AS
- X.nr )A 10n
- X.if !"\\$1"" .nr )A \\w'\\$1'u+3n
- X.nr )B \\n()Au+15n
- X.\"
- X.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
- X.nr )C \\n()Bu+\\w'(in/out)'u+2n
- X..
- X' # BS - start boxed text
- X' # ^y = starting y location
- X' # ^b = 1
- X.de BS
- X.br
- X.mk ^y
- X.nr ^b 1u
- X.if n .nf
- X.if n .ti 0
- X.if n \l'\\n(.lu\(ul'
- X.if n .fi
- X..
- X' # BE - end boxed text (draw box now)
- X.de BE
- X.nf
- X.ti 0
- X.mk ^t
- X.ie n \l'\\n(^lu\(ul'
- X.el \{\
- X.\" Draw four-sided box normally, but don't draw top of
- X.\" box if the box started on an earlier page.
- X.ie !\\n(^b-1 \{\
- X\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- X.\}
- X.el \}\
- X\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
- X.\}
- X.\}
- X.fi
- X.br
- X.nr ^b 0
- X..
- X' # VS - start vertical sidebar
- X' # ^Y = starting y location
- X' # ^v = 1 (for troff; for nroff this doesn't matter)
- X.de VS
- X.mk ^Y
- X.ie n 'mc \s12\(br\s0
- X.el .nr ^v 1u
- X..
- X' # VE - end of vertical sidebar
- X.de VE
- X.ie n 'mc
- X.el \{\
- X.ev 2
- X.nf
- X.ti 0
- X.mk ^t
- X\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
- X.sp -1
- X.fi
- X.ev
- X.\}
- X.nr ^v 0
- X..
- X' # Special macro to handle page bottom: finish off current
- X' # box/sidebar if in box/sidebar mode, then invoked standard
- X' # page bottom macro.
- X.de ^B
- X.ev 2
- X'ti 0
- X'nf
- X.mk ^t
- X.if \\n(^b \{\
- X.\" Draw three-sided box if this is the box's first page,
- X.\" draw two sides but no top otherwise.
- X.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- X.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
- X.\}
- X.if \\n(^v \{\
- X.nr ^x \\n(^tu+1v-\\n(^Yu
- X\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
- X.\}
- X.bp
- X'fi
- X.ev
- X.if \\n(^b \{\
- X.mk ^y
- X.nr ^b 2
- X.\}
- X.if \\n(^v \{\
- X.mk ^Y
- X.\}
- X..
- X' # DS - begin display
- X.de DS
- X.RS
- X.nf
- X.sp
- X..
- X' # DE - end display
- X.de DE
- X.fi
- X.RE
- X.sp .5
- X..
- X.HS Tcl_TraceVar tcl
- X.VS
- X.BS
- X.SH NAME
- XTcl_TraceVar, Tcl_TraceVar2, Tcl_UntraceVar, Tcl_UntraceVar2, \
- XTcl_VarTraceInfo, Tcl_VarTraceInfo2 \- monitor accesses to a variable
- X.SH SYNOPSIS
- X.nf
- X\fB#include <tcl.h>\fR
- X.sp
- Xint
- X\fBTcl_TraceVar(\fIinterp, varName, flags, proc, clientData\fB)\fR
- X.sp
- Xint
- X\fBTcl_TraceVar2(\fIinterp, name1, name2, flags, proc, clientData\fB)\fR
- X.sp
- X\fBTcl_UnTraceVar(\fIinterp, varName, flags, proc, clientData\fB)\fR
- X.sp
- X\fBTcl_UnTraceVar2(\fIinterp, name1, name2, flags, proc, clientData\fB)\fR
- X.sp
- XClientData
- X\fBTcl_VarTraceInfo(\fIinterp, varName, flags, proc, prevClientData\fB)\fR
- X.sp
- XClientData
- X\fBTcl_VarTraceInfo2(\fIinterp, name1, name2, flags, proc, prevClientData\fB)\fR
- X.SH ARGUMENTS
- X.AS Tcl_VarTraceProc prevClientData
- X.AP Tcl_Interp *interp in
- XInterpreter containing variable.
- X.AP char *varName in
- XName of variable. May refer to a scalar variable, to
- Xan array variable with no index, or to an array variable
- Xwith a parenthesized index.
- X.AP int flags in
- XOR-ed combination of the values TCL_TRACE_READS, TCL_TRACE_WRITES, and
- XTCL_TRACE_UNSETS, and TCL_GLOBAL_ONLY. Not all flags are used by all
- Xprocedures. See below for more information.
- X.AP Tcl_VarTraceProc *proc in
- XProcedure to invoke whenever one of the traced operations occurs.
- X.AP ClientData clientData in
- XArbitrary one-word value to pass to \fIproc\fR.
- X.AP char *name1 in
- XName of scalar or array variable (without array index).
- X.AP char *name2 in
- XFor a trace on an element of an array, gives the index of the
- Xelement. For traces on scalar variables or on whole arrays,
- Xis NULL.
- X.AP ClientData prevClientData in
- XIf non-NULL, gives last value returned by \fBTcl_VarTraceInfo\fR or
- X\fBTcl_VarTraceInfo2\fR, so this call will return information about
- Xnext trace. If NULL, this call will return information about first
- Xtrace.
- X.BE
- X
- X.SH DESCRIPTION
- X.PP
- X\fBTcl_TraceVar\fR allows a C procedure to monitor and control
- Xaccess to a Tcl variable, so that the C procedure is invoked
- Xwhenever the variable is read or written or unset.
- XIf the trace is created successfully then \fBTcl_TraceVar\fR returns
- XTCL_OK. If an error occurred (e.g. \fIvarName\fR specifies an element
- Xof an array, but the actual variable isn't an array) then TCL_ERROR
- Xis returned and an error message is left in \fIinterp->result\fR.
- X.PP
- XThe \fIflags\fR argument to \fBTcl_TraceVar\fR indicates when the
- Xtrace procedure is to be invoked and provides information
- Xfor setting up the trace. It consists of an OR-ed combination
- Xof any of the following values:
- X.TP
- X\fBTCL_GLOBAL_ONLY\fR
- XNormally, the variable will be looked up at the current level of
- Xprocedure call; if this bit is set then the variable will be looked
- Xup at global level, ignoring any active procedures.
- X.TP
- X\fBTCL_TRACE_READS\fR
- XInvoke \fIproc\fR whenever an attempt is made to read the variable.
- X.TP
- X\fBTCL_TRACE_WRITES\fR
- XInvoke \fIproc\fR whenever an attempt is made to modify the variable.
- X.TP
- X\fBTCL_TRACE_UNSETS\fR
- XInvoke \fIproc\fR whenever the variable is unset.
- XA variable may be unset either explicitly by an \fBunset\fR command,
- Xor implicitly when a procedure returns (its local variables are
- Xautomatically unset) or when the interpreter is deleted (all
- Xvariables are automatically unset).
- X.PP
- XWhenever one of the specified operations occurs on the variable,
- X\fIproc\fR will be invoked.
- XIt should have arguments and result that match the type
- X\fBTcl_VarTraceProc\fR:
- X.nf
- X.RS
- Xtypedef char *Tcl_VarTraceProc(
- X.RS
- XClientData \fIclientData\fR,
- XTcl_Interp *\fIinterp\fR,
- Xchar *\fIname1\fR,
- Xchar *\fIname2\fR,
- Xint \fIflags\fR);
- X.RE
- X.RE
- X.fi
- XThe \fIclientData\fP and \fIinterp\fP parameters will
- Xhave the same values as those passed to \fBTcl_TraceVar\fR when the
- Xtrace was created.
- X\fIClientData\fR typically points to an application-specific
- Xdata structure that describes what to do when \fIproc\fR
- Xis invoked.
- X\fIName1\fR and \fIname2\fR give the name of the traced variable
- Xin the normal two-part form (see the description of \fBTcl_TraceVar2\fR
- Xbelow for details).
- X\fIFlags\fR is an OR-ed combination of bits providing several
- Xpieces of information.
- XOne of the bits TCL_TRACE_READS, TCL_TRACE_WRITES, or TCL_TRACE_UNSETS
- Xwill be set in \fIflags\fR to indicate which operation is being performed
- Xon the variable.
- XThe bit TCL_GLOBAL_ONLY will be set whenever the variable being
- Xaccessed is a global one not accessible from the current level of
- Xprocedure call: the trace procedure will need to pass this flag
- Xback to variable-related procedures like \fBTcl_GetVar\fR if it
- Xattempts to access the variable.
- XThe bit TCL_TRACE_DESTROYED will be set in \fIflags\fR if the trace is
- Xabout to be destroyed; this information may be useful to \fIproc\fR
- Xso that it can clean up its own internal data structures (see
- Xthe section TCL_TRACE_DESTROYED below for more details).
- XLastly, the bit TCL_INTERP_DESTROYED will be set if the entire
- Xinterpreter is being destroyed.
- XWhen this bit is set, \fIproc\fR must be especially careful in
- Xthe things it does (see the section TCL_INTERP_DESTROYED below).
- XThe trace procedure's return value should normally be NULL; see
- XERROR RETURNS below for information on other possibilities.
- X.PP
- X\fBTcl_UnsetTrace\fR may be used to remove a trace.
- XIf the variable specified by \fIinterp\fR, \fIvarName\fR, and \fIflags\fR
- Xhas a trace set with \fIflags\fR, \fIproc\fR, and
- X\fIclientData\fR, then the corresponding trace is removed.
- XIf no such trace exists, then the call to \fBTcl_UnsetTrace\fR
- Xhas no effect.
- XThe same bits are valid for \fIflags\fR as for calls to \fBTcl_TraceVars\fR.
- X.PP
- X\fBTcl_VarTraceInfo\fR may be used to retrieve information about
- Xtraces set on a given variable.
- XThe return value from \fBTcl_VarTraceInfo\fR is the \fIclientData\fR
- Xassociated with a particular trace.
- XThe trace must be on the variable specified by the \fIinterp\fR,
- X\fIvarName\fR, and \fIflags\fR arguments (only the TCL_GLOBAL_ONLY
- Xbit from \fIflags\fR is used; other bits are ignored) and its trace procedure
- Xmust the same as the \fIproc\fR argument.
- XIf the \fIprevClientData\fR argument is NULL then the return
- Xvalue corresponds to the first (most recently created) matching
- Xtrace, or NULL if there are no matching traces.
- XIf the \fIprevClientData\fR argument isn't NULL, then it should
- Xbe the return value from a previous call to \fBTcl_VarTraceInfo\fR.
- XIn this case, the new return value will correspond to the next
- Xmatching trace after the one whose \fIclientData\fR matches
- X\fIprevClientData\fR, or NULL if no trace matches \fIprevClientData\fR
- Xor if there are no more matching traces after it.
- XThis mechanism makes it possible to step through all of the
- Xtraces for a given variable that have the same \fIproc\fR.
- X
- X.SH "TWO-PART NAMES"
- X.PP
- XThe procedures \fBTcl_TraceVar2\fR, \fBTcl_UntraceVar2\fR, and
- X\fBTcl_VarTraceInfo2\fR are identical to \fBTcl_TraceVar\fR,
- X\fBTcl_UntraceVar\fR, and \fBTcl_VarTraceInfo\fR, respectively,
- Xexcept that the name of the variable has already been
- Xseparated by the caller into two parts.
- X\fIName1\fR gives the name of a scalar variable or array,
- Xand \fIname2\fR gives the name of an element within an
- Xarray.
- XIf \fIname2\fR is NULL it means that either the variable is
- Xa scalar or the trace is to be set on the entire array rather
- Xthan an individual element (see WHOLE-ARRAY TRACES below for
- Xmore information).
- X
- X.SH "ACCESSING VARIABLES DURING TRACES"
- X.PP
- XDuring read and write traces, the
- Xtrace procedure can read or write the value of the traced
- Xvariable using \fBTcl_GetVar2\fR, \fBTcl_SetVar2\fR, and
- Xother procedures.
- XWhile \fIproc\fR is executing, traces are temporarily disabled
- Xfor the variable, so that calls to \fBTcl_GetVar2\fR and
- X\fBTcl_SetVar2\fR will not cause \fIproc\fR or other trace procedures
- Xto be invoked again.
- XDisabling only occurs for the variable whose trace procedure
- Xis active; accesses to other variables will still be traced.
- X.PP
- XDuring unset traces the variable has already been completely
- Xexpunged.
- XIt is possible for the trace procedure to read or write the
- Xvariable, but this will be a new version of the variable.
- XTraces are not disabled during unset traces as they are for
- Xread and write traces, but existing traces have been removed
- Xfrom the variable before any trace procedures are invoked.
- XIf new traces are set by unset trace procedures, these traces
- Xwill be invoked on accesses to the variable by the trace
- Xprocedures.
- X
- X.SH "CALLBACK TIMING"
- X.PP
- XWhen read tracing has been specified for a variable, the trace
- Xprocedure will be invoked whenever the variable's value is
- Xread. This includes \fBset\fR Tcl commands, \fB$\fR-notation
- Xin Tcl commands, and invocations of the \fBTcl_GetVar\fR
- Xand \fBTcl_GetVar2\fR procedures.
- X\fIProc\fR is invoked just before the variable's value is
- Xreturned.
- XIt may modify the value of the variable to affect what
- Xis returned by the traced access.
- X.PP
- XWhen write tracing has been specified for a variable, the
- Xtrace procedure will be invoked whenever the variable's value
- Xis modified. This includes \fBset\fR commands\fR,
- Xcommands that modify variables as side effects (such as
- X\fBcatch\fR and \fBscan\fR), and calls to the \fBTcl_SetVar\fR
- Xand \fBTcl_SetVar2\fR procedures).
- X\fIProc\fR will be invoked after the variable's value has been
- Xmodified, but before the new value of the variable has been
- Xreturned.
- XIt may modify the value of the variable to override the change
- Xand to determine the value actually returned by the traced
- Xaccess.
- X.PP
- XWhen unset tracing has been specified, the trace procedure
- Xwill be invoked whenever the variable is destroyed.
- XThe traces will be called after the variable has been
- Xcompletely unset.
- X
- X.SH "WHOLE-ARRAY TRACES"
- X.PP
- XIf a call to \fBTcl_TraceVar\fR or \fBTcl_TraceVar2\fR specifies
- Xthe name of an array variable without an index into the array,
- Xthen the trace will be set on the array as a whole.
- XThis means that \fIproc\fR will be invoked whenever any
- Xelement of the array is accessed in the ways specified by
- X\fIflags\fR.
- XWhen an array is unset, a whole-array trace will be invoked
- Xjust once, with \fIname1\fR equal to the name of the array
- Xand \fIname2\fR NULL; it will not be invoked once for each
- Xelement.
- X
- X.SH "MULTIPLE TRACES"
- X.PP
- XIt is possible for multiple traces to exist on the same variable.
- XWhen this happens, all of the trace procedures will be invoked on each
- Xaccess, in order from most-recently-created to least-recently-created.
- XWhen there exist whole-array traces for an array as well as
- Xtraces on individual elements, the whole-array traces are invoked
- Xbefore the individual-element traces.
- X
- X.SH "ERROR RETURNS"
- X.PP
- XUnder normal conditions trace procedures should return NULL, indicating
- Xsuccessful completion.
- XIf \fIproc\fR returns a non-NULL value it signifies that an
- Xerror occurred.
- XThe return value must be a pointer to a static character string
- Xcontaining an error message.
- XIf a trace procedure returns an error, no further traces are
- Xinvoked for the access and the traced access aborts with the
- Xgiven message.
- XTrace procedures can use this facility to make variables
- Xread-only, for example (but note that the value of the variable
- Xwill already have been modified before the trace procedure is
- Xcalled, so the trace procedure will have to restore the correct
- Xvalue).
- X.PP
- XThe return value from \fIproc\fR is only used during read and
- Xwrite tracing.
- XDuring unset traces, the return value is ignored and all relevant
- Xtrace procedures will always be invoked.
- X
- X.SH "RESTRICTIONS"
- X.PP
- XIt is not legal to delete a variable while a trace procedure
- Xis active for the variable.
- X
- X.SH "UNDEFINED VARIABLES"
- X.PP
- XIt is legal to set a trace on an undefined variable.
- XThe variable will still appear to be undefined until the
- Xfirst time its value is set.
- XIf an undefined variable is traced and then unset, the unset will fail
- Xwith an error (``no such variable''), but the trace
- Xprocedure will still be invoked.
- X
- X.SH "TCL_TRACE_DELETED FLAG"
- X.PP
- XIn an unset callback to \fIproc\fR, the TCL_TRACE_DELETED bit
- Xis set in \fIflags\fR if the trace is being removed as part
- Xof the deletion.
- XTraces on a variable are always removed whenever the variable
- Xis deleted; the only time TCL_TRACE_DELETED isn't set is for
- Xa whole-array trace invoked when only a single element of an
- Xarray is unset.
- X
- X.SH "TCL_INTERP_DESTROYED"
- X.PP
- XWhen an interpreter is destroyed, unset traces are called for
- Xall of its variables.
- XThe TCL_INTERP_DESTROYED bit will be set in the \fIflags\fR
- Xargument passed to the trace procedures.
- XTrace procedures must be extremely careful in what they do if
- Xthe TCL_INTERP_DESTROYED bit is set.
- XIt is not safe for the procedures to invoke any Tcl procedures
- Xon the interpreter, since its state is partially deleted.
- XAll that trace procedures should do under these circumstances is
- Xto clean up and free their own internal data structures.
- X
- X.SH BUGS
- X.PP
- XTcl doesn't do any error checking to prevent trace procedures
- Xfrom misusing the interpreter during traces with TCL_INTERP_DESTROYED
- Xset.
- X
- X.SH KEYWORDS
- XclientData, trace, variable
- X.VE
- END_OF_FILE
- if test 17059 -ne `wc -c <'tcl6.1/doc/TraceVar.man'`; then
- echo shar: \"'tcl6.1/doc/TraceVar.man'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/doc/TraceVar.man'
- fi
- if test -f 'tcl6.1/tests/expr.test' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tcl6.1/tests/expr.test'\"
- else
- echo shar: Extracting \"'tcl6.1/tests/expr.test'\" \(19899 characters\)
- sed "s/^X//" >'tcl6.1/tests/expr.test' <<'END_OF_FILE'
- X# Commands covered: expr
- X#
- X# This file contains a collection of tests for one or more of the Tcl
- X# built-in commands. Sourcing this file into Tcl runs the tests and
- X# generates output for errors. No output means no errors were found.
- X#
- X# $Header: /user6/ouster/tcl/tests/RCS/expr.test,v 1.11 91/10/31 16:40:46 ouster Exp $ (Berkeley)
- X
- Xif {[string compare test [info procs test]] == 1} then {source defs}
- X
- X# First, test all of the integer operators individually.
- X
- Xtest expr-1.1 {integer operators} {expr -4} -4
- Xtest expr-1.2 {integer operators} {expr -(1+4)} -5
- Xtest expr-1.3 {integer operators} {expr ~3} -4
- Xtest expr-1.4 {integer operators} {expr !2} 0
- Xtest expr-1.5 {integer operators} {expr !0} 1
- Xtest expr-1.6 {integer operators} {expr 4*6} 24
- Xtest expr-1.7 {integer operators} {expr 36/12} 3
- Xtest expr-1.8 {integer operators} {expr 27/4} 6
- Xtest expr-1.9 {integer operators} {expr 27%4} 3
- Xtest expr-1.10 {integer operators} {expr 2+2} 4
- Xtest expr-1.11 {integer operators} {expr 2-6} -4
- Xtest expr-1.12 {integer operators} {expr 1<<3} 8
- Xtest expr-1.13 {integer operators} {expr 0xff>>2} 63
- Xtest expr-1.14 {integer operators} {expr -1>>2} -1
- Xtest expr-1.15 {integer operators} {expr 3>2} 1
- Xtest expr-1.16 {integer operators} {expr 2>2} 0
- Xtest expr-1.17 {integer operators} {expr 1>2} 0
- Xtest expr-1.18 {integer operators} {expr 3<2} 0
- Xtest expr-1.19 {integer operators} {expr 2<2} 0
- Xtest expr-1.20 {integer operators} {expr 1<2} 1
- Xtest expr-1.21 {integer operators} {expr 3>=2} 1
- Xtest expr-1.22 {integer operators} {expr 2>=2} 1
- Xtest expr-1.23 {integer operators} {expr 1>=2} 0
- Xtest expr-1.24 {integer operators} {expr 3<=2} 0
- Xtest expr-1.25 {integer operators} {expr 2<=2} 1
- Xtest expr-1.26 {integer operators} {expr 1<=2} 1
- Xtest expr-1.27 {integer operators} {expr 3==2} 0
- Xtest expr-1.28 {integer operators} {expr 2==2} 1
- Xtest expr-1.29 {integer operators} {expr 3!=2} 1
- Xtest expr-1.30 {integer operators} {expr 2!=2} 0
- Xtest expr-1.31 {integer operators} {expr 7&0x13} 3
- Xtest expr-1.32 {integer operators} {expr 7^0x13} 20
- Xtest expr-1.33 {integer operators} {expr 7|0x13} 23
- Xtest expr-1.34 {integer operators} {expr 0&&1} 0
- Xtest expr-1.35 {integer operators} {expr 0&&0} 0
- Xtest expr-1.36 {integer operators} {expr 1&&3} 1
- Xtest expr-1.37 {integer operators} {expr 0||1} 1
- Xtest expr-1.38 {integer operators} {expr 3||0} 1
- Xtest expr-1.39 {integer operators} {expr 0||0} 0
- Xtest expr-1.40 {integer operators} {expr 3>2?44:66} 44
- Xtest expr-1.41 {integer operators} {expr 2>3?44:66} 66
- X
- X# Check the floating-point operators individually, along with
- X# automatic conversion to integers where needed.
- X
- Xtest expr-2.1 {floating-point operators} {expr -4.2} -4.2
- Xtest expr-2.2 {floating-point operators} {expr -(1.1+4.2)} -5.3
- Xtest expr-2.3 {floating-point operators} {expr !2.1} 0
- Xtest expr-2.4 {floating-point operators} {expr !0.0} 1
- Xtest expr-2.5 {floating-point operators} {expr 4.2*6.3} 26.46
- Xtest expr-2.6 {floating-point operators} {expr 36.0/12.0} 3
- Xtest expr-2.7 {floating-point operators} {expr 27/4.0} 6.75
- Xtest expr-2.8 {floating-point operators} {expr 2.3+2.1} 4.4
- Xtest expr-2.9 {floating-point operators} {expr 2.3-6.5} -4.2
- Xtest expr-2.10 {floating-point operators} {expr 3.1>2.1} 1
- Xtest expr-2.11 {floating-point operators} {expr {2.1 > 2.1}} 0
- Xtest expr-2.12 {floating-point operators} {expr 1.23>2.34e+1} 0
- Xtest expr-2.13 {floating-point operators} {expr 3.45<2.34} 0
- Xtest expr-2.14 {floating-point operators} {expr 0.002e3<--200e-2} 0
- Xtest expr-2.15 {floating-point operators} {expr 1.1<2.1} 1
- Xtest expr-2.16 {floating-point operators} {expr 3.1>=2.2} 1
- Xtest expr-2.17 {floating-point operators} {expr 2.345>=2.345} 1
- Xtest expr-2.18 {floating-point operators} {expr 1.1>=2.2} 0
- Xtest expr-2.19 {floating-point operators} {expr 3.0<=2.0} 0
- Xtest expr-2.20 {floating-point operators} {expr 2.2<=2.2} 1
- Xtest expr-2.21 {floating-point operators} {expr 2.2<=2.2001} 1
- Xtest expr-2.22 {floating-point operators} {expr 3.2==2.2} 0
- Xtest expr-2.23 {floating-point operators} {expr 2.2==2.2} 1
- Xtest expr-2.24 {floating-point operators} {expr 3.2!=2.2} 1
- Xtest expr-2.25 {floating-point operators} {expr 2.2!=2.2} 0
- Xtest expr-2.26 {floating-point operators} {expr 0.0&&0.0} 0
- Xtest expr-2.27 {floating-point operators} {expr 0.0&&1.3} 0
- Xtest expr-2.28 {floating-point operators} {expr 1.3&&0.0} 0
- Xtest expr-2.29 {floating-point operators} {expr 1.3&&3.3} 1
- Xtest expr-2.30 {floating-point operators} {expr 0.0||0.0} 0
- Xtest expr-2.31 {floating-point operators} {expr 0.0||1.3} 1
- Xtest expr-2.32 {floating-point operators} {expr 1.3||0.0} 1
- Xtest expr-2.33 {floating-point operators} {expr 3.3||0.0} 1
- Xtest expr-2.34 {floating-point operators} {expr 3.3>2.3?44.3:66.3} 44.3
- Xtest expr-2.35 {floating-point operators} {expr 2.3>3.3?44.3:66.3} 66.3
- X
- X# Operators that aren't legal on floating-point numbers
- X
- Xtest expr-3.1 {illegal floating-point operations} {
- X list [catch {expr ~4.0} msg] $msg
- X} {1 {can't use floating-point value as operand of "~"}}
- Xtest expr-3.2 {illegal floating-point operations} {
- X list [catch {expr 27%4.0} msg] $msg
- X} {1 {can't use floating-point value as operand of "%"}}
- Xtest expr-3.3 {illegal floating-point operations} {
- X list [catch {expr 27.0%4} msg] $msg
- X} {1 {can't use floating-point value as operand of "%"}}
- Xtest expr-3.4 {illegal floating-point operations} {
- X list [catch {expr 1.0<<3} msg] $msg
- X} {1 {can't use floating-point value as operand of "<<"}}
- Xtest expr-3.5 {illegal floating-point operations} {
- X list [catch {expr 3<<1.0} msg] $msg
- X} {1 {can't use floating-point value as operand of "<<"}}
- Xtest expr-3.6 {illegal floating-point operations} {
- X list [catch {expr 24.0>>3} msg] $msg
- X} {1 {can't use floating-point value as operand of ">>"}}
- Xtest expr-3.7 {illegal floating-point operations} {
- X list [catch {expr 24>>3.0} msg] $msg
- X} {1 {can't use floating-point value as operand of ">>"}}
- Xtest expr-3.8 {illegal floating-point operations} {
- X list [catch {expr 24&3.0} msg] $msg
- X} {1 {can't use floating-point value as operand of "&"}}
- Xtest expr-3.9 {illegal floating-point operations} {
- X list [catch {expr 24.0|3} msg] $msg
- X} {1 {can't use floating-point value as operand of "|"}}
- Xtest expr-3.10 {illegal floating-point operations} {
- X list [catch {expr 24.0^3} msg] $msg
- X} {1 {can't use floating-point value as operand of "^"}}
- X
- X# Check the string operators individually.
- X
- Xtest expr-4.1 {string operators} {expr {"abc" > "def"}} 0
- Xtest expr-4.2 {string operators} {expr {"def" > "def"}} 0
- Xtest expr-4.3 {string operators} {expr {"g" > "def"}} 1
- Xtest expr-4.4 {string operators} {expr {"abc" < "abd"}} 1
- Xtest expr-4.5 {string operators} {expr {"abd" < "abd"}} 0
- Xtest expr-4.6 {string operators} {expr {"abe" < "abd"}} 0
- Xtest expr-4.7 {string operators} {expr {"abc" >= "def"}} 0
- Xtest expr-4.8 {string operators} {expr {"def" >= "def"}} 1
- Xtest expr-4.9 {string operators} {expr {"g" >= "def"}} 1
- Xtest expr-4.10 {string operators} {expr {"abc" <= "abd"}} 1
- Xtest expr-4.11 {string operators} {expr {"abd" <= "abd"}} 1
- Xtest expr-4.12 {string operators} {expr {"abe" <= "abd"}} 0
- Xtest expr-4.13 {string operators} {expr {"abc" == "abd"}} 0
- Xtest expr-4.14 {string operators} {expr {"abd" == "abd"}} 1
- Xtest expr-4.15 {string operators} {expr {"abc" != "abd"}} 1
- Xtest expr-4.16 {string operators} {expr {"abd" != "abd"}} 0
- Xtest expr-4.17 {string operators} {expr {"0y" < "0x12"}} 1
- Xtest expr-4.18 {string operators} {expr {1?"foo":"bar"}} foo
- Xtest expr-4.19 {string operators} {expr {0?"foo":"bar"}} bar
- X
- X# Operators that aren't legal on string operands.
- X
- Xtest expr-5.1 {illegal string operations} {
- X list [catch {expr {-"a"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "-"}}
- Xtest expr-5.2 {illegal string operations} {
- X list [catch {expr {~"a"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "~"}}
- Xtest expr-5.3 {illegal string operations} {
- X list [catch {expr {!"a"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "!"}}
- Xtest expr-5.4 {illegal string operations} {
- X list [catch {expr {"a"*"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "*"}}
- Xtest expr-5.5 {illegal string operations} {
- X list [catch {expr {"a"/"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "/"}}
- Xtest expr-5.6 {illegal string operations} {
- X list [catch {expr {"a"%"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "%"}}
- Xtest expr-5.7 {illegal string operations} {
- X list [catch {expr {"a"+"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "+"}}
- Xtest expr-5.8 {illegal string operations} {
- X list [catch {expr {"a"-"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "-"}}
- Xtest expr-5.9 {illegal string operations} {
- X list [catch {expr {"a"<<"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "<<"}}
- Xtest expr-5.10 {illegal string operations} {
- X list [catch {expr {"a">>"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of ">>"}}
- Xtest expr-5.11 {illegal string operations} {
- X list [catch {expr {"a"&"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "&"}}
- Xtest expr-5.12 {illegal string operations} {
- X list [catch {expr {"a"^"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "^"}}
- Xtest expr-5.13 {illegal string operations} {
- X list [catch {expr {"a"|"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "|"}}
- Xtest expr-5.14 {illegal string operations} {
- X list [catch {expr {"a"&&"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "&&"}}
- Xtest expr-5.15 {illegal string operations} {
- X list [catch {expr {"a"||"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "||"}}
- Xtest expr-5.16 {illegal string operations} {
- X list [catch {expr {"a"?4:2}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "?"}}
- X
- X# Check precedence pairwise.
- X
- Xtest expr-6.1 {precedence checks} {expr -~3} 4
- Xtest expr-6.2 {precedence checks} {expr -!3} 0
- Xtest expr-6.3 {precedence checks} {expr -~0} 1
- X
- Xtest expr-7.1 {precedence checks} {expr 2*4/6} 1
- Xtest expr-7.2 {precedence checks} {expr 24/6*3} 12
- Xtest expr-7.3 {precedence checks} {expr 24/6/2} 2
- X
- Xtest expr-8.1 {precedence checks} {expr -2+4} 2
- Xtest expr-8.2 {precedence checks} {expr -2-4} -6
- X
- Xtest expr-9.1 {precedence checks} {expr 2*3+4} 10
- Xtest expr-9.2 {precedence checks} {expr 8/2+4} 8
- Xtest expr-9.3 {precedence checks} {expr 8%3+4} 6
- Xtest expr-9.4 {precedence checks} {expr 2*3-1} 5
- Xtest expr-9.5 {precedence checks} {expr 8/2-1} 3
- Xtest expr-9.6 {precedence checks} {expr 8%3-1} 1
- X
- Xtest expr-10.1 {precedence checks} {expr 6-3-2} 1
- X
- Xtest expr-11.1 {precedence checks} {expr 7+1>>2} 2
- Xtest expr-11.2 {precedence checks} {expr 7+1<<2} 32
- Xtest expr-11.3 {precedence checks} {expr 7>>3-2} 3
- Xtest expr-11.4 {precedence checks} {expr 7<<3-2} 14
- X
- Xtest expr-12.1 {precedence checks} {expr 6>>1>4} 0
- Xtest expr-12.2 {precedence checks} {expr 6>>1<2} 0
- Xtest expr-12.3 {precedence checks} {expr 6>>1>=3} 1
- Xtest expr-12.4 {precedence checks} {expr 6>>1<=2} 0
- Xtest expr-12.5 {precedence checks} {expr 6<<1>5} 1
- Xtest expr-12.6 {precedence checks} {expr 6<<1<5} 0
- Xtest expr-12.7 {precedence checks} {expr 5<=6<<1} 1
- Xtest expr-12.8 {precedence checks} {expr 5>=6<<1} 0
- X
- Xtest expr-13.1 {precedence checks} {expr 2<3<4} 1
- Xtest expr-13.2 {precedence checks} {expr 0<4>2} 0
- Xtest expr-13.3 {precedence checks} {expr 4>2<1} 0
- Xtest expr-13.4 {precedence checks} {expr 4>3>2} 0
- Xtest expr-13.5 {precedence checks} {expr 4>3>=2} 0
- Xtest expr-13.6 {precedence checks} {expr 4>=3>2} 0
- Xtest expr-13.7 {precedence checks} {expr 4>=3>=2} 0
- Xtest expr-13.8 {precedence checks} {expr 0<=4>=2} 0
- Xtest expr-13.9 {precedence checks} {expr 4>=2<=0} 0
- Xtest expr-10.10 {precedence checks} {expr 2<=3<=4} 1
- X
- Xtest expr-14.1 {precedence checks} {expr 1==4>3} 1
- Xtest expr-14.2 {precedence checks} {expr 0!=4>3} 1
- Xtest expr-14.3 {precedence checks} {expr 1==3<4} 1
- Xtest expr-14.4 {precedence checks} {expr 0!=3<4} 1
- Xtest expr-14.5 {precedence checks} {expr 1==4>=3} 1
- Xtest expr-14.6 {precedence checks} {expr 0!=4>=3} 1
- Xtest expr-14.7 {precedence checks} {expr 1==3<=4} 1
- Xtest expr-14.8 {precedence checks} {expr 0!=3<=4} 1
- X
- Xtest expr-15.1 {precedence checks} {expr 1==3==3} 0
- Xtest expr-15.2 {precedence checks} {expr 3==3!=2} 1
- Xtest expr-15.3 {precedence checks} {expr 2!=3==3} 0
- Xtest expr-15.4 {precedence checks} {expr 2!=1!=1} 0
- X
- Xtest expr-16.1 {precedence checks} {expr 2&3==2} 0
- Xtest expr-16.2 {precedence checks} {expr 1&3!=3} 0
- X
- Xtest expr-17.1 {precedence checks} {expr 7&3^0x10} 19
- Xtest expr-17.2 {precedence checks} {expr 7^0x10&3} 7
- X
- Xtest expr-18.1 {precedence checks} {expr 7^0x10|3} 23
- Xtest expr-18.2 {precedence checks} {expr 7|0x10^3} 23
- X
- Xtest expr-19.1 {precedence checks} {expr 7|3&&1} 1
- Xtest expr-19.2 {precedence checks} {expr 1&&3|7} 1
- Xtest expr-19.3 {precedence checks} {expr 0&&1||1} 1
- Xtest expr-19.4 {precedence checks} {expr 1||1&&0} 1
- X
- Xtest expr-20.1 {precedence checks} {expr 1||0?3:4} 3
- Xtest expr-20.2 {precedence checks} {expr 1?0:4||1} 0
- X
- X# Parentheses.
- X
- Xtest expr-21.1 {parenthesization} {expr (2+4)*6} 36
- Xtest expr-21.2 {parenthesization} {expr (1?0:4)||1} 1
- X
- X# Embedded commands and variable names.
- X
- Xset a 16
- Xtest expr-22.1 {embedded variables} {expr {2*$a}} 32
- Xtest expr-22.2 {embedded variables} {
- X set x -5
- X set y 10
- X expr {$x + $y}
- X} {5}
- Xtest expr-22.3 {embedded commands and variables} {expr {[set a] - 14}} 2
- Xtest expr-22.4 {embedded commands and variables} {
- X list [catch {expr {12 - [bad_command_name]}} msg] $msg
- X} {1 {invalid command name: "bad_command_name"}}
- X
- X# Double-quotes and things inside them.
- X
- Xtest expr-23.1 {double-quotes} {expr {"abc"}} abc
- Xtest expr-23.2 {double-quotes} {
- X set a 189
- X expr {"$a.bc"}
- X} 189.bc
- Xtest expr-23.3 {double-quotes} {
- X set b2 xyx
- X expr {"$b2$b2$b2.[set b2].[set b2]"}
- X} xyxxyxxyx.xyx.xyx
- Xtest expr-23.4 {double-quotes} {expr {"11\}\}22"}} 11}}22
- Xtest expr-23.5 {double-quotes} {expr {"\abc"}} {\abc}
- Xtest expr-23.6 {double-quotes} {
- X catch {unset bogus__}
- X list [catch {expr {"$bogus__"}} msg] $msg
- X} {1 {can't read "bogus__": no such variable}}
- Xtest expr-23.7 {double-quotes} {
- X list [catch {expr {"a[error Testing]bc"}} msg] $msg
- X} {1 Testing}
- X
- X# Numbers in various bases.
- X
- Xtest expr-24.1 {numbers in different bases} {expr 0x20} 32
- Xtest expr-24.2 {numbers in different bases} {expr 015} 13
- X
- X# Conversions between various data types.
- X
- Xtest expr-25.1 {type conversions} {expr 2+2.5} 4.5
- Xtest expr-25.2 {type conversions} {expr 2.5+2} 4.5
- Xtest expr-25.3 {type conversions} {expr 2-2.5} -0.5
- Xtest expr-25.4 {type conversions} {expr 2/2.5} 0.8
- Xtest expr-25.5 {type conversions} {expr 2>2.5} 0
- Xtest expr-25.6 {type conversions} {expr 2.5>2} 1
- Xtest expr-25.7 {type conversions} {expr 2<2.5} 1
- Xtest expr-25.8 {type conversions} {expr 2>=2.5} 0
- Xtest expr-25.9 {type conversions} {expr 2<=2.5} 1
- Xtest expr-25.10 {type conversions} {expr 2==2.5} 0
- Xtest expr-25.11 {type conversions} {expr 2!=2.5} 1
- Xtest expr-25.12 {type conversions} {expr 2>"ab"} 0
- Xtest expr-25.13 {type conversions} {expr {2>" "}} 1
- Xtest expr-25.14 {type conversions} {expr {"24.1a" > 24.1}} 1
- Xtest expr-25.15 {type conversions} {expr {24.1 > "24.1a"}} 0
- Xtest expr-25.16 {type conversions} {expr 2+2.5} 4.5
- Xtest expr-25.17 {type conversions} {expr 2+2.5} 4.5
- X
- X# Various error conditions.
- X
- Xtest expr-26.1 {error conditions} {
- X list [catch {expr 2+"a"} msg] $msg
- X} {1 {can't use non-numeric string as operand of "+"}}
- Xtest expr-26.2 {error conditions} {
- X list [catch {expr 2+4*} msg] $msg
- X} {1 {syntax error in expression "2+4*"}}
- Xtest expr-26.3 {error conditions} {
- X list [catch {expr 2+4*(} msg] $msg
- X} {1 {syntax error in expression "2+4*("}}
- Xcatch {unset _non_existent_}
- Xtest expr-26.4 {error conditions} {
- X list [catch {expr 2+$_non_existent_} msg] $msg
- X} {1 {can't read "_non_existent_": no such variable}}
- Xset a xx
- Xtest expr-26.5 {error conditions} {
- X list [catch {expr {2+$a}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "+"}}
- Xtest expr-26.6 {error conditions} {
- X list [catch {expr {2+[set a]}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "+"}}
- Xtest expr-26.7 {error conditions} {
- X list [catch {expr {2+(4}} msg] $msg
- X} {1 {unmatched parentheses in expression "2+(4"}}
- Xtest expr-26.8 {error conditions} {
- X list [catch {expr 2/0} msg] $msg
- X} {1 {divide by zero}}
- Xtest expr-26.9 {error conditions} {
- X list [catch {expr 2%0} msg] $msg
- X} {1 {divide by zero}}
- Xtest expr-26.10 {error conditions} {
- X list [catch {expr 2#} msg] $msg
- X} {1 {syntax error in expression "2#"}}
- Xtest expr-26.11 {error conditions} {
- X list [catch {expr a.b} msg] $msg
- X} {1 {syntax error in expression "a.b"}}
- Xtest expr-26.12 {error conditions} {
- X list [catch {expr {"a"/"b"}} msg] $msg
- X} {1 {can't use non-numeric string as operand of "/"}}
- Xtest expr-26.13 {error conditions} {
- X list [catch {expr 2:3} msg] $msg
- X} {1 {can't have : operator without ? first}}
- Xtest expr-26.14 {error conditions} {
- X list [catch {expr a@b} msg] $msg
- X} {1 {syntax error in expression "a@b"}}
- Xtest expr-26.15 {error conditions} {
- X list [catch {expr a@b} msg] $msg
- X} {1 {syntax error in expression "a@b"}}
- Xtest expr-26.16 {error conditions} {
- X list [catch {expr a[b} msg] $msg
- X} {1 {missing close-bracket}}
- Xtest expr-26.17 {error conditions} {
- X list [catch {expr a`b} msg] $msg
- X} {1 {syntax error in expression "a`b"}}
- Xtest expr-26.18 {error conditions} {
- X list [catch {expr \"a\"\{b} msg] $msg
- X} {1 {missing close-brace}}
- Xtest expr-26.19 {error conditions} {
- X list [catch {expr a} msg] $msg
- X} {1 {syntax error in expression "a"}}
- X
- X# Cancelled evaluation.
- X
- Xtest expr-27.1 {cancelled evaluation} {
- X set a 1
- X expr {0&&[set a 2]}
- X set a
- X} 1
- Xtest expr-27.2 {cancelled evaluation} {
- X set a 1
- X expr {1||[set a 2]}
- X set a
- X} 1
- Xtest expr-27.3 {cancelled evaluation} {
- X set a 1
- X expr {0?[set a 2]:1}
- X set a
- X} 1
- Xtest expr-27.4 {cancelled evaluation} {
- X set a 1
- X expr {1?2:[set a 2]}
- X set a
- X} 1
- X
- X# Tcl_ExprBool as used in "if" statements
- X
- Xtest expr-28.1 {Tcl_ExprBoolean usage} {
- X set a 1
- X if {2} {
- X set a 2
- X }
- X set a
- X} 2
- Xtest expr-28.2 {Tcl_ExprBoolean usage} {
- X set a 1
- X if {0} {
- X set a 2
- X }
- X set a
- X} 1
- Xtest expr-28.3 {Tcl_ExprBoolean usage} {
- X set a 1
- X if {1.2} {
- X set a 2
- X }
- X set a
- X} 2
- Xtest expr-28.4 {Tcl_ExprBoolean usage} {
- X set a 1
- X if {-1.1} {
- X set a 2
- X }
- X set a
- X} 2
- Xtest expr-28.5 {Tcl_ExprBoolean usage} {
- X set a 1
- X if {0.0} {
- X set a 2
- X }
- X set a
- X} 1
- Xtest expr-28.6 {Tcl_ExprBool usage} {
- X list [catch {if {"abc"} {}} msg] $msg
- X} {1 {expression didn't have numeric value}}
- X
- X# Operands enclosed in braces
- X
- Xtest expr-29.1 {braces} {expr {{abc}}} abc
- Xtest expr-29.2 {braces} {expr {{00010}}} 8
- Xtest expr-29.3 {braces} {expr {{3.1200000}}} 3.12
- Xtest expr-29.4 {braces} {expr {{a{b}{1 {2 3}}c}}} "a{b}{1 {2 3}}c"
- Xtest expr-29.5 {braces} {
- X list [catch {expr "\{abc"} msg] $msg
- X} {1 {missing close-brace}}
- X
- X# Very long values
- X
- Xtest expr-30.1 {long values} {
- X set a "0000 1111 2222 3333 4444"
- X set a "$a | $a | $a | $a | $a"
- X set a "$a || $a || $a || $a || $a"
- X expr {$a}
- X} {0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 \
- X4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 \
- X3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 \
- X2222 3333 4444 | 0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 \
- X1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | \
- X0000 1111 2222 3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 \
- X4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 \
- X3333 4444 || 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 \
- X2222 3333 4444 | 0000 1111 2222 3333 4444 | 0000 1111 2222 3333 4444}
- Xtest expr-30.2 {long values} {
- X set a "000000000000000000000000000000"
- X set a "$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a${a}5"
- X expr $a
- X} 5
- END_OF_FILE
- if test 19899 -ne `wc -c <'tcl6.1/tests/expr.test'`; then
- echo shar: \"'tcl6.1/tests/expr.test'\" unpacked with wrong size!
- fi
- # end of 'tcl6.1/tests/expr.test'
- fi
- echo shar: End of archive 14 \(of 33\).
- cp /dev/null ark14isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 33 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-