os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/compExpr-old.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # Commands covered: expr
     2 #
     3 # This file contains the original set of tests for the compilation (and
     4 # indirectly execution) of Tcl's expr command. A new set of tests covering
     5 # the new implementation are in the files "parseExpr.test" and
     6 # "compExpr.test". Sourcing this file into Tcl runs the tests and generates
     7 # output for errors. No output means no errors were found.
     8 #
     9 # Copyright (c) 1996-1997 Sun Microsystems, Inc.
    10 # Copyright (c) 1998-1999 by Scriptics Corporation.
    11 #
    12 # See the file "license.terms" for information on usage and redistribution
    13 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    14 #
    15 # RCS: @(#) $Id: compExpr-old.test,v 1.7 2001/12/06 10:59:17 dkf Exp $
    16 
    17 if {[lsearch [namespace children] ::tcltest] == -1} {
    18     package require tcltest
    19     namespace import -force ::tcltest::*
    20 }
    21 
    22 if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
    23     set gotT1 0
    24     puts "This application hasn't been compiled with the \"T1\" and"
    25     puts "\"T2\" math functions, so I'll skip some of the expr tests."
    26 } else {
    27     set gotT1 1
    28 }
    29 
    30 # procedures used below
    31 
    32 proc put_hello_char {c} {
    33     global a
    34     append a [format %c $c]
    35     return $c
    36 }
    37 proc hello_world {} {
    38     global a
    39     set a ""
    40     set L1 [set l0 [set h_1 [set q 0]]]
    41     for {put_hello_char [expr [put_hello_char [expr [set h 7]*10+2]]+29]} {$l0?[put_hello_char $l0]
    42         :!$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"])]
    43         ?[set ll [set l0 [expr 54<<1]]]:$ll==108&&$L1<3?
    44         [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"])]]]]
    45         :[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
    46         ?[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"])]]}
    47         expr {$L1!=1<<3?[incr q [expr ([string length "abc"]-[string length "abc"])-1]]:[set h_1 [set ll $h1]]}
    48     }
    49     set a
    50 }
    51 
    52 proc 12days {a b c} {
    53     global xxx
    54     expr {1<$a?[expr {$a<3?[12days -79 -13 [string range $c [12days -87 \
    55 	[expr 1-$b] [string range $c [12days -86 0 [string range $c 1 end]] \
    56 	end]] end]]:1};expr {$a<$b?[12days [expr $a+1] $b $c]:3};expr {[12days \
    57 	-94 [expr $a-27] $c]&&$a==2?$b<13?[12days 2 [expr $b+1] "%s %d %d\n"]:9
    58 	: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' ')# \}'+\}##(!!/"]
    59 	:$a<-50?[string compare [format %c $b] [string index $c 0]]==0?[append \
    60 	xxx [string index $c 31];scan [string index $c 31] %c x;set x]
    61 	:[12days -65 $b [string range $c 1 end]]:[12days [expr ([string compare \
    62 	[string index $c 0] "/"]==0)+$a] $b [string range $c 1 end]]:0<$a
    63 	?[12days 2 2 "%s"]:[string compare [string index $c 0] "/"]==0||
    64 	[12days 0 [12days -61 [scan [string index $c 0] %c x; set x] \
    65 	"!ek;dc i@bK'(q)-\[w\]*%n+r3#l,\{\}:\nuwloca-O;m .vpbks,fxntdCeghiry"] \
    66 	[string range $c 1 end]]}
    67 }
    68 proc do_twelve_days {} {
    69     global xxx
    70     set xxx ""
    71     12days 1 1 1
    72     string length $xxx
    73 }
    74 
    75 # start of tests
    76 
    77 catch {unset a b i x}
    78 
    79 test compExpr-old-1.1 {TclCompileExprCmd: no expression} {
    80     list [catch {expr  } msg] $msg
    81 } {1 {wrong # args: should be "expr arg ?arg ...?"}}
    82 test compExpr-old-1.2 {TclCompileExprCmd: one expression word} {
    83     expr -25
    84 } -25
    85 test compExpr-old-1.3 {TclCompileExprCmd: two expression words} {
    86     expr -8.2   -6
    87 } -14.2
    88 test compExpr-old-1.4 {TclCompileExprCmd: five expression words} {
    89     expr 20 - 5 +10 -7
    90 } 18
    91 test compExpr-old-1.5 {TclCompileExprCmd: quoted expression word} {
    92     expr "0005"
    93 } 5
    94 test compExpr-old-1.6 {TclCompileExprCmd: quoted expression word} {
    95     catch {expr "0005"zxy} msg
    96     set msg
    97 } {extra characters after close-quote}
    98 test compExpr-old-1.7 {TclCompileExprCmd: expression word in braces} {
    99     expr {-0005}
   100 } -5
   101 test compExpr-old-1.8 {TclCompileExprCmd: expression word in braces} {
   102     expr {{-0x1234}}
   103 } -4660
   104 test compExpr-old-1.9 {TclCompileExprCmd: expression word in braces} {
   105     catch {expr {-0005}foo} msg
   106     set msg
   107 } {extra characters after close-brace}
   108 test compExpr-old-1.10 {TclCompileExprCmd: other expression word in braces} {
   109     expr 4*[llength "6 2"]
   110 } 8
   111 test compExpr-old-1.11 {TclCompileExprCmd: expression word terminated by ;} {
   112     expr 4*[llength "6 2"];
   113 } 8
   114 test compExpr-old-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} {
   115     set a xxx
   116     catch {
   117 	# Might not be a number
   118 	set a [expr 10*$a]
   119     }
   120 } 1
   121 test compExpr-old-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} {
   122     set a xxx
   123     set x 27;  set bool {$x};  if $bool {set a foo}
   124     set a
   125 } foo
   126 test compExpr-old-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} {
   127     set a xxx
   128     set x 2;  set b {$x};  set a [expr $b == 2]
   129     set a
   130 } 1
   131 
   132 test compExpr-old-2.1 {TclCompileExpr: are builtin functions registered?} {
   133     expr double(5*[llength "6 2"])
   134 } 10.0
   135 test compExpr-old-2.2 {TclCompileExpr: error in expr} {
   136     catch {expr 2**3} msg
   137     set msg
   138 } {syntax error in expression "2**3": unexpected operator *}
   139 test compExpr-old-2.3 {TclCompileExpr: junk after legal expr} {
   140     catch {expr 7*[llength "a b"]foo} msg
   141     set msg
   142 } {syntax error in expression "7*2foo": extra tokens at end of expression}
   143 test compExpr-old-2.4 {TclCompileExpr: numeric expr string rep == formatted int rep} {
   144     expr {0001}
   145 } 1
   146 
   147 test compExpr-old-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
   148 test compExpr-old-3.2 {CompileCondExpr: error in lor expr} {
   149     catch {expr x||3} msg
   150     set msg
   151 } {syntax error in expression "x||3": variable references require preceding $} 
   152 test compExpr-old-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
   153 test compExpr-old-3.4 {CompileCondExpr: error compiling true arm} {
   154     catch {expr 3>2?2**3:66} msg
   155     set msg
   156 } {syntax error in expression "3>2?2**3:66": unexpected operator *}
   157 test compExpr-old-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66
   158 test compExpr-old-3.6 {CompileCondExpr: error compiling false arm} {
   159     catch {expr 2>3?44:2**3} msg
   160     set msg
   161 } {syntax error in expression "2>3?44:2**3": unexpected operator *}
   162 test compExpr-old-3.7 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} {
   163     puts "Note: doing test compExpr-old-3.7 which can take several minutes to run"
   164     hello_world
   165 } {Hello world}
   166 catch {unset xxx}
   167 test compExpr-old-3.8 {CompileCondExpr: long arms & nested cond exprs} {nonPortable} {
   168     puts "Note: doing test compExpr-old-3.8 which can take several minutes to run"
   169     do_twelve_days
   170 } 2358
   171 catch {unset xxx}
   172 
   173 test compExpr-old-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
   174 test compExpr-old-4.2 {CompileLorExpr: error in land expr} {
   175     catch {expr x&&3} msg
   176     set msg
   177 } {syntax error in expression "x&&3": variable references require preceding $} 
   178 test compExpr-old-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
   179 test compExpr-old-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
   180 test compExpr-old-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
   181 test compExpr-old-4.6 {CompileLorExpr: error compiling lor arm} {
   182     catch {expr 2**3||4.0} msg
   183     set msg
   184 } {syntax error in expression "2**3||4.0": unexpected operator *}
   185 test compExpr-old-4.7 {CompileLorExpr: error compiling lor arm} {
   186     catch {expr 1.3||2**3} msg
   187     set msg
   188 } {syntax error in expression "1.3||2**3": unexpected operator *}
   189 test compExpr-old-4.8 {CompileLorExpr: error compiling lor arms} {
   190     list [catch {expr {"a"||"b"}} msg] $msg
   191 } {1 {expected boolean value but got "a"}}
   192 test compExpr-old-4.9 {CompileLorExpr: long lor arm} {
   193     set a "abcdefghijkl"
   194     set i 7
   195     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]]}
   196 } 1
   197 
   198 test compExpr-old-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
   199 test compExpr-old-5.2 {CompileLandExpr: error in bitor expr} {
   200     catch {expr x|3} msg
   201     set msg
   202 } {syntax error in expression "x|3": variable references require preceding $} 
   203 test compExpr-old-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
   204 test compExpr-old-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
   205 test compExpr-old-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
   206 test compExpr-old-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1
   207 test compExpr-old-5.7 {CompileLandExpr: error compiling land arm} {
   208     catch {expr 2**3&&4.0} msg
   209     set msg
   210 } {syntax error in expression "2**3&&4.0": unexpected operator *}
   211 test compExpr-old-5.8 {CompileLandExpr: error compiling land arm} {
   212     catch {expr 1.3&&2**3} msg
   213     set msg
   214 } {syntax error in expression "1.3&&2**3": unexpected operator *}
   215 test compExpr-old-5.9 {CompileLandExpr: error compiling land arm} {
   216     list [catch {expr {"a"&&"b"}} msg] $msg
   217 } {1 {expected boolean value but got "a"}}
   218 test compExpr-old-5.10 {CompileLandExpr: long land arms} {
   219     set a "abcdefghijkl"
   220     set i 7
   221     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]]}
   222 } 1
   223 
   224 test compExpr-old-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
   225 test compExpr-old-6.2 {CompileBitXorExpr: error in bitand expr} {
   226     catch {expr x|3} msg
   227     set msg
   228 } {syntax error in expression "x|3": variable references require preceding $} 
   229 test compExpr-old-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
   230 test compExpr-old-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
   231 test compExpr-old-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
   232 test compExpr-old-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8
   233 test compExpr-old-6.7 {CompileBitXorExpr: error compiling bitxor arm} {
   234     catch {expr 2**3|6} msg
   235     set msg
   236 } {syntax error in expression "2**3|6": unexpected operator *}
   237 test compExpr-old-6.8 {CompileBitXorExpr: error compiling bitxor arm} {
   238     catch {expr 2^x} msg
   239     set msg
   240 } {syntax error in expression "2^x": variable references require preceding $}
   241 test compExpr-old-6.9 {CompileBitXorExpr: runtime error in bitxor arm} {
   242     list [catch {expr {24.0^3}} msg] $msg
   243 } {1 {can't use floating-point value as operand of "^"}}
   244 test compExpr-old-6.10 {CompileBitXorExpr: runtime error in bitxor arm} {
   245     list [catch {expr {"a"^"b"}} msg] $msg
   246 } {1 {can't use non-numeric string as operand of "^"}}
   247 
   248 test compExpr-old-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
   249 test compExpr-old-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
   250 test compExpr-old-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
   251 test compExpr-old-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
   252 test compExpr-old-7.5 {CompileBitAndExpr: error in equality expr} {
   253     catch {expr x==3} msg
   254     set msg
   255 } {syntax error in expression "x==3": variable references require preceding $} 
   256 test compExpr-old-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
   257 test compExpr-old-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
   258 test compExpr-old-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
   259 test compExpr-old-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7
   260 test compExpr-old-7.10 {CompileBitAndExpr: error compiling bitand arm} {
   261     catch {expr 2**3&6} msg
   262     set msg
   263 } {syntax error in expression "2**3&6": unexpected operator *}
   264 test compExpr-old-7.11 {CompileBitAndExpr: error compiling bitand arm} {
   265     catch {expr 2&x} msg
   266     set msg
   267 } {syntax error in expression "2&x": variable references require preceding $}
   268 test compExpr-old-7.12 {CompileBitAndExpr: runtime error in bitand arm} {
   269     list [catch {expr {24.0&3}} msg] $msg
   270 } {1 {can't use floating-point value as operand of "&"}}
   271 test compExpr-old-7.13 {CompileBitAndExpr: runtime error in bitand arm} {
   272     list [catch {expr {"a"&"b"}} msg] $msg
   273 } {1 {can't use non-numeric string as operand of "&"}}
   274 
   275 test compExpr-old-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
   276 test compExpr-old-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
   277 test compExpr-old-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
   278 test compExpr-old-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
   279 test compExpr-old-8.5 {CompileEqualityExpr: error in relational expr} {
   280     catch {expr x>3} msg
   281     set msg
   282 } {syntax error in expression "x>3": variable references require preceding $} 
   283 test compExpr-old-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
   284 test compExpr-old-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
   285 test compExpr-old-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
   286 test compExpr-old-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1
   287 test compExpr-old-8.10 {CompileEqualityExpr: error compiling equality arm} {
   288     catch {expr 2**3==6} msg
   289     set msg
   290 } {syntax error in expression "2**3==6": unexpected operator *}
   291 test compExpr-old-8.11 {CompileEqualityExpr: error compiling equality arm} {
   292     catch {expr 2!=x} msg
   293     set msg
   294 } {syntax error in expression "2!=x": variable references require preceding $}
   295 
   296 
   297 test compExpr-old-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
   298 test compExpr-old-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63
   299 test compExpr-old-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1
   300 test compExpr-old-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8
   301 
   302 # The following test is different for 32-bit versus 64-bit
   303 # architectures because LONG_MIN is different
   304 
   305 if {0x80000000 > 0} {
   306     test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
   307 	expr {1<<63}
   308     } -9223372036854775808
   309 } else {
   310     test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
   311 	expr {1<<31}
   312     } -2147483648
   313 }
   314 test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} {
   315     catch {expr x>>3} msg
   316     set msg
   317 } {syntax error in expression "x>>3": variable references require preceding $} 
   318 test compExpr-old-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
   319 test compExpr-old-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
   320 test compExpr-old-9.9 {CompileRelationalExpr: error compiling relational arm} {
   321     catch {expr 2**3>6} msg
   322     set msg
   323 } {syntax error in expression "2**3>6": unexpected operator *}
   324 test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} {
   325     catch {expr 2<x} msg
   326     set msg
   327 } {syntax error in expression "2<x": variable references require preceding $}
   328 
   329 test compExpr-old-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
   330 test compExpr-old-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
   331 test compExpr-old-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
   332 test compExpr-old-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
   333 test compExpr-old-10.5 {CompileShiftExpr: error in add expr} {
   334     catch {expr x+3} msg
   335     set msg
   336 } {syntax error in expression "x+3": variable references require preceding $}
   337 test compExpr-old-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
   338 test compExpr-old-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
   339 test compExpr-old-10.8 {CompileShiftExpr: error compiling shift arm} {
   340     catch {expr 2**3>>6} msg
   341     set msg
   342 } {syntax error in expression "2**3>>6": unexpected operator *}
   343 test compExpr-old-10.9 {CompileShiftExpr: error compiling shift arm} {
   344     catch {expr 2<<x} msg
   345     set msg
   346 } {syntax error in expression "2<<x": variable references require preceding $}
   347 test compExpr-old-10.10 {CompileShiftExpr: runtime error} {
   348     list [catch {expr {24.0>>43}} msg] $msg
   349 } {1 {can't use floating-point value as operand of ">>"}}
   350 test compExpr-old-10.11 {CompileShiftExpr: runtime error} {
   351     list [catch {expr {"a"<<"b"}} msg] $msg
   352 } {1 {can't use non-numeric string as operand of "<<"}}
   353 
   354 test compExpr-old-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
   355 test compExpr-old-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
   356 test compExpr-old-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
   357 test compExpr-old-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
   358 test compExpr-old-11.5 {CompileAddExpr: error in multiply expr} {
   359     catch {expr x*3} msg
   360     set msg
   361 } {syntax error in expression "x*3": variable references require preceding $}
   362 test compExpr-old-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
   363 test compExpr-old-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
   364 test compExpr-old-11.8 {CompileAddExpr: error compiling add arm} {
   365     catch {expr 2**3+6} msg
   366     set msg
   367 } {syntax error in expression "2**3+6": unexpected operator *}
   368 test compExpr-old-11.9 {CompileAddExpr: error compiling add arm} {
   369     catch {expr 2-x} msg
   370     set msg
   371 } {syntax error in expression "2-x": variable references require preceding $}
   372 test compExpr-old-11.10 {CompileAddExpr: runtime error} {
   373     list [catch {expr {24.0+"xx"}} msg] $msg
   374 } {1 {can't use non-numeric string as operand of "+"}}
   375 test compExpr-old-11.11 {CompileAddExpr: runtime error} {
   376     list [catch {expr {"a"-"b"}} msg] $msg
   377 } {1 {can't use non-numeric string as operand of "-"}}
   378 test compExpr-old-11.12 {CompileAddExpr: runtime error} {
   379     list [catch {expr {3/0}} msg] $msg
   380 } {1 {divide by zero}}
   381 test compExpr-old-11.13 {CompileAddExpr: runtime error} {
   382     list [catch {expr {2.3/0.0}} msg] $msg
   383 } {1 {divide by zero}}
   384 
   385 test compExpr-old-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
   386 test compExpr-old-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
   387 test compExpr-old-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
   388 test compExpr-old-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
   389 test compExpr-old-12.5 {CompileMultiplyExpr: error in unary expr} {
   390     catch {expr ~x} msg
   391     set msg
   392 } {syntax error in expression "~x": variable references require preceding $}
   393 test compExpr-old-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
   394 test compExpr-old-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
   395 test compExpr-old-12.8 {CompileMultiplyExpr: error compiling multiply arm} {
   396     catch {expr 2*3%%6} msg
   397     set msg
   398 } {syntax error in expression "2*3%%6": unexpected operator %}
   399 test compExpr-old-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
   400     catch {expr 2*x} msg
   401     set msg
   402 } {syntax error in expression "2*x": variable references require preceding $}
   403 test compExpr-old-12.10 {CompileMultiplyExpr: runtime error} {
   404     list [catch {expr {24.0*"xx"}} msg] $msg
   405 } {1 {can't use non-numeric string as operand of "*"}}
   406 test compExpr-old-12.11 {CompileMultiplyExpr: runtime error} {
   407     list [catch {expr {"a"/"b"}} msg] $msg
   408 } {1 {can't use non-numeric string as operand of "/"}}
   409 
   410 test compExpr-old-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255
   411 test compExpr-old-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83
   412 test compExpr-old-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36
   413 test compExpr-old-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
   414 test compExpr-old-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
   415 test compExpr-old-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
   416 test compExpr-old-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
   417 test compExpr-old-13.8 {CompileUnaryExpr: error compiling unary expr} {
   418     catch {expr ~x} msg
   419     set msg
   420 } {syntax error in expression "~x": variable references require preceding $}
   421 test compExpr-old-13.9 {CompileUnaryExpr: error compiling unary expr} {
   422     catch {expr !1.x} msg
   423     set msg
   424 } {syntax error in expression "!1.x": extra tokens at end of expression}
   425 test compExpr-old-13.10 {CompileUnaryExpr: runtime error} {
   426     list [catch {expr {~"xx"}} msg] $msg
   427 } {1 {can't use non-numeric string as operand of "~"}}
   428 test compExpr-old-13.11 {CompileUnaryExpr: runtime error} {
   429     list [catch {expr ~4.0} msg] $msg
   430 } {1 {can't use floating-point value as operand of "~"}}
   431 test compExpr-old-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291
   432 test compExpr-old-13.13 {CompileUnaryExpr: just primary expr} {
   433     set a 27
   434     expr $a
   435 } 27
   436 test compExpr-old-13.14 {CompileUnaryExpr: just primary expr} {
   437     expr double(27)
   438 } 27.0
   439 test compExpr-old-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123
   440 test compExpr-old-13.16 {CompileUnaryExpr: error in primary expr} {
   441     catch {expr [set]} msg
   442     set msg
   443 } {wrong # args: should be "set varName ?newValue?"}
   444 test compExpr-old-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1
   445 test compExpr-old-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123
   446 test compExpr-old-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255
   447 test compExpr-old-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8
   448 test compExpr-old-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0
   449 test compExpr-old-14.6 {CompilePrimaryExpr: literal primary} {
   450     expr 3.1400000
   451 } 3.14
   452 test compExpr-old-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1
   453 test compExpr-old-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\
   454 def} < {abcdef}}} 1
   455 test compExpr-old-14.9 {CompilePrimaryExpr: literal primary} {expr {{abc\tde} > {abc\tdef}}} 0
   456 test compExpr-old-14.10 {CompilePrimaryExpr: literal primary} {expr {{123}}} 123
   457 test compExpr-old-14.11 {CompilePrimaryExpr: var reference primary} {
   458     set i 789
   459     list [expr {$i}] [expr $i]
   460 } {789 789}
   461 test compExpr-old-14.12 {CompilePrimaryExpr: var reference primary} {
   462     set i {789}    ;# test expr's aggressive conversion to numeric semantics
   463     list [expr {$i}] [expr $i]
   464 } {789 789}
   465 test compExpr-old-14.13 {CompilePrimaryExpr: var reference primary} {
   466     catch {unset a}
   467     set a(foo) foo
   468     set a(bar) bar
   469     set a(123) 123
   470     set result ""
   471     lappend result [expr $a(123)] [expr {$a(bar)<$a(foo)}]
   472     catch {unset a}
   473     set result
   474 } {123 1}
   475 test compExpr-old-14.14 {CompilePrimaryExpr: var reference primary} {
   476     set i 123    ;# test "$var.0" floating point conversion hack
   477     list [expr $i] [expr $i.0] [expr $i.0/12.0]
   478 } {123 123.0 10.25}
   479 test compExpr-old-14.15 {CompilePrimaryExpr: var reference primary} {
   480     set i 123
   481     catch {expr $i.2} msg
   482     set msg
   483 } 123.2
   484 test compExpr-old-14.16 {CompilePrimaryExpr: error compiling var reference primary} {
   485     catch {expr {$a(foo}} msg
   486     set errorInfo
   487 } {missing )
   488     while compiling
   489 "expr {$a(foo}"}
   490 test compExpr-old-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {
   491     expr $
   492 } $
   493 test compExpr-old-14.18 {CompilePrimaryExpr: quoted string primary} {
   494     expr "21"
   495 } 21
   496 test compExpr-old-14.19 {CompilePrimaryExpr: quoted string primary} {
   497     set i 123
   498     set x 456
   499     expr "$i+$x"
   500 } 579
   501 test compExpr-old-14.20 {CompilePrimaryExpr: quoted string primary} {
   502     set i 3
   503     set x 6
   504     expr 2+"$i.$x"
   505 } 5.6
   506 test compExpr-old-14.21 {CompilePrimaryExpr: error in quoted string primary} {
   507     catch {expr "[set]"} msg
   508     set msg
   509 } {wrong # args: should be "set varName ?newValue?"}
   510 test compExpr-old-14.22 {CompilePrimaryExpr: subcommand primary} {
   511     expr {[set i 123; set i]}
   512 } 123
   513 test compExpr-old-14.23 {CompilePrimaryExpr: error in subcommand primary} {
   514     catch {expr {[set]}} msg
   515     set errorInfo
   516 } {wrong # args: should be "set varName ?newValue?"
   517     while compiling
   518 "set"
   519     while compiling
   520 "expr {[set]}"}
   521 test compExpr-old-14.24 {CompilePrimaryExpr: error in subcommand primary} {
   522     catch {expr {[set i}} msg
   523     set errorInfo
   524 } {missing close-bracket
   525     while compiling
   526 "expr {[set i}"}
   527 test compExpr-old-14.25 {CompilePrimaryExpr: math function primary} {
   528     format %.6g [expr exp(1.0)]
   529 } 2.71828
   530 test compExpr-old-14.26 {CompilePrimaryExpr: math function primary} {
   531     format %.6g [expr pow(2.0+0.1,3.0+0.1)]
   532 } 9.97424
   533 test compExpr-old-14.27 {CompilePrimaryExpr: error in math function primary} {
   534     catch {expr sinh::(2.0)} msg
   535     set errorInfo
   536 } {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments
   537     while compiling
   538 "expr sinh::(2.0)"}
   539 test compExpr-old-14.28 {CompilePrimaryExpr: subexpression primary} {
   540     expr 2+(3*4)
   541 } 14
   542 test compExpr-old-14.29 {CompilePrimaryExpr: error in subexpression primary} {
   543     catch {expr 2+(3*[set])} msg
   544     set errorInfo
   545 } {wrong # args: should be "set varName ?newValue?"
   546     while compiling
   547 "set"
   548     while compiling
   549 "expr 2+(3*[set])"}
   550 test compExpr-old-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} {
   551     catch {expr 2+(3*(4+5)} msg
   552     set errorInfo
   553 } {syntax error in expression "2+(3*(4+5)": looking for close parenthesis
   554     while compiling
   555 "expr 2+(3*(4+5)"}
   556 test compExpr-old-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
   557     set i "5+10"
   558     list "[expr $i] == 15" "[expr ($i)] == 15" "[eval expr ($i)] == 15"
   559 } {{15 == 15} {15 == 15} {15 == 15}}
   560 test compExpr-old-14.32 {CompilePrimaryExpr: unexpected token} {
   561     catch {expr @} msg
   562     set errorInfo
   563 } {syntax error in expression "@": character not legal in expressions
   564     while compiling
   565 "expr @"}
   566 
   567 test compExpr-old-15.1 {CompileMathFuncCall: missing parenthesis} {
   568     catch {expr sinh2.0)} msg
   569     set errorInfo
   570 } {syntax error in expression "sinh2.0)": variable references require preceding $
   571     while compiling
   572 "expr sinh2.0)"}
   573 test compExpr-old-15.2 {CompileMathFuncCall: unknown math function} {
   574     catch {expr whazzathuh(1)} msg
   575     set errorInfo
   576 } {unknown math function "whazzathuh"
   577     while compiling
   578 "expr whazzathuh(1)"}
   579 test compExpr-old-15.3 {CompileMathFuncCall: too many arguments} {
   580     catch {expr sin(1,2,3)} msg
   581     set errorInfo
   582 } {too many arguments for math function
   583     while compiling
   584 "expr sin(1,2,3)"}
   585 test compExpr-old-15.4 {CompileMathFuncCall: ')' found before last required arg} {
   586     catch {expr sin()} msg
   587     set errorInfo
   588 } {too few arguments for math function
   589     while compiling
   590 "expr sin()"}
   591 test compExpr-old-15.5 {CompileMathFuncCall: too few arguments} {
   592     catch {expr pow(1)} msg
   593     set errorInfo
   594 } {too few arguments for math function
   595     while compiling
   596 "expr pow(1)"}
   597 test compExpr-old-15.6 {CompileMathFuncCall: missing ')'} {
   598     catch {expr sin(1} msg
   599     set errorInfo
   600 } {syntax error in expression "sin(1": missing close parenthesis at end of function call
   601     while compiling
   602 "expr sin(1"}
   603 if $gotT1 {
   604     test compExpr-old-15.7 {CompileMathFuncCall: call registered math function} {
   605 	expr 2*T1()
   606     } 246
   607     test compExpr-old-15.8 {CompileMathFuncCall: call registered math function} {
   608 	expr T2()*3
   609     } 1035
   610 
   611     test compExpr-old-15.9 {CompileMathFuncCall: call registered math function} {
   612 	expr T3(21, 37)
   613     } 37
   614     test compExpr-old-15.10 {CompileMathFuncCall: call registered math function} {
   615 	expr T3(21.2, 37)
   616     } 37.0
   617     test compExpr-old-15.11 {CompileMathFuncCall: call registered math function} {
   618 	expr T3(-21.2, -17.5)
   619     } -17.5
   620 }
   621 
   622 test compExpr-old-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} {
   623     catch {unset a}
   624     set a(VALUE) ff15
   625     set i 123
   626     if {[expr 0x$a(VALUE)] & 16} {
   627         set i {}
   628     }
   629     set i
   630 } {}
   631 test compExpr-old-16.2 {GetToken: check for string literal in braces} {
   632     expr {{1}}
   633 } {1}
   634 
   635 # Check "expr" and computed command names.
   636 
   637 test compExpr-old-17.1 {expr and computed command names} {
   638     set i 0
   639     set z expr
   640     $z 1+2
   641 } 3
   642 
   643 # Check correct conversion of operands to numbers: If the string looks like
   644 # an integer, convert to integer. Otherwise, if the string looks like a
   645 # double, convert to double.
   646 
   647 test compExpr-old-18.1 {expr and conversion of operands to numbers} {
   648     set x [lindex 11 0]
   649     catch {expr int($x)}
   650     expr {$x}
   651 } 11
   652 
   653 # Check "expr" and interpreter result object resetting before appending
   654 # an error msg during evaluation of exprs not in {}s
   655 
   656 test compExpr-old-19.1 {expr and interpreter result object resetting} {
   657     proc p {} {
   658         set t  10.0
   659         set x  2.0
   660         set dx 0.2
   661         set f  {$dx-$x/10}
   662         set g  {-$x/5}
   663         set center 1.0
   664         set x  [expr $x-$center]
   665         set dx [expr $dx+$g]
   666         set x  [expr $x+$f+$center]
   667         set x  [expr $x+$f+$center]
   668         set y  [expr round($x)]
   669     }
   670     p
   671 } 3
   672 
   673 # cleanup
   674 if {[info exists a]} {
   675     unset a
   676 }
   677 ::tcltest::cleanupTests
   678 return