os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/compExpr-old.test
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/compExpr-old.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,678 @@
1.4 +# Commands covered: expr
1.5 +#
1.6 +# This file contains the original set of tests for the compilation (and
1.7 +# indirectly execution) of Tcl's expr command. A new set of tests covering
1.8 +# the new implementation are in the files "parseExpr.test" and
1.9 +# "compExpr.test". Sourcing this file into Tcl runs the tests and generates
1.10 +# output for errors. No output means no errors were found.
1.11 +#
1.12 +# Copyright (c) 1996-1997 Sun Microsystems, Inc.
1.13 +# Copyright (c) 1998-1999 by Scriptics Corporation.
1.14 +#
1.15 +# See the file "license.terms" for information on usage and redistribution
1.16 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1.17 +#
1.18 +# RCS: @(#) $Id: compExpr-old.test,v 1.7 2001/12/06 10:59:17 dkf Exp $
1.19 +
1.20 +if {[lsearch [namespace children] ::tcltest] == -1} {
1.21 + package require tcltest
1.22 + namespace import -force ::tcltest::*
1.23 +}
1.24 +
1.25 +if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
1.26 + set gotT1 0
1.27 + puts "This application hasn't been compiled with the \"T1\" and"
1.28 + puts "\"T2\" math functions, so I'll skip some of the expr tests."
1.29 +} else {
1.30 + set gotT1 1
1.31 +}
1.32 +
1.33 +# procedures used below
1.34 +
1.35 +proc put_hello_char {c} {
1.36 + global a
1.37 + append a [format %c $c]
1.38 + return $c
1.39 +}
1.40 +proc hello_world {} {
1.41 + global a
1.42 + set a ""
1.43 + set L1 [set l0 [set h_1 [set q 0]]]
1.44 + for {put_hello_char [expr [put_hello_char [expr [set h 7]*10+2]]+29]} {$l0?[put_hello_char $l0]
1.45 + :!$h_1} {put_hello_char $ll;expr {$L1==2?[set ll [expr 32+0-0+[set bar 0]]]:0}} {expr {[incr L1]==[expr 1+([string length "abc"]-[string length "abc"])]
1.46 + ?[set ll [set l0 [expr 54<<1]]]:$ll==108&&$L1<3?
1.47 + [incr ll [expr 1|1<<1]; set ll $ll; set ll $ll; set ll $ll; set ll $ll; set l0 [expr ([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])]; set l0; set l0 $l0; set l0; set l0]:$L1==4&&$ll==32?[set ll [expr 19+$h1+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])+[set foo [expr ([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])+([string length "abc"]-[string length "abc"])]]]]
1.48 + :[set q [expr $q-$h1+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])]]};expr {$L1==5?[incr ll -8; set ll $ll; set ll]:$q&&$h1&&1};expr {$L1==4+2
1.49 + ?[incr ll 3]:[expr ([string length "abc"]-[string length "abc"])+1]};expr {$ll==($h<<4)+2+0&&$L1!=6?[incr ll -6]:[set h1 [expr 100+([string length "abc"]-[string length "abc"])-([string length "abc"]-[string length "abc"])]]}
1.50 + expr {$L1!=1<<3?[incr q [expr ([string length "abc"]-[string length "abc"])-1]]:[set h_1 [set ll $h1]]}
1.51 + }
1.52 + set a
1.53 +}
1.54 +
1.55 +proc 12days {a b c} {
1.56 + global xxx
1.57 + expr {1<$a?[expr {$a<3?[12days -79 -13 [string range $c [12days -87 \
1.58 + [expr 1-$b] [string range $c [12days -86 0 [string range $c 1 end]] \
1.59 + end]] end]]:1};expr {$a<$b?[12days [expr $a+1] $b $c]:3};expr {[12days \
1.60 + -94 [expr $a-27] $c]&&$a==2?$b<13?[12days 2 [expr $b+1] "%s %d %d\n"]:9
1.61 + :16}]:$a<0?$a<-72?[12days $b $a "@n'+,#'/*\{\}w+/w#cdnr/+,\{\}r/*de\}+,/*\{*+,/w\{%+,/w#q#n+,/#\{l+,/n\{n+,/+#n+,/#;#q#n+,/+k#;*+,/'r :'d*'3,\}\{w+K w'K:'+\}e#';dq#'l q#'+d'K#!/+k#;q#'r\}eKK#\}w'r\}eKK\{nl\]'/#;#q#n')\{)#\}w')\{)\{nl\]'/+#n';d\}rw' i;# )\{nl\]!/n\{n#'; r\{#w'r nc\{nl\]'/#\{l,+'K \{rw' iK\{;\[\{nl\]'/w#q#n'wk nw' iwk\{KK\{nl\]!/w\{%'l##w#' i; :\{nl\]'/*\{q#'ld;r'\}\{nlwb!/*de\}'c ;;\{nl'-\{\}rw\]'/+,\}##'*\}#nc,',#nw\]'/+kd'+e\}+;#'rdq#w! nr'/ ') \}+\}\{rl#'\{n' ')# \}'+\}##(!!/"]
1.62 + :$a<-50?[string compare [format %c $b] [string index $c 0]]==0?[append \
1.63 + xxx [string index $c 31];scan [string index $c 31] %c x;set x]
1.64 + :[12days -65 $b [string range $c 1 end]]:[12days [expr ([string compare \
1.65 + [string index $c 0] "/"]==0)+$a] $b [string range $c 1 end]]:0<$a
1.66 + ?[12days 2 2 "%s"]:[string compare [string index $c 0] "/"]==0||
1.67 + [12days 0 [12days -61 [scan [string index $c 0] %c x; set x] \
1.68 + "!ek;dc i@bK'(q)-\[w\]*%n+r3#l,\{\}:\nuwloca-O;m .vpbks,fxntdCeghiry"] \
1.69 + [string range $c 1 end]]}
1.70 +}
1.71 +proc do_twelve_days {} {
1.72 + global xxx
1.73 + set xxx ""
1.74 + 12days 1 1 1
1.75 + string length $xxx
1.76 +}
1.77 +
1.78 +# start of tests
1.79 +
1.80 +catch {unset a b i x}
1.81 +
1.82 +test compExpr-old-1.1 {TclCompileExprCmd: no expression} {
1.83 + list [catch {expr } msg] $msg
1.84 +} {1 {wrong # args: should be "expr arg ?arg ...?"}}
1.85 +test compExpr-old-1.2 {TclCompileExprCmd: one expression word} {
1.86 + expr -25
1.87 +} -25
1.88 +test compExpr-old-1.3 {TclCompileExprCmd: two expression words} {
1.89 + expr -8.2 -6
1.90 +} -14.2
1.91 +test compExpr-old-1.4 {TclCompileExprCmd: five expression words} {
1.92 + expr 20 - 5 +10 -7
1.93 +} 18
1.94 +test compExpr-old-1.5 {TclCompileExprCmd: quoted expression word} {
1.95 + expr "0005"
1.96 +} 5
1.97 +test compExpr-old-1.6 {TclCompileExprCmd: quoted expression word} {
1.98 + catch {expr "0005"zxy} msg
1.99 + set msg
1.100 +} {extra characters after close-quote}
1.101 +test compExpr-old-1.7 {TclCompileExprCmd: expression word in braces} {
1.102 + expr {-0005}
1.103 +} -5
1.104 +test compExpr-old-1.8 {TclCompileExprCmd: expression word in braces} {
1.105 + expr {{-0x1234}}
1.106 +} -4660
1.107 +test compExpr-old-1.9 {TclCompileExprCmd: expression word in braces} {
1.108 + catch {expr {-0005}foo} msg
1.109 + set msg
1.110 +} {extra characters after close-brace}
1.111 +test compExpr-old-1.10 {TclCompileExprCmd: other expression word in braces} {
1.112 + expr 4*[llength "6 2"]
1.113 +} 8
1.114 +test compExpr-old-1.11 {TclCompileExprCmd: expression word terminated by ;} {
1.115 + expr 4*[llength "6 2"];
1.116 +} 8
1.117 +test compExpr-old-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} {
1.118 + set a xxx
1.119 + catch {
1.120 + # Might not be a number
1.121 + set a [expr 10*$a]
1.122 + }
1.123 +} 1
1.124 +test compExpr-old-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} {
1.125 + set a xxx
1.126 + set x 27; set bool {$x}; if $bool {set a foo}
1.127 + set a
1.128 +} foo
1.129 +test compExpr-old-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} {
1.130 + set a xxx
1.131 + set x 2; set b {$x}; set a [expr $b == 2]
1.132 + set a
1.133 +} 1
1.134 +
1.135 +test compExpr-old-2.1 {TclCompileExpr: are builtin functions registered?} {
1.136 + expr double(5*[llength "6 2"])
1.137 +} 10.0
1.138 +test compExpr-old-2.2 {TclCompileExpr: error in expr} {
1.139 + catch {expr 2**3} msg
1.140 + set msg
1.141 +} {syntax error in expression "2**3": unexpected operator *}
1.142 +test compExpr-old-2.3 {TclCompileExpr: junk after legal expr} {
1.143 + catch {expr 7*[llength "a b"]foo} msg
1.144 + set msg
1.145 +} {syntax error in expression "7*2foo": extra tokens at end of expression}
1.146 +test compExpr-old-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} {
1.147 + expr {0001}
1.148 +} 1
1.149 +
1.150 +test compExpr-old-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
1.151 +test compExpr-old-3.2 {CompileCondExpr: error in lor expr} {
1.152 + catch {expr x||3} msg
1.153 + set msg
1.154 +} {syntax error in expression "x||3": variable references require preceding $}
1.155 +test compExpr-old-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
1.156 +test compExpr-old-3.4 {CompileCondExpr: error compiling true arm} {
1.157 + catch {expr 3>2?2**3:66} msg
1.158 + set msg
1.159 +} {syntax error in expression "3>2?2**3:66": unexpected operator *}
1.160 +test compExpr-old-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66
1.161 +test compExpr-old-3.6 {CompileCondExpr: error compiling false arm} {
1.162 + catch {expr 2>3?44:2**3} msg
1.163 + set msg
1.164 +} {syntax error in expression "2>3?44:2**3": unexpected operator *}
1.165 +test compExpr-old-3.7 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} {
1.166 + puts "Note: doing test compExpr-old-3.7 which can take several minutes to run"
1.167 + hello_world
1.168 +} {Hello world}
1.169 +catch {unset xxx}
1.170 +test compExpr-old-3.8 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} {
1.171 + puts "Note: doing test compExpr-old-3.8 which can take several minutes to run"
1.172 + do_twelve_days
1.173 +} 2358
1.174 +catch {unset xxx}
1.175 +
1.176 +test compExpr-old-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
1.177 +test compExpr-old-4.2 {CompileLorExpr: error in land expr} {
1.178 + catch {expr x&&3} msg
1.179 + set msg
1.180 +} {syntax error in expression "x&&3": variable references require preceding $}
1.181 +test compExpr-old-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
1.182 +test compExpr-old-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
1.183 +test compExpr-old-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
1.184 +test compExpr-old-4.6 {CompileLorExpr: error compiling lor arm} {
1.185 + catch {expr 2**3||4.0} msg
1.186 + set msg
1.187 +} {syntax error in expression "2**3||4.0": unexpected operator *}
1.188 +test compExpr-old-4.7 {CompileLorExpr: error compiling lor arm} {
1.189 + catch {expr 1.3||2**3} msg
1.190 + set msg
1.191 +} {syntax error in expression "1.3||2**3": unexpected operator *}
1.192 +test compExpr-old-4.8 {CompileLorExpr: error compiling lor arms} {
1.193 + list [catch {expr {"a"||"b"}} msg] $msg
1.194 +} {1 {expected boolean value but got "a"}}
1.195 +test compExpr-old-4.9 {CompileLorExpr: long lor arm} {
1.196 + set a "abcdefghijkl"
1.197 + set i 7
1.198 + expr {[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]] || [string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]&&[string compare [format %c $i] [string index $a $i]]}
1.199 +} 1
1.200 +
1.201 +test compExpr-old-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
1.202 +test compExpr-old-5.2 {CompileLandExpr: error in bitor expr} {
1.203 + catch {expr x|3} msg
1.204 + set msg
1.205 +} {syntax error in expression "x|3": variable references require preceding $}
1.206 +test compExpr-old-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
1.207 +test compExpr-old-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
1.208 +test compExpr-old-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
1.209 +test compExpr-old-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1
1.210 +test compExpr-old-5.7 {CompileLandExpr: error compiling land arm} {
1.211 + catch {expr 2**3&&4.0} msg
1.212 + set msg
1.213 +} {syntax error in expression "2**3&&4.0": unexpected operator *}
1.214 +test compExpr-old-5.8 {CompileLandExpr: error compiling land arm} {
1.215 + catch {expr 1.3&&2**3} msg
1.216 + set msg
1.217 +} {syntax error in expression "1.3&&2**3": unexpected operator *}
1.218 +test compExpr-old-5.9 {CompileLandExpr: error compiling land arm} {
1.219 + list [catch {expr {"a"&&"b"}} msg] $msg
1.220 +} {1 {expected boolean value but got "a"}}
1.221 +test compExpr-old-5.10 {CompileLandExpr: long land arms} {
1.222 + set a "abcdefghijkl"
1.223 + set i 7
1.224 + expr {[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]] && [string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]^[string compare [format %c 103] [string index $a $i]]^[string compare [format %c 105] [string index $a $i]]}
1.225 +} 1
1.226 +
1.227 +test compExpr-old-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
1.228 +test compExpr-old-6.2 {CompileBitXorExpr: error in bitand expr} {
1.229 + catch {expr x|3} msg
1.230 + set msg
1.231 +} {syntax error in expression "x|3": variable references require preceding $}
1.232 +test compExpr-old-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
1.233 +test compExpr-old-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
1.234 +test compExpr-old-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
1.235 +test compExpr-old-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8
1.236 +test compExpr-old-6.7 {CompileBitXorExpr: error compiling bitxor arm} {
1.237 + catch {expr 2**3|6} msg
1.238 + set msg
1.239 +} {syntax error in expression "2**3|6": unexpected operator *}
1.240 +test compExpr-old-6.8 {CompileBitXorExpr: error compiling bitxor arm} {
1.241 + catch {expr 2^x} msg
1.242 + set msg
1.243 +} {syntax error in expression "2^x": variable references require preceding $}
1.244 +test compExpr-old-6.9 {CompileBitXorExpr: runtime error in bitxor arm} {
1.245 + list [catch {expr {24.0^3}} msg] $msg
1.246 +} {1 {can't use floating-point value as operand of "^"}}
1.247 +test compExpr-old-6.10 {CompileBitXorExpr: runtime error in bitxor arm} {
1.248 + list [catch {expr {"a"^"b"}} msg] $msg
1.249 +} {1 {can't use non-numeric string as operand of "^"}}
1.250 +
1.251 +test compExpr-old-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
1.252 +test compExpr-old-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
1.253 +test compExpr-old-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
1.254 +test compExpr-old-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
1.255 +test compExpr-old-7.5 {CompileBitAndExpr: error in equality expr} {
1.256 + catch {expr x==3} msg
1.257 + set msg
1.258 +} {syntax error in expression "x==3": variable references require preceding $}
1.259 +test compExpr-old-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
1.260 +test compExpr-old-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
1.261 +test compExpr-old-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
1.262 +test compExpr-old-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7
1.263 +test compExpr-old-7.10 {CompileBitAndExpr: error compiling bitand arm} {
1.264 + catch {expr 2**3&6} msg
1.265 + set msg
1.266 +} {syntax error in expression "2**3&6": unexpected operator *}
1.267 +test compExpr-old-7.11 {CompileBitAndExpr: error compiling bitand arm} {
1.268 + catch {expr 2&x} msg
1.269 + set msg
1.270 +} {syntax error in expression "2&x": variable references require preceding $}
1.271 +test compExpr-old-7.12 {CompileBitAndExpr: runtime error in bitand arm} {
1.272 + list [catch {expr {24.0&3}} msg] $msg
1.273 +} {1 {can't use floating-point value as operand of "&"}}
1.274 +test compExpr-old-7.13 {CompileBitAndExpr: runtime error in bitand arm} {
1.275 + list [catch {expr {"a"&"b"}} msg] $msg
1.276 +} {1 {can't use non-numeric string as operand of "&"}}
1.277 +
1.278 +test compExpr-old-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
1.279 +test compExpr-old-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
1.280 +test compExpr-old-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
1.281 +test compExpr-old-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
1.282 +test compExpr-old-8.5 {CompileEqualityExpr: error in relational expr} {
1.283 + catch {expr x>3} msg
1.284 + set msg
1.285 +} {syntax error in expression "x>3": variable references require preceding $}
1.286 +test compExpr-old-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
1.287 +test compExpr-old-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
1.288 +test compExpr-old-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
1.289 +test compExpr-old-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1
1.290 +test compExpr-old-8.10 {CompileEqualityExpr: error compiling equality arm} {
1.291 + catch {expr 2**3==6} msg
1.292 + set msg
1.293 +} {syntax error in expression "2**3==6": unexpected operator *}
1.294 +test compExpr-old-8.11 {CompileEqualityExpr: error compiling equality arm} {
1.295 + catch {expr 2!=x} msg
1.296 + set msg
1.297 +} {syntax error in expression "2!=x": variable references require preceding $}
1.298 +
1.299 +
1.300 +test compExpr-old-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
1.301 +test compExpr-old-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
1.302 +test compExpr-old-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
1.303 +test compExpr-old-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8
1.304 +
1.305 +# The following test is different for 32-bit versus 64-bit
1.306 +# architectures because LONG_MIN is different
1.307 +
1.308 +if {0x80000000 > 0} {
1.309 + test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
1.310 + expr {1<<63}
1.311 + } -9223372036854775808
1.312 +} else {
1.313 + test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
1.314 + expr {1<<31}
1.315 + } -2147483648
1.316 +}
1.317 +test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} {
1.318 + catch {expr x>>3} msg
1.319 + set msg
1.320 +} {syntax error in expression "x>>3": variable references require preceding $}
1.321 +test compExpr-old-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
1.322 +test compExpr-old-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
1.323 +test compExpr-old-9.9 {CompileRelationalExpr: error compiling relational arm} {
1.324 + catch {expr 2**3>6} msg
1.325 + set msg
1.326 +} {syntax error in expression "2**3>6": unexpected operator *}
1.327 +test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} {
1.328 + catch {expr 2<x} msg
1.329 + set msg
1.330 +} {syntax error in expression "2<x": variable references require preceding $}
1.331 +
1.332 +test compExpr-old-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
1.333 +test compExpr-old-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
1.334 +test compExpr-old-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
1.335 +test compExpr-old-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
1.336 +test compExpr-old-10.5 {CompileShiftExpr: error in add expr} {
1.337 + catch {expr x+3} msg
1.338 + set msg
1.339 +} {syntax error in expression "x+3": variable references require preceding $}
1.340 +test compExpr-old-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
1.341 +test compExpr-old-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
1.342 +test compExpr-old-10.8 {CompileShiftExpr: error compiling shift arm} {
1.343 + catch {expr 2**3>>6} msg
1.344 + set msg
1.345 +} {syntax error in expression "2**3>>6": unexpected operator *}
1.346 +test compExpr-old-10.9 {CompileShiftExpr: error compiling shift arm} {
1.347 + catch {expr 2<<x} msg
1.348 + set msg
1.349 +} {syntax error in expression "2<<x": variable references require preceding $}
1.350 +test compExpr-old-10.10 {CompileShiftExpr: runtime error} {
1.351 + list [catch {expr {24.0>>43}} msg] $msg
1.352 +} {1 {can't use floating-point value as operand of ">>"}}
1.353 +test compExpr-old-10.11 {CompileShiftExpr: runtime error} {
1.354 + list [catch {expr {"a"<<"b"}} msg] $msg
1.355 +} {1 {can't use non-numeric string as operand of "<<"}}
1.356 +
1.357 +test compExpr-old-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
1.358 +test compExpr-old-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
1.359 +test compExpr-old-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
1.360 +test compExpr-old-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
1.361 +test compExpr-old-11.5 {CompileAddExpr: error in multiply expr} {
1.362 + catch {expr x*3} msg
1.363 + set msg
1.364 +} {syntax error in expression "x*3": variable references require preceding $}
1.365 +test compExpr-old-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
1.366 +test compExpr-old-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
1.367 +test compExpr-old-11.8 {CompileAddExpr: error compiling add arm} {
1.368 + catch {expr 2**3+6} msg
1.369 + set msg
1.370 +} {syntax error in expression "2**3+6": unexpected operator *}
1.371 +test compExpr-old-11.9 {CompileAddExpr: error compiling add arm} {
1.372 + catch {expr 2-x} msg
1.373 + set msg
1.374 +} {syntax error in expression "2-x": variable references require preceding $}
1.375 +test compExpr-old-11.10 {CompileAddExpr: runtime error} {
1.376 + list [catch {expr {24.0+"xx"}} msg] $msg
1.377 +} {1 {can't use non-numeric string as operand of "+"}}
1.378 +test compExpr-old-11.11 {CompileAddExpr: runtime error} {
1.379 + list [catch {expr {"a"-"b"}} msg] $msg
1.380 +} {1 {can't use non-numeric string as operand of "-"}}
1.381 +test compExpr-old-11.12 {CompileAddExpr: runtime error} {
1.382 + list [catch {expr {3/0}} msg] $msg
1.383 +} {1 {divide by zero}}
1.384 +test compExpr-old-11.13 {CompileAddExpr: runtime error} {
1.385 + list [catch {expr {2.3/0.0}} msg] $msg
1.386 +} {1 {divide by zero}}
1.387 +
1.388 +test compExpr-old-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
1.389 +test compExpr-old-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
1.390 +test compExpr-old-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
1.391 +test compExpr-old-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
1.392 +test compExpr-old-12.5 {CompileMultiplyExpr: error in unary expr} {
1.393 + catch {expr ~x} msg
1.394 + set msg
1.395 +} {syntax error in expression "~x": variable references require preceding $}
1.396 +test compExpr-old-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
1.397 +test compExpr-old-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
1.398 +test compExpr-old-12.8 {CompileMultiplyExpr: error compiling multiply arm} {
1.399 + catch {expr 2*3%%6} msg
1.400 + set msg
1.401 +} {syntax error in expression "2*3%%6": unexpected operator %}
1.402 +test compExpr-old-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
1.403 + catch {expr 2*x} msg
1.404 + set msg
1.405 +} {syntax error in expression "2*x": variable references require preceding $}
1.406 +test compExpr-old-12.10 {CompileMultiplyExpr: runtime error} {
1.407 + list [catch {expr {24.0*"xx"}} msg] $msg
1.408 +} {1 {can't use non-numeric string as operand of "*"}}
1.409 +test compExpr-old-12.11 {CompileMultiplyExpr: runtime error} {
1.410 + list [catch {expr {"a"/"b"}} msg] $msg
1.411 +} {1 {can't use non-numeric string as operand of "/"}}
1.412 +
1.413 +test compExpr-old-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
1.414 +test compExpr-old-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
1.415 +test compExpr-old-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
1.416 +test compExpr-old-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
1.417 +test compExpr-old-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
1.418 +test compExpr-old-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
1.419 +test compExpr-old-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
1.420 +test compExpr-old-13.8 {CompileUnaryExpr: error compiling unary expr} {
1.421 + catch {expr ~x} msg
1.422 + set msg
1.423 +} {syntax error in expression "~x": variable references require preceding $}
1.424 +test compExpr-old-13.9 {CompileUnaryExpr: error compiling unary expr} {
1.425 + catch {expr !1.x} msg
1.426 + set msg
1.427 +} {syntax error in expression "!1.x": extra tokens at end of expression}
1.428 +test compExpr-old-13.10 {CompileUnaryExpr: runtime error} {
1.429 + list [catch {expr {~"xx"}} msg] $msg
1.430 +} {1 {can't use non-numeric string as operand of "~"}}
1.431 +test compExpr-old-13.11 {CompileUnaryExpr: runtime error} {
1.432 + list [catch {expr ~4.0} msg] $msg
1.433 +} {1 {can't use floating-point value as operand of "~"}}
1.434 +test compExpr-old-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291
1.435 +test compExpr-old-13.13 {CompileUnaryExpr: just primary expr} {
1.436 + set a 27
1.437 + expr $a
1.438 +} 27
1.439 +test compExpr-old-13.14 {CompileUnaryExpr: just primary expr} {
1.440 + expr double(27)
1.441 +} 27.0
1.442 +test compExpr-old-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123
1.443 +test compExpr-old-13.16 {CompileUnaryExpr: error in primary expr} {
1.444 + catch {expr [set]} msg
1.445 + set msg
1.446 +} {wrong # args: should be "set varName ?newValue?"}
1.447 +test compExpr-old-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
1.448 +test compExpr-old-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
1.449 +test compExpr-old-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
1.450 +test compExpr-old-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
1.451 +test compExpr-old-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
1.452 +test compExpr-old-14.6 {CompilePrimaryExpr: literal primary} {
1.453 + expr 3.1400000
1.454 +} 3.14
1.455 +test compExpr-old-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1
1.456 +test compExpr-old-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\
1.457 +def} < {abcdef}}} 1
1.458 +test compExpr-old-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0
1.459 +test compExpr-old-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123
1.460 +test compExpr-old-14.11 {CompilePrimaryExpr: var reference primary} {
1.461 + set i 789
1.462 + list [expr {$i}] [expr $i]
1.463 +} {789 789}
1.464 +test compExpr-old-14.12 {CompilePrimaryExpr: var reference primary} {
1.465 + set i {789} ;# test expr's aggressive conversion to numeric semantics
1.466 + list [expr {$i}] [expr $i]
1.467 +} {789 789}
1.468 +test compExpr-old-14.13 {CompilePrimaryExpr: var reference primary} {
1.469 + catch {unset a}
1.470 + set a(foo) foo
1.471 + set a(bar) bar
1.472 + set a(123) 123
1.473 + set result ""
1.474 + lappend result [expr $a(123)] [expr {$a(bar)<$a(foo)}]
1.475 + catch {unset a}
1.476 + set result
1.477 +} {123 1}
1.478 +test compExpr-old-14.14 {CompilePrimaryExpr: var reference primary} {
1.479 + set i 123 ;# test "$var.0" floating point conversion hack
1.480 + list [expr $i] [expr $i.0] [expr $i.0/12.0]
1.481 +} {123 123.0 10.25}
1.482 +test compExpr-old-14.15 {CompilePrimaryExpr: var reference primary} {
1.483 + set i 123
1.484 + catch {expr $i.2} msg
1.485 + set msg
1.486 +} 123.2
1.487 +test compExpr-old-14.16 {CompilePrimaryExpr: error compiling var reference primary} {
1.488 + catch {expr {$a(foo}} msg
1.489 + set errorInfo
1.490 +} {missing )
1.491 + while compiling
1.492 +"expr {$a(foo}"}
1.493 +test compExpr-old-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {
1.494 + expr $
1.495 +} $
1.496 +test compExpr-old-14.18 {CompilePrimaryExpr: quoted string primary} {
1.497 + expr "21"
1.498 +} 21
1.499 +test compExpr-old-14.19 {CompilePrimaryExpr: quoted string primary} {
1.500 + set i 123
1.501 + set x 456
1.502 + expr "$i+$x"
1.503 +} 579
1.504 +test compExpr-old-14.20 {CompilePrimaryExpr: quoted string primary} {
1.505 + set i 3
1.506 + set x 6
1.507 + expr 2+"$i.$x"
1.508 +} 5.6
1.509 +test compExpr-old-14.21 {CompilePrimaryExpr: error in quoted string primary} {
1.510 + catch {expr "[set]"} msg
1.511 + set msg
1.512 +} {wrong # args: should be "set varName ?newValue?"}
1.513 +test compExpr-old-14.22 {CompilePrimaryExpr: subcommand primary} {
1.514 + expr {[set i 123; set i]}
1.515 +} 123
1.516 +test compExpr-old-14.23 {CompilePrimaryExpr: error in subcommand primary} {
1.517 + catch {expr {[set]}} msg
1.518 + set errorInfo
1.519 +} {wrong # args: should be "set varName ?newValue?"
1.520 + while compiling
1.521 +"set"
1.522 + while compiling
1.523 +"expr {[set]}"}
1.524 +test compExpr-old-14.24 {CompilePrimaryExpr: error in subcommand primary} {
1.525 + catch {expr {[set i}} msg
1.526 + set errorInfo
1.527 +} {missing close-bracket
1.528 + while compiling
1.529 +"expr {[set i}"}
1.530 +test compExpr-old-14.25 {CompilePrimaryExpr: math function primary} {
1.531 + format %.6g [expr exp(1.0)]
1.532 +} 2.71828
1.533 +test compExpr-old-14.26 {CompilePrimaryExpr: math function primary} {
1.534 + format %.6g [expr pow(2.0+0.1,3.0+0.1)]
1.535 +} 9.97424
1.536 +test compExpr-old-14.27 {CompilePrimaryExpr: error in math function primary} {
1.537 + catch {expr sinh::(2.0)} msg
1.538 + set errorInfo
1.539 +} {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments
1.540 + while compiling
1.541 +"expr sinh::(2.0)"}
1.542 +test compExpr-old-14.28 {CompilePrimaryExpr: subexpression primary} {
1.543 + expr 2+(3*4)
1.544 +} 14
1.545 +test compExpr-old-14.29 {CompilePrimaryExpr: error in subexpression primary} {
1.546 + catch {expr 2+(3*[set])} msg
1.547 + set errorInfo
1.548 +} {wrong # args: should be "set varName ?newValue?"
1.549 + while compiling
1.550 +"set"
1.551 + while compiling
1.552 +"expr 2+(3*[set])"}
1.553 +test compExpr-old-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} {
1.554 + catch {expr 2+(3*(4+5)} msg
1.555 + set errorInfo
1.556 +} {syntax error in expression "2+(3*(4+5)": looking for close parenthesis
1.557 + while compiling
1.558 +"expr 2+(3*(4+5)"}
1.559 +test compExpr-old-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
1.560 + set i "5+10"
1.561 + list "[expr $i] == 15" "[expr ($i)] == 15" "[eval expr ($i)] == 15"
1.562 +} {{15 == 15} {15 == 15} {15 == 15}}
1.563 +test compExpr-old-14.32 {CompilePrimaryExpr: unexpected token} {
1.564 + catch {expr @} msg
1.565 + set errorInfo
1.566 +} {syntax error in expression "@": character not legal in expressions
1.567 + while compiling
1.568 +"expr @"}
1.569 +
1.570 +test compExpr-old-15.1 {CompileMathFuncCall: missing parenthesis} {
1.571 + catch {expr sinh2.0)} msg
1.572 + set errorInfo
1.573 +} {syntax error in expression "sinh2.0)": variable references require preceding $
1.574 + while compiling
1.575 +"expr sinh2.0)"}
1.576 +test compExpr-old-15.2 {CompileMathFuncCall: unknown math function} {
1.577 + catch {expr whazzathuh(1)} msg
1.578 + set errorInfo
1.579 +} {unknown math function "whazzathuh"
1.580 + while compiling
1.581 +"expr whazzathuh(1)"}
1.582 +test compExpr-old-15.3 {CompileMathFuncCall: too many arguments} {
1.583 + catch {expr sin(1,2,3)} msg
1.584 + set errorInfo
1.585 +} {too many arguments for math function
1.586 + while compiling
1.587 +"expr sin(1,2,3)"}
1.588 +test compExpr-old-15.4 {CompileMathFuncCall: ')' found before last required arg} {
1.589 + catch {expr sin()} msg
1.590 + set errorInfo
1.591 +} {too few arguments for math function
1.592 + while compiling
1.593 +"expr sin()"}
1.594 +test compExpr-old-15.5 {CompileMathFuncCall: too few arguments} {
1.595 + catch {expr pow(1)} msg
1.596 + set errorInfo
1.597 +} {too few arguments for math function
1.598 + while compiling
1.599 +"expr pow(1)"}
1.600 +test compExpr-old-15.6 {CompileMathFuncCall: missing ')'} {
1.601 + catch {expr sin(1} msg
1.602 + set errorInfo
1.603 +} {syntax error in expression "sin(1": missing close parenthesis at end of function call
1.604 + while compiling
1.605 +"expr sin(1"}
1.606 +if $gotT1 {
1.607 + test compExpr-old-15.7 {CompileMathFuncCall: call registered math function} {
1.608 + expr 2*T1()
1.609 + } 246
1.610 + test compExpr-old-15.8 {CompileMathFuncCall: call registered math function} {
1.611 + expr T2()*3
1.612 + } 1035
1.613 +
1.614 + test compExpr-old-15.9 {CompileMathFuncCall: call registered math function} {
1.615 + expr T3(21, 37)
1.616 + } 37
1.617 + test compExpr-old-15.10 {CompileMathFuncCall: call registered math function} {
1.618 + expr T3(21.2, 37)
1.619 + } 37.0
1.620 + test compExpr-old-15.11 {CompileMathFuncCall: call registered math function} {
1.621 + expr T3(-21.2, -17.5)
1.622 + } -17.5
1.623 +}
1.624 +
1.625 +test compExpr-old-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} {
1.626 + catch {unset a}
1.627 + set a(VALUE) ff15
1.628 + set i 123
1.629 + if {[expr 0x$a(VALUE)] & 16} {
1.630 + set i {}
1.631 + }
1.632 + set i
1.633 +} {}
1.634 +test compExpr-old-16.2 {GetToken: check for string literal in braces} {
1.635 + expr {{1}}
1.636 +} {1}
1.637 +
1.638 +# Check "expr" and computed command names.
1.639 +
1.640 +test compExpr-old-17.1 {expr and computed command names} {
1.641 + set i 0
1.642 + set z expr
1.643 + $z 1+2
1.644 +} 3
1.645 +
1.646 +# Check correct conversion of operands to numbers: If the string looks like
1.647 +# an integer, convert to integer. Otherwise, if the string looks like a
1.648 +# double, convert to double.
1.649 +
1.650 +test compExpr-old-18.1 {expr and conversion of operands to numbers} {
1.651 + set x [lindex 11 0]
1.652 + catch {expr int($x)}
1.653 + expr {$x}
1.654 +} 11
1.655 +
1.656 +# Check "expr" and interpreter result object resetting before appending
1.657 +# an error msg during evaluation of exprs not in {}s
1.658 +
1.659 +test compExpr-old-19.1 {expr and interpreter result object resetting} {
1.660 + proc p {} {
1.661 + set t 10.0
1.662 + set x 2.0
1.663 + set dx 0.2
1.664 + set f {$dx-$x/10}
1.665 + set g {-$x/5}
1.666 + set center 1.0
1.667 + set x [expr $x-$center]
1.668 + set dx [expr $dx+$g]
1.669 + set x [expr $x+$f+$center]
1.670 + set x [expr $x+$f+$center]
1.671 + set y [expr round($x)]
1.672 + }
1.673 + p
1.674 +} 3
1.675 +
1.676 +# cleanup
1.677 +if {[info exists a]} {
1.678 + unset a
1.679 +}
1.680 +::tcltest::cleanupTests
1.681 +return