summaryrefslogtreecommitdiffstats
path: root/tests/compExpr-old.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compExpr-old.test')
-rw-r--r--tests/compExpr-old.test150
1 files changed, 106 insertions, 44 deletions
diff --git a/tests/compExpr-old.test b/tests/compExpr-old.test
index c770729..6ac7ff1 100644
--- a/tests/compExpr-old.test
+++ b/tests/compExpr-old.test
@@ -12,7 +12,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: compExpr-old.test,v 1.11 2004/10/31 18:46:55 dkf Exp $
+# RCS: @(#) $Id: compExpr-old.test,v 1.12 2005/05/10 18:35:17 kennykb Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -25,6 +25,64 @@ if {([catch {expr T1()} msg] == 1) && ($msg == {unknown math function "T1"})} {
testConstraint testmathfunctions 1
}
+# Big test for correct ordering of data in [expr]
+
+proc testIEEE {} {
+ variable ieeeValues
+ binary scan [binary format dd -1.0 1.0] c* c
+ switch -exact -- $c {
+ {0 0 0 0 0 0 -16 -65 0 0 0 0 0 0 -16 63} {
+ # little endian
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\xff d \
+ ieeeValues(-Infinity)
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\xbf d \
+ ieeeValues(-Normal)
+ binary scan \x00\x00\x00\x00\x00\x00\x08\x80 d \
+ ieeeValues(-Subnormal)
+ binary scan \x00\x00\x00\x00\x00\x00\x00\x80 d \
+ ieeeValues(-0)
+ binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(+0)
+ binary scan \x00\x00\x00\x00\x00\x00\x08\x00 d \
+ ieeeValues(+Subnormal)
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\x3f d \
+ ieeeValues(+Normal)
+ binary scan \x00\x00\x00\x00\x00\x00\xf0\x7f d \
+ ieeeValues(+Infinity)
+ binary scan \x00\x00\x00\x00\x00\x00\xf8\x7f d \
+ ieeeValues(NaN)
+ set ieeeValues(littleEndian) 1
+ return 1
+ }
+ {-65 -16 0 0 0 0 0 0 63 -16 0 0 0 0 0 0} {
+ binary scan \xff\xf0\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(-Infinity)
+ binary scan \xbf\xf0\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(-Normal)
+ binary scan \x80\x08\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(-Subnormal)
+ binary scan \x80\x00\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(-0)
+ binary scan \x00\x00\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(+0)
+ binary scan \x00\x08\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(+Subnormal)
+ binary scan \x3f\xf0\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(+Normal)
+ binary scan \x7f\xf0\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(+Infinity)
+ binary scan \x7f\xf8\x00\x00\x00\x00\x00\x00 d \
+ ieeeValues(NaN)
+ set ieeeValues(littleEndian) 0
+ return 1
+ }
+ default {
+ return 0
+ }
+ }
+}
+::tcltest::testConstraint ieeeFloatingPoint [testIEEE]
+
# procedures used below
proc put_hello_char {c} {
@@ -143,10 +201,11 @@ test compExpr-old-2.4 {TclCompileExpr: numeric expr string rep == formatted int
} 1
test compExpr-old-3.1 {CompileCondExpr: just lor expr} {expr 3||0} 1
-test compExpr-old-3.2 {CompileCondExpr: error in lor expr} {
+test compExpr-old-3.2 {CompileCondExpr: error in lor expr} -body {
catch {expr x||3} msg
set msg
-} {syntax error in expression "x||3": variable references require preceding $}
+} -match glob \
+ -result {syntax error in expression "x||3": * preceding $*}
test compExpr-old-3.3 {CompileCondExpr: test true arm} {expr 3>2?44:66} 44
test compExpr-old-3.4 {CompileCondExpr: error compiling true arm} {
catch {expr 3>2?2***3:66} msg
@@ -169,10 +228,10 @@ test compExpr-old-3.8 {CompileCondExpr: long arms & nested cond exprs} {nonPorta
catch {unset xxx}
test compExpr-old-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1
-test compExpr-old-4.2 {CompileLorExpr: error in land expr} {
+test compExpr-old-4.2 {CompileLorExpr: error in land expr} -body {
catch {expr x&&3} msg
set msg
-} {syntax error in expression "x&&3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x&&3": * preceding $*}
test compExpr-old-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1
test compExpr-old-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1
test compExpr-old-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1
@@ -194,10 +253,10 @@ test compExpr-old-4.9 {CompileLorExpr: long lor arm} {
} 1
test compExpr-old-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23
-test compExpr-old-5.2 {CompileLandExpr: error in bitor expr} {
+test compExpr-old-5.2 {CompileLandExpr: error in bitor expr} -body {
catch {expr x|3} msg
set msg
-} {syntax error in expression "x|3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x|3": * preceding $*}
test compExpr-old-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0
test compExpr-old-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0
test compExpr-old-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1
@@ -220,10 +279,10 @@ test compExpr-old-5.10 {CompileLandExpr: long land arms} {
} 1
test compExpr-old-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3
-test compExpr-old-6.2 {CompileBitXorExpr: error in bitand expr} {
+test compExpr-old-6.2 {CompileBitXorExpr: error in bitand expr} -body {
catch {expr x|3} msg
set msg
-} {syntax error in expression "x|3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x|3": * preceding $*}
test compExpr-old-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20
test compExpr-old-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19
test compExpr-old-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7
@@ -232,10 +291,10 @@ test compExpr-old-6.7 {CompileBitXorExpr: error compiling bitxor arm} {
catch {expr 2***3|6} msg
set msg
} {syntax error in expression "2***3|6": unexpected operator *}
-test compExpr-old-6.8 {CompileBitXorExpr: error compiling bitxor arm} {
+test compExpr-old-6.8 {CompileBitXorExpr: error compiling bitxor arm} -body {
catch {expr 2^x} msg
set msg
-} {syntax error in expression "2^x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2^x": * preceding $*}
test compExpr-old-6.9 {CompileBitXorExpr: runtime error in bitxor arm} {
list [catch {expr {24.0^3}} msg] $msg
} {1 {can't use floating-point value as operand of "^"}}
@@ -247,10 +306,10 @@ test compExpr-old-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0
test compExpr-old-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1
test compExpr-old-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1
test compExpr-old-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0
-test compExpr-old-7.5 {CompileBitAndExpr: error in equality expr} {
+test compExpr-old-7.5 {CompileBitAndExpr: error in equality expr} -body {
catch {expr x==3} msg
set msg
-} {syntax error in expression "x==3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x==3": * preceding $*}
test compExpr-old-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3
test compExpr-old-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82
test compExpr-old-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2
@@ -259,10 +318,10 @@ test compExpr-old-7.10 {CompileBitAndExpr: error compiling bitand arm} {
catch {expr 2***3&6} msg
set msg
} {syntax error in expression "2***3&6": unexpected operator *}
-test compExpr-old-7.11 {CompileBitAndExpr: error compiling bitand arm} {
+test compExpr-old-7.11 {CompileBitAndExpr: error compiling bitand arm} -body {
catch {expr 2&x} msg
set msg
-} {syntax error in expression "2&x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2&x": * preceding $*}
test compExpr-old-7.12 {CompileBitAndExpr: runtime error in bitand arm} {
list [catch {expr {24.0&3}} msg] $msg
} {1 {can't use floating-point value as operand of "&"}}
@@ -274,10 +333,10 @@ test compExpr-old-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1
test compExpr-old-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1
test compExpr-old-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1
test compExpr-old-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0
-test compExpr-old-8.5 {CompileEqualityExpr: error in relational expr} {
+test compExpr-old-8.5 {CompileEqualityExpr: error in relational expr} -body {
catch {expr x>3} msg
set msg
-} {syntax error in expression "x>3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x>3": * preceding $*}
test compExpr-old-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0
test compExpr-old-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1
test compExpr-old-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1
@@ -286,10 +345,10 @@ test compExpr-old-8.10 {CompileEqualityExpr: error compiling equality arm} {
catch {expr 2***3==6} msg
set msg
} {syntax error in expression "2***3==6": unexpected operator *}
-test compExpr-old-8.11 {CompileEqualityExpr: error compiling equality arm} {
+test compExpr-old-8.11 {CompileEqualityExpr: error compiling equality arm} -body {
catch {expr 2!=x} msg
set msg
-} {syntax error in expression "2!=x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2!=x": * preceding $*}
test compExpr-old-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12
@@ -309,39 +368,39 @@ if {int(0x80000000) > 0} {
expr {1<<31}
} -2147483648
}
-test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} {
+test compExpr-old-9.6 {CompileRelationalExpr: error in shift expr} -body {
catch {expr x>>3} msg
set msg
-} {syntax error in expression "x>>3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x>>3": * preceding $*}
test compExpr-old-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1
test compExpr-old-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1
test compExpr-old-9.9 {CompileRelationalExpr: error compiling relational arm} {
catch {expr 2***3>6} msg
set msg
} {syntax error in expression "2***3>6": unexpected operator *}
-test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} {
+test compExpr-old-9.10 {CompileRelationalExpr: error compiling relational arm} -body {
catch {expr 2<x} msg
set msg
-} {syntax error in expression "2<x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2<x": * preceding $*}
test compExpr-old-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2
test compExpr-old-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253
test compExpr-old-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1
test compExpr-old-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82
-test compExpr-old-10.5 {CompileShiftExpr: error in add expr} {
+test compExpr-old-10.5 {CompileShiftExpr: error in add expr} -body {
catch {expr x+3} msg
set msg
-} {syntax error in expression "x+3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x+3": * preceding $*}
test compExpr-old-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31
test compExpr-old-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936
test compExpr-old-10.8 {CompileShiftExpr: error compiling shift arm} {
catch {expr 2***3>>6} msg
set msg
} {syntax error in expression "2***3>>6": unexpected operator *}
-test compExpr-old-10.9 {CompileShiftExpr: error compiling shift arm} {
+test compExpr-old-10.9 {CompileShiftExpr: error compiling shift arm} -body {
catch {expr 2<<x} msg
set msg
-} {syntax error in expression "2<<x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2<<x": * preceding $*}
test compExpr-old-10.10 {CompileShiftExpr: runtime error} {
list [catch {expr {24.0>>43}} msg] $msg
} {1 {can't use floating-point value as operand of ">>"}}
@@ -353,20 +412,20 @@ test compExpr-old-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8
test compExpr-old-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1
test compExpr-old-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1
test compExpr-old-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6
-test compExpr-old-11.5 {CompileAddExpr: error in multiply expr} {
+test compExpr-old-11.5 {CompileAddExpr: error in multiply expr} -body {
catch {expr x*3} msg
set msg
-} {syntax error in expression "x*3": variable references require preceding $}
+} -match glob -result {syntax error in expression "x*3": * preceding $*}
test compExpr-old-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258
test compExpr-old-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239
test compExpr-old-11.8 {CompileAddExpr: error compiling add arm} {
catch {expr 2***3+6} msg
set msg
} {syntax error in expression "2***3+6": unexpected operator *}
-test compExpr-old-11.9 {CompileAddExpr: error compiling add arm} {
+test compExpr-old-11.9 {CompileAddExpr: error compiling add arm} -body {
catch {expr 2-x} msg
set msg
-} {syntax error in expression "2-x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2-x": * preceding $*}
test compExpr-old-11.10 {CompileAddExpr: runtime error} {
list [catch {expr {24.0+"xx"}} msg] $msg
} {1 {can't use non-numeric string as operand of "+"}}
@@ -376,7 +435,10 @@ test compExpr-old-11.11 {CompileAddExpr: runtime error} {
test compExpr-old-11.12 {CompileAddExpr: runtime error} {
list [catch {expr {3/0}} msg] $msg
} {1 {divide by zero}}
-test compExpr-old-11.13 {CompileAddExpr: runtime error} {
+test compExpr-old-11.13a {CompileAddExpr: runtime error} ieeeFloatingPoint {
+ list [catch {expr {2.3/0.0}} msg] $msg
+} {0 Inf}
+test compExpr-old-11.13b {CompileAddExpr: runtime error} !ieeeFloatingPoint {
list [catch {expr {2.3/0.0}} msg] $msg
} {1 {divide by zero}}
@@ -384,20 +446,20 @@ test compExpr-old-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5
test compExpr-old-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5
test compExpr-old-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0
test compExpr-old-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936
-test compExpr-old-12.5 {CompileMultiplyExpr: error in unary expr} {
+test compExpr-old-12.5 {CompileMultiplyExpr: error in unary expr} -body {
catch {expr ~x} msg
set msg
-} {syntax error in expression "~x": variable references require preceding $}
+} -match glob -result {syntax error in expression "~x": * preceding $*}
test compExpr-old-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765
test compExpr-old-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2
test compExpr-old-12.8 {CompileMultiplyExpr: error compiling multiply arm} {
catch {expr 2*3%%6} msg
set msg
} {syntax error in expression "2*3%%6": unexpected operator %}
-test compExpr-old-12.9 {CompileMultiplyExpr: error compiling multiply arm} {
+test compExpr-old-12.9 {CompileMultiplyExpr: error compiling multiply arm} -body {
catch {expr 2*x} msg
set msg
-} {syntax error in expression "2*x": variable references require preceding $}
+} -match glob -result {syntax error in expression "2*x": * preceding $*}
test compExpr-old-12.10 {CompileMultiplyExpr: runtime error} {
list [catch {expr {24.0*"xx"}} msg] $msg
} {1 {can't use non-numeric string as operand of "*"}}
@@ -412,10 +474,10 @@ test compExpr-old-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0
test compExpr-old-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0
test compExpr-old-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1
test compExpr-old-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0
-test compExpr-old-13.8 {CompileUnaryExpr: error compiling unary expr} {
+test compExpr-old-13.8 {CompileUnaryExpr: error compiling unary expr} -body {
catch {expr ~x} msg
set msg
-} {syntax error in expression "~x": variable references require preceding $}
+} -match glob -result {syntax error in expression "~x": * preceding $*}
test compExpr-old-13.9 {CompileUnaryExpr: error compiling unary expr} {
catch {expr !1.x} msg
set msg
@@ -529,7 +591,7 @@ test compExpr-old-14.26 {CompilePrimaryExpr: math function primary} {
test compExpr-old-14.27 {CompilePrimaryExpr: error in math function primary} -body {
catch {expr sinh::(2.0)} msg
set errorInfo
-} -match glob -result {syntax error in expression "sinh::(2.0)": expected parenthesis enclosing function arguments
+} -match glob -result {syntax error in expression "sinh::(2.0)": * function arguments*
while *ing
"expr sinh::(2.0)"}
test compExpr-old-14.28 {CompilePrimaryExpr: subexpression primary} {
@@ -561,31 +623,31 @@ test compExpr-old-14.32 {CompilePrimaryExpr: unexpected token} -body {
test compExpr-old-15.1 {CompileMathFuncCall: missing parenthesis} -body {
catch {expr sinh2.0)} msg
set errorInfo
-} -match glob -result {syntax error in expression "sinh2.0)": variable references require preceding $
+} -match glob -result {syntax error in expression "sinh2.0)": * preceding $*
while *ing
"expr sinh2.0)"}
test compExpr-old-15.2 {CompileMathFuncCall: unknown math function} -body {
catch {expr whazzathuh(1)} msg
set errorInfo
-} -match glob -result {unknown math function "whazzathuh"
+} -match glob -result {* "*whazzathuh"
while *ing
"expr whazzathuh(1)"}
test compExpr-old-15.3 {CompileMathFuncCall: too many arguments} -body {
catch {expr sin(1,2,3)} msg
set errorInfo
-} -match glob -result {too many arguments for math function
+} -match glob -result {too many arguments for math function*
while *ing
"expr sin(1,2,3)"}
test compExpr-old-15.4 {CompileMathFuncCall: ')' found before last required arg} -body {
catch {expr sin()} msg
set errorInfo
-} -match glob -result {too few arguments for math function
+} -match glob -result {too few arguments for math function*
while *ing
"expr sin()"}
test compExpr-old-15.5 {CompileMathFuncCall: too few arguments} -body {
catch {expr pow(1)} msg
set errorInfo
-} -match glob -result {too few arguments for math function
+} -match glob -result {too few arguments for math function*
while *ing
"expr pow(1)"}
test compExpr-old-15.6 {CompileMathFuncCall: missing ')'} -body {