os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/compExpr-old.test
Update contrib.
1 # Commands covered: expr
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.
9 # Copyright (c) 1996-1997 Sun Microsystems, Inc.
10 # Copyright (c) 1998-1999 by Scriptics Corporation.
12 # See the file "license.terms" for information on usage and redistribution
13 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
15 # RCS: @(#) $Id: compExpr-old.test,v 1.7 2001/12/06 10:59:17 dkf Exp $
17 if {[lsearch [namespace children] ::tcltest] == -1} {
18 package require tcltest
19 namespace import -force ::tcltest::*
22 if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
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."
30 # procedures used below
32 proc put_hello_char {c} {
34 append a [format %c $c]
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]]}
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]]}
68 proc do_twelve_days {} {
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} {
85 test compExpr-old-1.3 {TclCompileExprCmd: two expression words} {
88 test compExpr-old-1.4 {TclCompileExprCmd: five expression words} {
91 test compExpr-old-1.5 {TclCompileExprCmd: quoted expression word} {
94 test compExpr-old-1.6 {TclCompileExprCmd: quoted expression word} {
95 catch {expr "0005"zxy} msg
97 } {extra characters after close-quote}
98 test compExpr-old-1.7 {TclCompileExprCmd: expression word in braces} {
101 test compExpr-old-1.8 {TclCompileExprCmd: expression word in braces} {
104 test compExpr-old-1.9 {TclCompileExprCmd: expression word in braces} {
105 catch {expr {-0005}foo} 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"]
111 test compExpr-old-1.11 {TclCompileExprCmd: expression word terminated by ;} {
112 expr 4*[llength "6 2"];
114 test compExpr-old-1.12 {TclCompileExprCmd: inlined expr (in "catch") inside other catch} {
117 # Might not be a number
121 test compExpr-old-1.13 {TclCompileExprCmd: second level of substitutions in expr not in braces with single var reference} {
123 set x 27; set bool {$x}; if $bool {set a foo}
126 test compExpr-old-1.14 {TclCompileExprCmd: second level of substitutions in expr with comparison as top-level operator} {
128 set x 2; set b {$x}; set a [expr $b == 2]
132 test compExpr-old-2.1 {TclCompileExpr: are builtin functions registered?} {
133 expr double(5*[llength "6 2"])
135 test compExpr-old-2.2 {TclCompileExpr: error in expr} {
136 catch {expr 2**3} 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
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} {
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
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
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
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"
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"
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
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
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
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} {
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]]}
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} {
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
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
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} {
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]]}
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} {
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
236 } {syntax error in expression "2**3|6": unexpected operator *}
237 test compExpr-old-6.8 {CompileBitXorExpr: error compiling bitxor arm} {
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 "^"}}
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
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
263 } {syntax error in expression "2**3&6": unexpected operator *}
264 test compExpr-old-7.11 {CompileBitAndExpr: error compiling bitand arm} {
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 "&"}}
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} {
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
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
294 } {syntax error in expression "2!=x": variable references require preceding $}
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
302 # The following test is different for 32-bit versus 64-bit
303 # architectures because LONG_MIN is different
305 if {0x80000000 > 0} {
306 test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
308 } -9223372036854775808
310 test compExpr-old-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} {
314 test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} {
315 catch {expr x>>3} 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
323 } {syntax error in expression "2**3>6": unexpected operator *}
324 test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} {
327 } {syntax error in expression "2<x": variable references require preceding $}
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} {
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
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
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 "<<"}}
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} {
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
367 } {syntax error in expression "2**3+6": unexpected operator *}
368 test compExpr-old-11.9 {CompileAddExpr: error compiling add arm} {
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}}
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} {
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
398 } {syntax error in expression "2*3%%6": unexpected operator %}
399 test compExpr-old-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
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 "/"}}
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} {
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
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} {
436 test compExpr-old-13.14 {CompileUnaryExpr: just primary expr} {
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
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} {
452 test compExpr-old-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1
453 test compExpr-old-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\
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} {
459 list [expr {$i}] [expr $i]
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]
465 test compExpr-old-14.13 {CompilePrimaryExpr: var reference primary} {
471 lappend result [expr $a(123)] [expr {$a(bar)<$a(foo)}]
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]
479 test compExpr-old-14.15 {CompilePrimaryExpr: var reference primary} {
481 catch {expr $i.2} msg
484 test compExpr-old-14.16 {CompilePrimaryExpr: error compiling var reference primary} {
485 catch {expr {$a(foo}} msg
490 test compExpr-old-14.17 {CompilePrimaryExpr: string primary that looks like var ref} {
493 test compExpr-old-14.18 {CompilePrimaryExpr: quoted string primary} {
496 test compExpr-old-14.19 {CompilePrimaryExpr: quoted string primary} {
501 test compExpr-old-14.20 {CompilePrimaryExpr: quoted string primary} {
506 test compExpr-old-14.21 {CompilePrimaryExpr: error in quoted string primary} {
507 catch {expr "[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]}
513 test compExpr-old-14.23 {CompilePrimaryExpr: error in subcommand primary} {
514 catch {expr {[set]}} msg
516 } {wrong # args: should be "set varName ?newValue?"
521 test compExpr-old-14.24 {CompilePrimaryExpr: error in subcommand primary} {
522 catch {expr {[set i}} msg
524 } {missing close-bracket
527 test compExpr-old-14.25 {CompilePrimaryExpr: math function primary} {
528 format %.6g [expr exp(1.0)]
530 test compExpr-old-14.26 {CompilePrimaryExpr: math function primary} {
531 format %.6g [expr pow(2.0+0.1,3.0+0.1)]
533 test compExpr-old-14.27 {CompilePrimaryExpr: error in math function primary} {
534 catch {expr sinh::(2.0)} msg
536 } {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments
539 test compExpr-old-14.28 {CompilePrimaryExpr: subexpression primary} {
542 test compExpr-old-14.29 {CompilePrimaryExpr: error in subexpression primary} {
543 catch {expr 2+(3*[set])} msg
545 } {wrong # args: should be "set varName ?newValue?"
550 test compExpr-old-14.30 {CompilePrimaryExpr: missing paren in subexpression primary} {
551 catch {expr 2+(3*(4+5)} msg
553 } {syntax error in expression "2+(3*(4+5)": looking for close parenthesis
556 test compExpr-old-14.31 {CompilePrimaryExpr: just var ref in subexpression primary} {
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} {
563 } {syntax error in expression "@": character not legal in expressions
567 test compExpr-old-15.1 {CompileMathFuncCall: missing parenthesis} {
568 catch {expr sinh2.0)} msg
570 } {syntax error in expression "sinh2.0)": variable references require preceding $
573 test compExpr-old-15.2 {CompileMathFuncCall: unknown math function} {
574 catch {expr whazzathuh(1)} msg
576 } {unknown math function "whazzathuh"
578 "expr whazzathuh(1)"}
579 test compExpr-old-15.3 {CompileMathFuncCall: too many arguments} {
580 catch {expr sin(1,2,3)} msg
582 } {too many arguments for math function
585 test compExpr-old-15.4 {CompileMathFuncCall: ')' found before last required arg} {
586 catch {expr sin()} msg
588 } {too few arguments for math function
591 test compExpr-old-15.5 {CompileMathFuncCall: too few arguments} {
592 catch {expr pow(1)} msg
594 } {too few arguments for math function
597 test compExpr-old-15.6 {CompileMathFuncCall: missing ')'} {
598 catch {expr sin(1} msg
600 } {syntax error in expression "sin(1": missing close parenthesis at end of function call
604 test compExpr-old-15.7 {CompileMathFuncCall: call registered math function} {
607 test compExpr-old-15.8 {CompileMathFuncCall: call registered math function} {
611 test compExpr-old-15.9 {CompileMathFuncCall: call registered math function} {
614 test compExpr-old-15.10 {CompileMathFuncCall: call registered math function} {
617 test compExpr-old-15.11 {CompileMathFuncCall: call registered math function} {
618 expr T3(-21.2, -17.5)
622 test compExpr-old-16.1 {GetToken: checks whether integer token starting with "0x" (e.g., "0x$") is invalid} {
626 if {[expr 0x$a(VALUE)] & 16} {
631 test compExpr-old-16.2 {GetToken: check for string literal in braces} {
635 # Check "expr" and computed command names.
637 test compExpr-old-17.1 {expr and computed command names} {
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.
647 test compExpr-old-18.1 {expr and conversion of operands to numbers} {
653 # Check "expr" and interpreter result object resetting before appending
654 # an error msg during evaluation of exprs not in {}s
656 test compExpr-old-19.1 {expr and interpreter result object resetting} {
664 set x [expr $x-$center]
666 set x [expr $x+$f+$center]
667 set x [expr $x+$f+$center]
668 set y [expr round($x)]
674 if {[info exists a]} {
677 ::tcltest::cleanupTests