📄 expr.test
字号:
test expr-6.5 {CompileBitXorExpr: simple bitxor exprs} {expr 0^7} 7test expr-6.6 {CompileBitXorExpr: simple bitxor exprs} {expr -1^7} -8test expr-6.7 {CompileBitXorExpr: error compiling bitxor arm} { catch {expr 2**3|6} msg set msg} {syntax error in expression "2**3|6"}test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} { catch {expr 2^x} msg set msg} {syntax error in expression "2^x"}test expr-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 "^"}}test expr-6.10 {CompileBitXorExpr: runtime error in bitxor arm} { list [catch {expr {"a"^"b"}} msg] $msg} {1 {can't use non-numeric string as operand of "^"}}test expr-7.1 {CompileBitAndExpr: just equality expr} {expr 3==2} 0test expr-7.2 {CompileBitAndExpr: just equality expr} {expr 2.0==2} 1test expr-7.3 {CompileBitAndExpr: just equality expr} {expr 3.2!=2.2} 1test expr-7.4 {CompileBitAndExpr: just equality expr} {expr {"abc" == "abd"}} 0test expr-7.5 {CompileBitAndExpr: error in equality expr} { catch {expr x==3} msg set msg} {syntax error in expression "x==3"} test expr-7.6 {CompileBitAndExpr: simple bitand exprs} {expr 7&0x13} 3test expr-7.7 {CompileBitAndExpr: simple bitand exprs} {expr 0xf2&0x53} 82test expr-7.8 {CompileBitAndExpr: simple bitand exprs} {expr 3&6} 2test expr-7.9 {CompileBitAndExpr: simple bitand exprs} {expr -1&-7} -7test expr-7.10 {CompileBitAndExpr: error compiling bitand arm} { catch {expr 2**3&6} msg set msg} {syntax error in expression "2**3&6"}test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} { catch {expr 2&x} msg set msg} {syntax error in expression "2&x"}test expr-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 "&"}}test expr-7.13 {CompileBitAndExpr: runtime error in bitand arm} { list [catch {expr {"a"&"b"}} msg] $msg} {1 {can't use non-numeric string as operand of "&"}}test expr-8.1 {CompileEqualityExpr: just relational expr} {expr 3>=2} 1test expr-8.2 {CompileEqualityExpr: just relational expr} {expr 2<=2.1} 1test expr-8.3 {CompileEqualityExpr: just relational expr} {expr 3.2>"2.2"} 1test expr-8.4 {CompileEqualityExpr: just relational expr} {expr {"0y"<"0x12"}} 0test expr-8.5 {CompileEqualityExpr: error in relational expr} { catch {expr x>3} msg set msg} {syntax error in expression "x>3"} test expr-8.6 {CompileEqualityExpr: simple equality exprs} {expr 7==0x13} 0test expr-8.7 {CompileEqualityExpr: simple equality exprs} {expr -0xf2!=0x53} 1test expr-8.8 {CompileEqualityExpr: simple equality exprs} {expr {"12398712938788234-1298379" != ""}} 1test expr-8.9 {CompileEqualityExpr: simple equality exprs} {expr -1!="abc"} 1test expr-8.10 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2**3==6} msg set msg} {syntax error in expression "2**3==6"}test expr-8.11 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2!=x} msg set msg} {syntax error in expression "2!=x"}test expr-9.1 {CompileRelationalExpr: just shift expr} {expr 3<<2} 12test expr-9.2 {CompileRelationalExpr: just shift expr} {expr 0xff>>2} 63test expr-9.3 {CompileRelationalExpr: just shift expr} {expr -1>>2} -1test expr-9.4 {CompileRelationalExpr: just shift expr} {expr {1<<3}} 8# The following test is different for 32-bit versus 64-bit# architectures because LONG_MIN is differentif {0x80000000 > 0} { test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} { expr {1<<63} } -9223372036854775808} else { test expr-9.5 {CompileRelationalExpr: shift expr producing LONG_MIN} {nonPortable} { expr {1<<31} } -2147483648}test expr-9.6 {CompileRelationalExpr: error in shift expr} { catch {expr x>>3} msg set msg} {syntax error in expression "x>>3"} test expr-9.7 {CompileRelationalExpr: simple relational exprs} {expr 0xff>=+0x3} 1test expr-9.8 {CompileRelationalExpr: simple relational exprs} {expr -0xf2<0x3} 1test expr-9.9 {CompileRelationalExpr: error compiling relational arm} { catch {expr 2**3>6} msg set msg} {syntax error in expression "2**3>6"}test expr-9.10 {CompileRelationalExpr: error compiling relational arm} { catch {expr 2<x} msg set msg} {syntax error in expression "2<x"}test expr-10.1 {CompileShiftExpr: just add expr} {expr 4+-2} 2test expr-10.2 {CompileShiftExpr: just add expr} {expr 0xff-2} 253test expr-10.3 {CompileShiftExpr: just add expr} {expr -1--2} 1test expr-10.4 {CompileShiftExpr: just add expr} {expr 1-0123} -82test expr-10.5 {CompileShiftExpr: error in add expr} { catch {expr x+3} msg set msg} {syntax error in expression "x+3"}test expr-10.6 {CompileShiftExpr: simple shift exprs} {expr 0xff>>0x3} 31test expr-10.7 {CompileShiftExpr: simple shift exprs} {expr -0xf2<<0x3} -1936test expr-10.8 {CompileShiftExpr: error compiling shift arm} { catch {expr 2**3>>6} msg set msg} {syntax error in expression "2**3>>6"}test expr-10.9 {CompileShiftExpr: error compiling shift arm} { catch {expr 2<<x} msg set msg} {syntax error in expression "2<<x"}test expr-10.10 {CompileShiftExpr: runtime error} { list [catch {expr {24.0>>43}} msg] $msg} {1 {can't use floating-point value as operand of ">>"}}test expr-10.11 {CompileShiftExpr: runtime error} { list [catch {expr {"a"<<"b"}} msg] $msg} {1 {can't use non-numeric string as operand of "<<"}}test expr-11.1 {CompileAddExpr: just multiply expr} {expr 4*-2} -8test expr-11.2 {CompileAddExpr: just multiply expr} {expr 0xff%2} 1test expr-11.3 {CompileAddExpr: just multiply expr} {expr -1/2} -1test expr-11.4 {CompileAddExpr: just multiply expr} {expr 7891%0123} 6test expr-11.5 {CompileAddExpr: error in multiply expr} { catch {expr x*3} msg set msg} {syntax error in expression "x*3"}test expr-11.6 {CompileAddExpr: simple add exprs} {expr 0xff++0x3} 258test expr-11.7 {CompileAddExpr: simple add exprs} {expr -0xf2--0x3} -239test expr-11.8 {CompileAddExpr: error compiling add arm} { catch {expr 2**3+6} msg set msg} {syntax error in expression "2**3+6"}test expr-11.9 {CompileAddExpr: error compiling add arm} { catch {expr 2-x} msg set msg} {syntax error in expression "2-x"}test expr-11.10 {CompileAddExpr: runtime error} { list [catch {expr {24.0+"xx"}} msg] $msg} {1 {can't use non-numeric string as operand of "+"}}test expr-11.11 {CompileAddExpr: runtime error} { list [catch {expr {"a"-"b"}} msg] $msg} {1 {can't use non-numeric string as operand of "-"}}test expr-11.12 {CompileAddExpr: runtime error} { list [catch {expr {3/0}} msg] $msg} {1 {divide by zero}}test expr-11.13 {CompileAddExpr: runtime error} { list [catch {expr {2.3/0.0}} msg] $msg} {1 {divide by zero}}test expr-12.1 {CompileMultiplyExpr: just unary expr} {expr ~4} -5test expr-12.2 {CompileMultiplyExpr: just unary expr} {expr --5} 5test expr-12.3 {CompileMultiplyExpr: just unary expr} {expr !27} 0test expr-12.4 {CompileMultiplyExpr: just unary expr} {expr ~0xff00ff} -16711936test expr-12.5 {CompileMultiplyExpr: error in unary expr} { catch {expr ~x} msg set msg} {syntax error in expression "~x"}test expr-12.6 {CompileMultiplyExpr: simple multiply exprs} {expr 0xff*0x3} 765test expr-12.7 {CompileMultiplyExpr: simple multiply exprs} {expr -0xf2%-0x3} -2test expr-12.8 {CompileMultiplyExpr: error compiling multiply arm} { catch {expr 2*3%%6} msg set msg} {syntax error in expression "2*3%%6"}test expr-12.9 {CompileMultiplyExpr: error compiling multiply arm} { catch {expr 2*x} msg set msg} {syntax error in expression "2*x"}test expr-12.10 {CompileMultiplyExpr: runtime error} { list [catch {expr {24.0*"xx"}} msg] $msg} {1 {can't use non-numeric string as operand of "*"}}test expr-12.11 {CompileMultiplyExpr: runtime error} { list [catch {expr {"a"/"b"}} msg] $msg} {1 {can't use non-numeric string as operand of "/"}}test expr-13.1 {CompileUnaryExpr: unary exprs} {expr -0xff} -255test expr-13.2 {CompileUnaryExpr: unary exprs} {expr +000123} 83test expr-13.3 {CompileUnaryExpr: unary exprs} {expr +--++36} 36test expr-13.4 {CompileUnaryExpr: unary exprs} {expr !2} 0test expr-13.5 {CompileUnaryExpr: unary exprs} {expr +--+-62.0} -62.0test expr-13.6 {CompileUnaryExpr: unary exprs} {expr !0.0} 1test expr-13.7 {CompileUnaryExpr: unary exprs} {expr !0xef} 0test expr-13.8 {CompileUnaryExpr: error compiling unary expr} { catch {expr ~x} msg set msg} {syntax error in expression "~x"}test expr-13.9 {CompileUnaryExpr: error compiling unary expr} { catch {expr !1.x} msg set msg} {syntax error in expression "!1.x"}test expr-13.10 {CompileUnaryExpr: runtime error} { list [catch {expr {~"xx"}} msg] $msg} {1 {can't use non-numeric string as operand of "~"}}test expr-13.11 {CompileUnaryExpr: runtime error} { list [catch {expr ~4.0} msg] $msg} {1 {can't use floating-point value as operand of "~"}}test expr-13.12 {CompileUnaryExpr: just primary expr} {expr 0x123} 291test expr-13.13 {CompileUnaryExpr: just primary expr} { set a 27 expr $a} 27test expr-13.14 {CompileUnaryExpr: just primary expr} { expr double(27)} 27.0test expr-13.15 {CompileUnaryExpr: just primary expr} {expr "123"} 123test expr-13.16 {CompileUnaryExpr: error in primary expr} { catch {expr [set]} msg set msg} {wrong # args: should be "set varName ?newValue?"}test expr-14.1 {CompilePrimaryExpr: literal primary} {expr 1} 1test expr-14.2 {CompilePrimaryExpr: literal primary} {expr 123} 123test expr-14.3 {CompilePrimaryExpr: literal primary} {expr 0xff} 255test expr-14.4 {CompilePrimaryExpr: literal primary} {expr 00010} 8test expr-14.5 {CompilePrimaryExpr: literal primary} {expr 62.0} 62.0test expr-14.6 {CompilePrimaryExpr: literal primary} { expr 3.1400000} 3.14test expr-14.7 {CompilePrimaryExpr: literal primary} {expr {{abcde}<{abcdef}}} 1test expr-14.8 {CompilePrimaryExpr: literal primary} {expr {{abc\def} < {abcdef}}} 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -