os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/expr.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/expr.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,930 @@
     1.4 +# Commands covered: expr
     1.5 +#
     1.6 +# This file contains a collection of tests for one or more of the Tcl
     1.7 +# built-in commands. Sourcing this file into Tcl runs the tests and
     1.8 +# generates output for errors.  No output means no errors were found.
     1.9 +#
    1.10 +# Copyright (c) 1996-1997 Sun Microsystems, Inc.
    1.11 +# Copyright (c) 1998-2000 by Scriptics Corporation.
    1.12 +#
    1.13 +# See the file "license.terms" for information on usage and redistribution
    1.14 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1.15 +#
    1.16 +# RCS: @(#) $Id: expr.test,v 1.17.2.12 2006/03/23 16:40:32 dgp Exp $
    1.17 +
    1.18 +if {[lsearch [namespace children] ::tcltest] == -1} {
    1.19 +    package require tcltest
    1.20 +    namespace import -force ::tcltest::*
    1.21 +}
    1.22 +
    1.23 +testConstraint registeredMathFuncs [expr {
    1.24 +    ([catch {expr T1()} msg] != 1) || ($msg ne {unknown math function "T1"})
    1.25 +}]
    1.26 +
    1.27 +testConstraint wideIs64bit [expr {(0x80000000 > 0) && (0x8000000000000000 < 0)}]
    1.28 +# procedures used below
    1.29 +
    1.30 +proc put_hello_char {c} {
    1.31 +    global a
    1.32 +    append a [format %c $c]
    1.33 +    return $c
    1.34 +}
    1.35 +proc hello_world {} {
    1.36 +    global a
    1.37 +    set a ""
    1.38 +    set L1 [set l0 [set h_1 [set q 0]]]
    1.39 +    for {put_hello_char [expr [put_hello_char [expr [set h 7]*10+2]]+29]} {$l0?[put_hello_char $l0]
    1.40 +        :!$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.41 +        ?[set ll [set l0 [expr 54<<1]]]:$ll==108&&$L1<3?
    1.42 +        [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.43 +        :[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.44 +        ?[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.45 +        expr {$L1!=1<<3?[incr q [expr ([string length "abc"]-[string length "abc"])-1]]:[set h_1 [set ll $h1]]}
    1.46 +    }
    1.47 +    set a
    1.48 +}
    1.49 +
    1.50 +proc 12days {a b c} {
    1.51 +    global xxx
    1.52 +    expr {1<$a?[expr {$a<3?[12days -79 -13 [string range $c [12days -87 \
    1.53 +	[expr 1-$b] [string range $c [12days -86 0 [string range $c 1 end]] \
    1.54 +	end]] end]]:1};expr {$a<$b?[12days [expr $a+1] $b $c]:3};expr {[12days \
    1.55 +	-94 [expr $a-27] $c]&&$a==2?$b<13?[12days 2 [expr $b+1] "%s %d %d\n"]:9
    1.56 +	: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.57 +	:$a<-50?[string compare [format %c $b] [string index $c 0]]==0?[append \
    1.58 +	xxx [string index $c 31];scan [string index $c 31] %c x;set x]
    1.59 +	:[12days -65 $b [string range $c 1 end]]:[12days [expr ([string compare \
    1.60 +	[string index $c 0] "/"]==0)+$a] $b [string range $c 1 end]]:0<$a
    1.61 +	?[12days 2 2 "%s"]:[string compare [string index $c 0] "/"]==0||
    1.62 +	[12days 0 [12days -61 [scan [string index $c 0] %c x; set x] \
    1.63 +	"!ek;dc i@bK'(q)-\[w\]*%n+r3#l,\{\}:\nuwloca-O;m .vpbks,fxntdCeghiry"] \
    1.64 +	[string range $c 1 end]]}
    1.65 +}
    1.66 +proc do_twelve_days {} {
    1.67 +    global xxx
    1.68 +    set xxx ""
    1.69 +    12days 1 1 1
    1.70 +    string length $xxx
    1.71 +}
    1.72 +
    1.73 +# start of tests
    1.74 +
    1.75 +catch {unset a b i x}
    1.76 +
    1.77 +test expr-1.1 {TclCompileExprCmd: no expression} {
    1.78 +    list [catch {expr  } msg] $msg
    1.79 +} {1 {wrong # args: should be "expr arg ?arg ...?"}}
    1.80 +test expr-1.2 {TclCompileExprCmd: one expression word} {
    1.81 +    expr -25
    1.82 +} -25
    1.83 +test expr-1.3 {TclCompileExprCmd: two expression words} {
    1.84 +    expr -8.2   -6
    1.85 +} -14.2
    1.86 +test expr-1.4 {TclCompileExprCmd: five expression words} {
    1.87 +    expr 20 - 5 +10 -7
    1.88 +} 18
    1.89 +test expr-1.5 {TclCompileExprCmd: quoted expression word} {
    1.90 +    expr "0005"
    1.91 +} 5
    1.92 +test expr-1.6 {TclCompileExprCmd: quoted expression word} {
    1.93 +    catch {expr "0005"zxy} msg
    1.94 +    set msg
    1.95 +} {extra characters after close-quote}
    1.96 +test expr-1.7 {TclCompileExprCmd: expression word in braces} {
    1.97 +    expr {-0005}
    1.98 +} -5
    1.99 +test expr-1.8 {TclCompileExprCmd: expression word in braces} {
   1.100 +    expr {{-0x1234}}
   1.101 +} -4660
   1.102 +test expr-1.9 {TclCompileExprCmd: expression word in braces} {
   1.103 +    catch {expr {-0005}foo} msg
   1.104 +    set msg
   1.105 +} {extra characters after close-brace}
   1.106 +test expr-1.10 {TclCompileExprCmd: other expression word in braces} {
   1.107 +    expr 4*[llength "6 2"]
   1.108 +} 8
   1.109 +test expr-1.11 {TclCompileExprCmd: expression word terminated by ;} {
   1.110 +    expr 4*[llength "6 2"];
   1.111 +} 8
   1.112 +test expr-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} {
   1.113 +    set a xxx
   1.114 +    catch {
   1.115 +	# Might not be a number
   1.116 +	set a [expr 10*$a]
   1.117 +    }
   1.118 +} 1
   1.119 +test expr-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} {
   1.120 +    set a xxx
   1.121 +    set x 27;  set bool {$x};  if $bool {set a foo}
   1.122 +    set a
   1.123 +} foo
   1.124 +test expr-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} {
   1.125 +    set a xxx
   1.126 +    set x 2;  set b {$x};  set a [expr $b == 2]
   1.127 +    set a
   1.128 +} 1
   1.129 +test expr-1.15 {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 eq 2]
   1.132 +    set a
   1.133 +} 1
   1.134 +
   1.135 +test expr-2.1 {TclCompileExpr: are builtin functions registered?} {
   1.136 +    expr double(5*[llength "6 2"])
   1.137 +} 10.0
   1.138 +test expr-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 expr-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 expr-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} {
   1.147 +    expr {0001}
   1.148 +} 1
   1.149 +
   1.150 +test expr-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
   1.151 +test expr-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 expr-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
   1.156 +test expr-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 expr-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66
   1.161 +test expr-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 expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} {
   1.166 +    puts "Note: doing test expr-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 expr-3.8 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} {
   1.171 +    puts "Note: doing test expr-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 expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
   1.177 +test expr-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 expr-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
   1.182 +test expr-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
   1.183 +test expr-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
   1.184 +test expr-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 expr-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 expr-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 expr-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 expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
   1.202 +test expr-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 expr-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
   1.207 +test expr-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
   1.208 +test expr-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
   1.209 +test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1
   1.210 +test expr-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 expr-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 expr-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 expr-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 expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
   1.228 +test expr-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 expr-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
   1.233 +test expr-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
   1.234 +test expr-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
   1.235 +test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8
   1.236 +test expr-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 expr-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 expr-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 expr-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 expr-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
   1.252 +test expr-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
   1.253 +test expr-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
   1.254 +test expr-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
   1.255 +test expr-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 expr-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
   1.260 +test expr-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
   1.261 +test expr-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
   1.262 +test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7
   1.263 +test expr-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 expr-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 expr-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 expr-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 +test expr-7.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0
   1.278 +test expr-7.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0
   1.279 +test expr-7.20 {CompileBitAndExpr: error in equality expr} {
   1.280 +    catch {expr xne3} msg
   1.281 +    set msg
   1.282 +} {syntax error in expression "xne3": variable references require preceding $} 
   1.283 +
   1.284 +test expr-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
   1.285 +test expr-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
   1.286 +test expr-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
   1.287 +test expr-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
   1.288 +test expr-8.5 {CompileEqualityExpr: error in relational expr} {
   1.289 +    catch {expr x>3} msg
   1.290 +    set msg
   1.291 +} {syntax error in expression "x>3": variable references require preceding $}
   1.292 +test expr-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
   1.293 +test expr-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
   1.294 +test expr-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
   1.295 +test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1
   1.296 +test expr-8.10 {CompileEqualityExpr: error compiling equality arm} {
   1.297 +    catch {expr 2**3==6} msg
   1.298 +    set msg
   1.299 +} {syntax error in expression "2**3==6": unexpected operator *}
   1.300 +test expr-8.11 {CompileEqualityExpr: error compiling equality arm} {
   1.301 +    catch {expr 2!=x} msg
   1.302 +    set msg
   1.303 +} {syntax error in expression "2!=x": variable references require preceding $}
   1.304 +test expr-8.12 {CompileBitAndExpr: equality expr} {expr {"a"eq"a"}} 1
   1.305 +test expr-8.13 {CompileBitAndExpr: equality expr} {expr {"\374" eq "ü"}} 1
   1.306 +test expr-8.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0
   1.307 +test expr-8.15 {CompileBitAndExpr: equality expr} {expr 2.0eq2} 0
   1.308 +test expr-8.16 {CompileBitAndExpr: equality expr} {expr 3.2ne2.2} 1
   1.309 +test expr-8.17 {CompileBitAndExpr: equality expr} {expr 01eq1} 0
   1.310 +test expr-8.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0
   1.311 +test expr-8.19 {CompileBitAndExpr: equality expr} {expr {"abc" ne "abd"}} 1
   1.312 +test expr-8.20 {CompileBitAndExpr: error in equality expr} {
   1.313 +    catch {expr x ne3} msg
   1.314 +    set msg
   1.315 +} {syntax error in expression "x ne3": variable references require preceding $} 
   1.316 +test expr-8.21 {CompileBitAndExpr: error in equality expr} {
   1.317 +    # These should be ""ed to avoid the error
   1.318 +    catch {expr a eq b} msg
   1.319 +    set msg
   1.320 +} {syntax error in expression "a eq b": variable references require preceding $}
   1.321 +
   1.322 +test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
   1.323 +test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
   1.324 +test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
   1.325 +test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8
   1.326 +
   1.327 +# The following test is different for 32-bit versus 64-bit
   1.328 +# architectures because LONG_MIN is different
   1.329 +
   1.330 +if {0x80000000 > 0} {
   1.331 +    test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
   1.332 +	expr {1<<63}
   1.333 +    } -9223372036854775808
   1.334 +} else {
   1.335 +    test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
   1.336 +	expr {1<<31}
   1.337 +    } -2147483648
   1.338 +}
   1.339 +test expr-9.6 {CompileRelationalExpr: error in shift expr} {
   1.340 +    catch {expr x>>3} msg
   1.341 +    set msg
   1.342 +} {syntax error in expression "x>>3": variable references require preceding $}
   1.343 +test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
   1.344 +test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
   1.345 +test expr-9.9 {CompileRelationalExpr: error compiling relational arm} {
   1.346 +    catch {expr 2**3>6} msg
   1.347 +    set msg
   1.348 +} {syntax error in expression "2**3>6": unexpected operator *}
   1.349 +test expr-9.10 {CompileRelationalExpr: error compiling relational arm} {
   1.350 +    catch {expr 2<x} msg
   1.351 +    set msg
   1.352 +} {syntax error in expression "2<x": variable references require preceding $}
   1.353 +
   1.354 +test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
   1.355 +test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
   1.356 +test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
   1.357 +test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
   1.358 +test expr-10.5 {CompileShiftExpr: error in add expr} {
   1.359 +    catch {expr x+3} msg
   1.360 +    set msg
   1.361 +} {syntax error in expression "x+3": variable references require preceding $}
   1.362 +test expr-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
   1.363 +test expr-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
   1.364 +test expr-10.8 {CompileShiftExpr: error compiling shift arm} {
   1.365 +    catch {expr 2**3>>6} msg
   1.366 +    set msg
   1.367 +} {syntax error in expression "2**3>>6": unexpected operator *}
   1.368 +test expr-10.9 {CompileShiftExpr: error compiling shift arm} {
   1.369 +    catch {expr 2<<x} msg
   1.370 +    set msg
   1.371 +} {syntax error in expression "2<<x": variable references require preceding $}
   1.372 +test expr-10.10 {CompileShiftExpr: runtime error} {
   1.373 +    list [catch {expr {24.0>>43}} msg] $msg
   1.374 +} {1 {can't use floating-point value as operand of ">>"}}
   1.375 +test expr-10.11 {CompileShiftExpr: runtime error} {
   1.376 +    list [catch {expr {"a"<<"b"}} msg] $msg
   1.377 +} {1 {can't use non-numeric string as operand of "<<"}}
   1.378 +
   1.379 +test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
   1.380 +test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
   1.381 +test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
   1.382 +test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
   1.383 +test expr-11.5 {CompileAddExpr: error in multiply expr} {
   1.384 +    catch {expr x*3} msg
   1.385 +    set msg
   1.386 +} {syntax error in expression "x*3": variable references require preceding $}
   1.387 +test expr-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
   1.388 +test expr-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
   1.389 +test expr-11.8 {CompileAddExpr: error compiling add arm} {
   1.390 +    catch {expr 2**3+6} msg
   1.391 +    set msg
   1.392 +} {syntax error in expression "2**3+6": unexpected operator *}
   1.393 +test expr-11.9 {CompileAddExpr: error compiling add arm} {
   1.394 +    catch {expr 2-x} msg
   1.395 +    set msg
   1.396 +} {syntax error in expression "2-x": variable references require preceding $}
   1.397 +test expr-11.10 {CompileAddExpr: runtime error} {
   1.398 +    list [catch {expr {24.0+"xx"}} msg] $msg
   1.399 +} {1 {can't use non-numeric string as operand of "+"}}
   1.400 +test expr-11.11 {CompileAddExpr: runtime error} {
   1.401 +    list [catch {expr {"a"-"b"}} msg] $msg
   1.402 +} {1 {can't use non-numeric string as operand of "-"}}
   1.403 +test expr-11.12 {CompileAddExpr: runtime error} {
   1.404 +    list [catch {expr {3/0}} msg] $msg
   1.405 +} {1 {divide by zero}}
   1.406 +test expr-11.13 {CompileAddExpr: runtime error} {
   1.407 +    list [catch {expr {2.3/0.0}} msg] $msg
   1.408 +} {1 {divide by zero}}
   1.409 +
   1.410 +test expr-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
   1.411 +test expr-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
   1.412 +test expr-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
   1.413 +test expr-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
   1.414 +test expr-12.5 {CompileMultiplyExpr: error in unary expr} {
   1.415 +    catch {expr ~x} msg
   1.416 +    set msg
   1.417 +} {syntax error in expression "~x": variable references require preceding $}
   1.418 +test expr-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
   1.419 +test expr-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
   1.420 +test expr-12.8 {CompileMultiplyExpr: error compiling multiply arm} {
   1.421 +    catch {expr 2*3%%6} msg
   1.422 +    set msg
   1.423 +} {syntax error in expression "2*3%%6": unexpected operator %}
   1.424 +test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
   1.425 +    catch {expr 2*x} msg
   1.426 +    set msg
   1.427 +} {syntax error in expression "2*x": variable references require preceding $}
   1.428 +test expr-12.10 {CompileMultiplyExpr: runtime error} {
   1.429 +    list [catch {expr {24.0*"xx"}} msg] $msg
   1.430 +} {1 {can't use non-numeric string as operand of "*"}}
   1.431 +test expr-12.11 {CompileMultiplyExpr: runtime error} {
   1.432 +    list [catch {expr {"a"/"b"}} msg] $msg
   1.433 +} {1 {can't use non-numeric string as operand of "/"}}
   1.434 +
   1.435 +test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
   1.436 +test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
   1.437 +test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
   1.438 +test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
   1.439 +test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
   1.440 +test expr-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
   1.441 +test expr-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
   1.442 +test expr-13.8 {CompileUnaryExpr: error compiling unary expr} {
   1.443 +    catch {expr ~x} msg
   1.444 +    set msg
   1.445 +} {syntax error in expression "~x": variable references require preceding $}
   1.446 +test expr-13.9 {CompileUnaryExpr: error compiling unary expr} {
   1.447 +    catch {expr !1.x} msg
   1.448 +    set msg
   1.449 +} {syntax error in expression "!1.x": extra tokens at end of expression}
   1.450 +test expr-13.10 {CompileUnaryExpr: runtime error} {
   1.451 +    list [catch {expr {~"xx"}} msg] $msg
   1.452 +} {1 {can't use non-numeric string as operand of "~"}}
   1.453 +test expr-13.11 {CompileUnaryExpr: runtime error} {
   1.454 +    list [catch {expr ~4.0} msg] $msg
   1.455 +} {1 {can't use floating-point value as operand of "~"}}
   1.456 +test expr-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291
   1.457 +test expr-13.13 {CompileUnaryExpr: just primary expr} {
   1.458 +    set a 27
   1.459 +    expr $a
   1.460 +} 27
   1.461 +test expr-13.14 {CompileUnaryExpr: just primary expr} {
   1.462 +    expr double(27)
   1.463 +} 27.0
   1.464 +test expr-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123
   1.465 +test expr-13.16 {CompileUnaryExpr: error in primary expr} {
   1.466 +    catch {expr [set]} msg
   1.467 +    set msg
   1.468 +} {wrong # args: should be "set varName ?newValue?"}
   1.469 +test expr-13.17 {CompileUnaryExpr: negating non-numeric boolean literals} {
   1.470 +    set a1 yes; set a0 no; set b1 true; set b0 false
   1.471 +    list [expr {!$a1}] [expr {!$a0}] [expr {!$b1}] [expr {!$b0}]
   1.472 +} {0 1 0 1}
   1.473 +
   1.474 +test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
   1.475 +test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
   1.476 +test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
   1.477 +test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
   1.478 +test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
   1.479 +test expr-14.6 {CompilePrimaryExpr: literal primary} {
   1.480 +    expr 3.1400000
   1.481 +} 3.14
   1.482 +test expr-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1
   1.483 +test expr-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\
   1.484 +def} < {abcdef}}} 1
   1.485 +test expr-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0
   1.486 +test expr-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123
   1.487 +test expr-14.11 {CompilePrimaryExpr: var reference primary} {
   1.488 +    set i 789
   1.489 +    list [expr {$i}] [expr $i]
   1.490 +} {789 789}
   1.491 +test expr-14.12 {CompilePrimaryExpr: var reference primary} {
   1.492 +    set i {789}    ;# test expr's aggressive conversion to numeric semantics
   1.493 +    list [expr {$i}] [expr $i]
   1.494 +} {789 789}
   1.495 +test expr-14.13 {CompilePrimaryExpr: var reference primary} {
   1.496 +    catch {unset a}
   1.497 +    set a(foo) foo
   1.498 +    set a(bar) bar
   1.499 +    set a(123) 123
   1.500 +    set result ""
   1.501 +    lappend result [expr $a(123)] [expr {$a(bar)<$a(foo)}]
   1.502 +    catch {unset a}
   1.503 +    set result
   1.504 +} {123 1}
   1.505 +test expr-14.14 {CompilePrimaryExpr: var reference primary} {
   1.506 +    set i 123    ;# test "$var.0" floating point conversion hack
   1.507 +    list [expr $i] [expr $i.0] [expr $i.0/12.0]
   1.508 +} {123 123.0 10.25}
   1.509 +test expr-14.15 {CompilePrimaryExpr: var reference primary} {
   1.510 +    set i 123
   1.511 +    catch {expr $i.2} msg
   1.512 +    set msg
   1.513 +} 123.2
   1.514 +test expr-14.16 {CompilePrimaryExpr: error compiling var reference primary} {
   1.515 +    catch {expr {$a(foo}} msg
   1.516 +    set errorInfo
   1.517 +} {missing )
   1.518 +    while compiling
   1.519 +"expr {$a(foo}"}
   1.520 +test expr-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {
   1.521 +    expr $
   1.522 +} $
   1.523 +test expr-14.18 {CompilePrimaryExpr: quoted string primary} {
   1.524 +    expr "21"
   1.525 +} 21
   1.526 +test expr-14.19 {CompilePrimaryExpr: quoted string primary} {
   1.527 +    set i 123
   1.528 +    set x 456
   1.529 +    expr "$i+$x"
   1.530 +} 579
   1.531 +test expr-14.20 {CompilePrimaryExpr: quoted string primary} {
   1.532 +    set i 3
   1.533 +    set x 6
   1.534 +    expr 2+"$i.$x"
   1.535 +} 5.6
   1.536 +test expr-14.21 {CompilePrimaryExpr: error in quoted string primary} {
   1.537 +    catch {expr "[set]"} msg
   1.538 +    set msg
   1.539 +} {wrong # args: should be "set varName ?newValue?"}
   1.540 +test expr-14.22 {CompilePrimaryExpr: subcommand primary} {
   1.541 +    expr {[set i 123; set i]}
   1.542 +} 123
   1.543 +test expr-14.23 {CompilePrimaryExpr: error in subcommand primary} {
   1.544 +    catch {expr {[set]}} msg
   1.545 +    set errorInfo
   1.546 +} {wrong # args: should be "set varName ?newValue?"
   1.547 +    while compiling
   1.548 +"set"
   1.549 +    while compiling
   1.550 +"expr {[set]}"}
   1.551 +test expr-14.24 {CompilePrimaryExpr: error in subcommand primary} {
   1.552 +    catch {expr {[set i}} msg
   1.553 +    set errorInfo
   1.554 +} {missing close-bracket
   1.555 +    while compiling
   1.556 +"expr {[set i}"}
   1.557 +test expr-14.25 {CompilePrimaryExpr: math function primary} {
   1.558 +    format %.6g [expr exp(1.0)]
   1.559 +} 2.71828
   1.560 +test expr-14.26 {CompilePrimaryExpr: math function primary} {
   1.561 +    format %.6g [expr pow(2.0+0.1,3.0+0.1)]
   1.562 +} 9.97424
   1.563 +test expr-14.27 {CompilePrimaryExpr: error in math function primary} {
   1.564 +    catch {expr sinh::(2.0)} msg
   1.565 +    set errorInfo
   1.566 +} {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments
   1.567 +    while compiling
   1.568 +"expr sinh::(2.0)"}
   1.569 +test expr-14.28 {CompilePrimaryExpr: subexpression primary} {
   1.570 +    expr 2+(3*4)
   1.571 +} 14
   1.572 +test expr-14.29 {CompilePrimaryExpr: error in subexpression primary} {
   1.573 +    catch {expr 2+(3*[set])} msg
   1.574 +    set errorInfo
   1.575 +} {wrong # args: should be "set varName ?newValue?"
   1.576 +    while compiling
   1.577 +"set"
   1.578 +    while compiling
   1.579 +"expr 2+(3*[set])"}
   1.580 +test expr-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} {
   1.581 +    catch {expr 2+(3*(4+5)} msg
   1.582 +    set errorInfo
   1.583 +} {syntax error in expression "2+(3*(4+5)": looking for close parenthesis
   1.584 +    while compiling
   1.585 +"expr 2+(3*(4+5)"}
   1.586 +test expr-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
   1.587 +    set i "5+10"
   1.588 +    list "[expr $i] == 15" "[expr ($i)] == 15" "[eval expr ($i)] == 15"
   1.589 +} {{15 == 15} {15 == 15} {15 == 15}}
   1.590 +test expr-14.32 {CompilePrimaryExpr: unexpected token} {
   1.591 +    catch {expr @} msg
   1.592 +    set errorInfo
   1.593 +} {syntax error in expression "@": character not legal in expressions
   1.594 +    while compiling
   1.595 +"expr @"}
   1.596 +
   1.597 +test expr-15.1 {CompileMathFuncCall: missing parenthesis} {
   1.598 +    catch {expr sinh2.0)} msg
   1.599 +    set errorInfo
   1.600 +} {syntax error in expression "sinh2.0)": variable references require preceding $
   1.601 +    while compiling
   1.602 +"expr sinh2.0)"}
   1.603 +test expr-15.2 {CompileMathFuncCall: unknown math function} {
   1.604 +    catch {expr whazzathuh(1)} msg
   1.605 +    set errorInfo
   1.606 +} {unknown math function "whazzathuh"
   1.607 +    while compiling
   1.608 +"expr whazzathuh(1)"}
   1.609 +test expr-15.3 {CompileMathFuncCall: too many arguments} {
   1.610 +    catch {expr sin(1,2,3)} msg
   1.611 +    set errorInfo
   1.612 +} {too many arguments for math function
   1.613 +    while compiling
   1.614 +"expr sin(1,2,3)"}
   1.615 +test expr-15.4 {CompileMathFuncCall: ')' found before last required arg} {
   1.616 +    catch {expr sin()} msg
   1.617 +    set errorInfo
   1.618 +} {too few arguments for math function
   1.619 +    while compiling
   1.620 +"expr sin()"}
   1.621 +test expr-15.5 {CompileMathFuncCall: too few arguments} {
   1.622 +    catch {expr pow(1)} msg
   1.623 +    set errorInfo
   1.624 +} {too few arguments for math function
   1.625 +    while compiling
   1.626 +"expr pow(1)"}
   1.627 +test expr-15.6 {CompileMathFuncCall: missing ')'} {
   1.628 +    catch {expr sin(1} msg
   1.629 +    set errorInfo
   1.630 +} {syntax error in expression "sin(1": missing close parenthesis at end of function call
   1.631 +    while compiling
   1.632 +"expr sin(1"}
   1.633 +test expr-15.7 {CompileMathFuncCall: call registered math function} {registeredMathFuncs} {
   1.634 +    expr 2*T1()
   1.635 +} 246
   1.636 +test expr-15.8 {CompileMathFuncCall: call registered math function} {registeredMathFuncs} {
   1.637 +    expr T2()*3
   1.638 +} 1035
   1.639 +test expr-15.9 {CompileMathFuncCall: call registered math function} {registeredMathFuncs} {
   1.640 +    expr T3(21, 37)
   1.641 +} 37
   1.642 +test expr-15.10 {CompileMathFuncCall: call registered math function} {registeredMathFuncs} {
   1.643 +    expr T3(21.2, 37)
   1.644 +} 37.0
   1.645 +test expr-15.11 {CompileMathFuncCall: call registered math function} {registeredMathFuncs} {
   1.646 +    expr T3(-21.2, -17.5)
   1.647 +} -17.5
   1.648 +test expr-15.12 {ExprCallMathFunc: call registered math function} {registeredMathFuncs} {
   1.649 +    expr T3(21, wide(37))
   1.650 +} 37
   1.651 +test expr=15.13 {ExprCallMathFunc: call registered math function} {registeredMathFuncs} {
   1.652 +    expr T3(wide(21), 37)
   1.653 +} 37
   1.654 +test expr=15.14 {ExprCallMathFunc: call registered math function} {registeredMathFuncs} {
   1.655 +    expr T3(wide(21), wide(37))
   1.656 +} 37
   1.657 +test expr-15.15 {ExprCallMathFunc: call registered math function} {registeredMathFuncs} {
   1.658 +    expr T3(21.0, wide(37))
   1.659 +} 37.0
   1.660 +test expr=15.16 {ExprCallMathFunc: call registered math function} {registeredMathFuncs} {
   1.661 +    expr T3(wide(21), 37.0)
   1.662 +} 37.0
   1.663 +
   1.664 +test expr-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} {
   1.665 +    catch {unset a}
   1.666 +    set a(VALUE) ff15
   1.667 +    set i 123
   1.668 +    if {[expr 0x$a(VALUE)] & 16} {
   1.669 +        set i {}
   1.670 +    }
   1.671 +    set i
   1.672 +} {}
   1.673 +test expr-16.2 {GetToken: check for string literal in braces} {
   1.674 +    expr {{1}}
   1.675 +} {1}
   1.676 +
   1.677 +# Check "expr" and computed command names.
   1.678 +
   1.679 +test expr-17.1 {expr and computed command names} {
   1.680 +    set i 0
   1.681 +    set z expr
   1.682 +    $z 1+2
   1.683 +} 3
   1.684 +
   1.685 +# Check correct conversion of operands to numbers: If the string looks like
   1.686 +# an integer, convert to integer. Otherwise, if the string looks like a
   1.687 +# double, convert to double.
   1.688 +
   1.689 +test expr-18.1 {expr and conversion of operands to numbers} {
   1.690 +    set x [lindex 11 0]
   1.691 +    catch {expr int($x)}
   1.692 +    expr {$x}
   1.693 +} 11
   1.694 +test expr-18.2 {whitespace strings should not be == 0 (buggy strtod)} {
   1.695 +    expr {" "}
   1.696 +} { }
   1.697 +
   1.698 +# Check "expr" and interpreter result object resetting before appending
   1.699 +# an error msg during evaluation of exprs not in {}s
   1.700 +
   1.701 +test expr-19.1 {expr and interpreter result object resetting} {
   1.702 +    proc p {} {
   1.703 +        set t  10.0
   1.704 +        set x  2.0
   1.705 +        set dx 0.2
   1.706 +        set f  {$dx-$x/10}
   1.707 +        set g  {-$x/5}
   1.708 +        set center 1.0
   1.709 +        set x  [expr $x-$center]
   1.710 +        set dx [expr $dx+$g]
   1.711 +        set x  [expr $x+$f+$center]
   1.712 +        set x  [expr $x+$f+$center]
   1.713 +        set y  [expr round($x)]
   1.714 +    }
   1.715 +    p
   1.716 +} 3
   1.717 +
   1.718 +# Test for incorrect "double evaluation" semantics
   1.719 +
   1.720 +test expr-20.1 {wrong brace matching} {
   1.721 +    catch {unset l}
   1.722 +    catch {unset r}
   1.723 +    catch {unset q}
   1.724 +    catch {unset cmd}
   1.725 +    catch {unset a}
   1.726 +    set l "\{"; set r "\}"; set q "\""
   1.727 +    set cmd "expr $l$q|$q == $q$r$q$r"
   1.728 +    list [catch $cmd a] $a
   1.729 +} {1 {extra characters after close-brace}}
   1.730 +test expr-20.2 {double invocation of variable traces} {
   1.731 +    set exprtracecounter 0
   1.732 +    proc exprtraceproc {args} {
   1.733 +       upvar #0 exprtracecounter counter
   1.734 +       set argc [llength $args]
   1.735 +       set extraargs [lrange $args 0 [expr {$argc - 4}]]
   1.736 +       set name [lindex $args [expr {$argc - 3}]]
   1.737 +       upvar 1 $name var
   1.738 +       if {[incr counter] % 2 == 1} {
   1.739 +           set var "$counter oops [concat $extraargs]"
   1.740 +       } else {
   1.741 +           set var "$counter + [concat $extraargs]"
   1.742 +       }
   1.743 +    }
   1.744 +    trace variable exprtracevar r [list exprtraceproc 10]
   1.745 +    list [catch {expr "$exprtracevar + 20"} a] $a \
   1.746 +        [catch {expr "$exprtracevar + 20"} b] $b \
   1.747 +        [unset exprtracevar exprtracecounter]
   1.748 +} {1 {syntax error in expression "1 oops 10 + 20": extra tokens at end of expression} 0 32 {}}
   1.749 +test expr-20.3 {broken substitution of integer digits} {
   1.750 +    # fails with 8.0.x, but not 8.1b2
   1.751 +    list [set a 000; expr 0x1$a] [set a 1; expr ${a}000]
   1.752 +} {4096 1000}
   1.753 +test expr-20.4 {proper double evaluation compilation, error case} {
   1.754 +    catch {unset a}; # make sure $a doesn't exist
   1.755 +    list [catch {expr 1?{$a}:0} msg] $msg
   1.756 +} {1 {can't read "a": no such variable}}
   1.757 +test expr-20.5 {proper double evaluation compilation, working case} {
   1.758 +    set a yellow
   1.759 +    expr 1?{$a}:0
   1.760 +} yellow
   1.761 +test expr-20.6 {handling of compile error in trial compile} {
   1.762 +    list [catch {expr + {[incr]}} msg] $msg
   1.763 +} {1 {wrong # args: should be "incr varName ?increment?"}}
   1.764 +test expr-20.7 {handling of compile error in runtime case} {
   1.765 +    list [catch {expr + {[error foo]}} msg] $msg
   1.766 +} {1 foo}
   1.767 +
   1.768 +# Test for non-numeric boolean literal handling
   1.769 +test expr-21.1 	{non-numeric boolean literals} {expr false } false
   1.770 +test expr-21.2 	{non-numeric boolean literals} {expr true  } true
   1.771 +test expr-21.3 	{non-numeric boolean literals} {expr off   } off
   1.772 +test expr-21.4 	{non-numeric boolean literals} {expr on    } on
   1.773 +test expr-21.5 	{non-numeric boolean literals} {expr no    } no
   1.774 +test expr-21.6 	{non-numeric boolean literals} {expr yes   } yes
   1.775 +test expr-21.7 	{non-numeric boolean literals} {expr !false} 1
   1.776 +test expr-21.8 	{non-numeric boolean literals} {expr !true } 0
   1.777 +test expr-21.9 	{non-numeric boolean literals} {expr !off  } 1
   1.778 +test expr-21.10 {non-numeric boolean literals} {expr !on   } 0
   1.779 +test expr-21.11 {non-numeric boolean literals} {expr !no   } 1
   1.780 +test expr-21.12 {non-numeric boolean literals} {expr !yes  } 0
   1.781 +
   1.782 +# Test for non-numeric float handling.
   1.783 +#
   1.784 +# These are non-portable because strtod()-support for "Inf" and "NaN"
   1.785 +# is so wildly variable.  This sucks...
   1.786 +test expr-22.1 {non-numeric floats} nonPortable {
   1.787 +    list [catch {expr {NaN + 1}} msg] $msg
   1.788 +} {1 {can't use non-numeric floating-point value as operand of "+"}}
   1.789 +test expr-22.2 {non-numeric floats} nonPortable {
   1.790 +    list [catch {expr {Inf + 1}} msg] $msg
   1.791 +} {1 {can't use infinite floating-point value as operand of "+"}}
   1.792 +test expr-22.3 {non-numeric floats} nonPortable {
   1.793 +    set nan NaN
   1.794 +    list [catch {expr {$nan + 1}} msg] $msg
   1.795 +} {1 {can't use non-numeric floating-point value as operand of "+"}}
   1.796 +test expr-22.4 {non-numeric floats} nonPortable {
   1.797 +    set inf Inf
   1.798 +    list [catch {expr {$inf + 1}} msg] $msg
   1.799 +} {1 {can't use infinite floating-point value as operand of "+"}}
   1.800 +test expr-22.5 {non-numeric floats} nonPortable {
   1.801 +    list [catch {expr NaN} msg] $msg
   1.802 +} {1 {domain error: argument not in valid range}}
   1.803 +test expr-22.6 {non-numeric floats} nonPortable {
   1.804 +    list [catch {expr Inf} msg] $msg
   1.805 +} {1 {floating-point value too large to represent}}
   1.806 +test expr-22.7 {non-numeric floats} nonPortable {
   1.807 +    list [catch {expr {1 / NaN}} msg] $msg
   1.808 +} {1 {can't use non-numeric floating-point value as operand of "/"}}
   1.809 +test expr-22.8 {non-numeric floats} nonPortable {
   1.810 +    list [catch {expr {1 / Inf}} msg] $msg
   1.811 +} {1 {can't use infinite floating-point value as operand of "/"}}
   1.812 +# Make sure [Bug 761471] stays fixed.
   1.813 +test expr-22.9 {non-numeric floats: shared object equality and NaN} nonPortable {
   1.814 +    set x NaN
   1.815 +    expr {$x == $x}
   1.816 +} 0
   1.817 +
   1.818 +# Some compilers get this wrong; ensure that we work around it correctly
   1.819 +test expr-24.1 {expr edge cases; shifting} {expr int(5)>>31} 0
   1.820 +test expr-24.2 {expr edge cases; shifting} {expr int(5)>>63} 0
   1.821 +test expr-24.3 {expr edge cases; shifting} {expr wide(5)>>31} 0
   1.822 +test expr-24.4 {expr edge cases; shifting} {expr wide(5)>>63} 0
   1.823 +test expr-24.5 {expr edge cases; shifting} nonPortable {expr int(5)<<31} 0
   1.824 +test expr-24.6 {expr edge cases; shifting} nonPortable {expr int(5)<<63} 0
   1.825 +test expr-24.7 {expr edge cases; shifting} {expr wide(5)<<31} 10737418240
   1.826 +test expr-24.8 {expr edge cases; shifting} nonPortable {expr wide(5)<<63} -9223372036854775808
   1.827 +test expr-24.9 {expr edge cases; shifting} {expr 5>>32} 0
   1.828 +
   1.829 +test expr-38.1 {abs of smallest 32-bit integer [Bug 1241572]} {wideIs64bit} {
   1.830 +    expr {abs(int(-2147483648))}
   1.831 +} 2147483648
   1.832 +
   1.833 +test expr-46.1 {round() rounds to +-infinity} {
   1.834 +    expr round(0.5)
   1.835 +} 1
   1.836 +test expr-46.2 {round() rounds to +-infinity} {
   1.837 +    expr round(1.5)
   1.838 +} 2
   1.839 +test expr-46.3 {round() rounds to +-infinity} {
   1.840 +    expr round(-0.5)
   1.841 +} -1
   1.842 +test expr-46.4 {round() rounds to +-infinity} {
   1.843 +    expr round(-1.5)
   1.844 +} -2
   1.845 +test expr-46.5 {round() overflow} {
   1.846 +    list [catch {expr round(9.2233720368547758e+018)} result] $result
   1.847 +} {1 {integer value too large to represent}}
   1.848 +test expr-46.6 {round() overflow} {
   1.849 +    list [catch {expr round(-9.2233720368547758e+018)} result] $result
   1.850 +} {1 {integer value too large to represent}}
   1.851 +test expr-46.7 {round() bad value} {
   1.852 +    set x trash
   1.853 +    list [catch {expr {round($x)}} result] $result
   1.854 +} {1 {argument to math function didn't have numeric value}}
   1.855 +test expr-46.8 {round() already an integer} {
   1.856 +    set x 123456789012
   1.857 +    incr x
   1.858 +    expr round($x)
   1.859 +} 123456789013
   1.860 +test expr-46.9 {round() boundary case - 1/2 - 1 ulp} {
   1.861 +    set x 0.25
   1.862 +    set bit 0.125
   1.863 +    while 1 {
   1.864 +	set newx [expr {$x + $bit}]
   1.865 +	if { $newx == $x || $newx == 0.5 } break
   1.866 +	set x $newx
   1.867 +	set bit [expr { $bit / 2.0 }]
   1.868 +    }
   1.869 +    expr {round($x)}
   1.870 +} 0
   1.871 +test expr-46.10 {round() boundary case - 1/2 + 1 ulp} {
   1.872 +    set x 0.75
   1.873 +    set bit 0.125
   1.874 +    while 1 {
   1.875 +	set newx [expr { $x - $bit }]
   1.876 +	if { $newx == $x || $newx == 0.5 } break
   1.877 +	set x $newx
   1.878 +	set bit [expr { $bit / 2.0 }]
   1.879 +    }
   1.880 +    expr {round($x)}
   1.881 +} 1
   1.882 +test expr-46.11 {round() boundary case - -1/2 - 1 ulp} {
   1.883 +    set x -0.75
   1.884 +    set bit 0.125
   1.885 +    while 1 {
   1.886 +	set newx [expr { $x + $bit }]
   1.887 +	if { $newx == $x || $newx == -0.5 } break
   1.888 +	set x $newx
   1.889 +	set bit [expr { $bit / 2.0 }]
   1.890 +    }
   1.891 +    expr {round($x)}
   1.892 +} -1
   1.893 +test expr-46.12 {round() boundary case - -1/2 + 1 ulp} {
   1.894 +    set x -0.25
   1.895 +    set bit 0.125
   1.896 +    while 1 {
   1.897 +	set newx [expr { $x - $bit }]
   1.898 +	if { $newx == $x || $newx == -0.5 } break
   1.899 +	set x $newx
   1.900 +	set bit [expr { $bit / 2.0 }]
   1.901 +    }
   1.902 +    expr {round($x)}
   1.903 +} 0
   1.904 +
   1.905 +test expr-46.13 {round() boundary case - round down} {
   1.906 +    expr {round(2147483647 - 0.51)}
   1.907 +} 2147483646
   1.908 +
   1.909 +test expr-46.14 {round() boundary case - round up} {
   1.910 +    expr {round(2147483647 - 0.50)}
   1.911 +} 2147483647
   1.912 +
   1.913 +test expr-46.15 {round() boundary case - round up to wide} {
   1.914 +    expr {round(2147483647 + 0.50)}
   1.915 +} [expr {wide(2147483647) + 1}]
   1.916 +
   1.917 +test expr-46.16 {round() boundary case - round up} {
   1.918 +    expr {round(-2147483648 + 0.51)}
   1.919 +} -2147483647
   1.920 +
   1.921 +test expr-46.17 {round() boundary case - round down} {
   1.922 +    expr {round(-2147483648 + 0.50)}
   1.923 +} -2147483648
   1.924 +test expr-46.18 {round() boundary case - round down to wide} {
   1.925 +    expr {round(-2147483648 - 0.50)}
   1.926 +} [expr {wide(-2147483648) - 1}]
   1.927 +
   1.928 +# cleanup
   1.929 +if {[info exists a]} {
   1.930 +    unset a
   1.931 +}
   1.932 +::tcltest::cleanupTests
   1.933 +return