expr.test
来自「tcl是工具命令语言」· TEST 代码 · 共 301 行 · 第 1/2 页
TEST
301 行
test expr-3.4 {CompileCondExpr: error compiling true arm} { catch {expr 3>2?2**3:66} msg set msg} {syntax error in expression "3>2?2**3:66": unexpected operator *}test expr-3.5 {CompileCondExpr: test false arm} {expr 2>3?44:66} 66test expr-3.6 {CompileCondExpr: error compiling false arm} { catch {expr 2>3?44:2**3} msg set msg} {syntax error in expression "2>3?44:2**3": unexpected operator *}test expr-3.7 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} { puts "Note: doing test expr-3.7 which can take several minutes to run" hello_world} {Hello world}catch {unset xxx}test expr-3.8 {CompileCondExpr: long arms & nested cond exprs} {unixOnly nonPortable} { puts "Note: doing test expr-3.8 which can take several minutes to run" do_twelve_days} 2358catch {unset xxx}test expr-4.1 {CompileLorExpr: just land expr} {expr 1.3&&3.3} 1test expr-4.2 {CompileLorExpr: error in land expr} { catch {expr x&&3} msg set msg} {syntax error in expression "x&&3": variable references require preceding $} test expr-4.3 {CompileLorExpr: simple lor exprs} {expr 0||1.0} 1test expr-4.4 {CompileLorExpr: simple lor exprs} {expr 3.0||0.0} 1test expr-4.5 {CompileLorExpr: simple lor exprs} {expr 0||0||1} 1test expr-4.6 {CompileLorExpr: error compiling lor arm} { catch {expr 2**3||4.0} msg set msg} {syntax error in expression "2**3||4.0": unexpected operator *}test expr-4.7 {CompileLorExpr: error compiling lor arm} { catch {expr 1.3||2**3} msg set msg} {syntax error in expression "1.3||2**3": unexpected operator *}test expr-4.8 {CompileLorExpr: error compiling lor arms} { list [catch {expr {"a"||"b"}} msg] $msg} {1 {expected boolean value but got "a"}}test expr-4.9 {CompileLorExpr: long lor arm} { set a "abcdefghijkl" set i 7 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]]}} 1test expr-5.1 {CompileLandExpr: just bitor expr} {expr 7|0x13} 23test expr-5.2 {CompileLandExpr: error in bitor expr} { catch {expr x|3} msg set msg} {syntax error in expression "x|3": variable references require preceding $} test expr-5.3 {CompileLandExpr: simple land exprs} {expr 0&&1.0} 0test expr-5.4 {CompileLandExpr: simple land exprs} {expr 0&&0} 0test expr-5.5 {CompileLandExpr: simple land exprs} {expr 3.0&&1.2} 1test expr-5.6 {CompileLandExpr: simple land exprs} {expr 1&&1&&2} 1test expr-5.7 {CompileLandExpr: error compiling land arm} { catch {expr 2**3&&4.0} msg set msg} {syntax error in expression "2**3&&4.0": unexpected operator *}test expr-5.8 {CompileLandExpr: error compiling land arm} { catch {expr 1.3&&2**3} msg set msg} {syntax error in expression "1.3&&2**3": unexpected operator *}test expr-5.9 {CompileLandExpr: error compiling land arm} { list [catch {expr {"a"&&"b"}} msg] $msg} {1 {expected boolean value but got "a"}}test expr-5.10 {CompileLandExpr: long land arms} { set a "abcdefghijkl" set i 7 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]]}} 1test expr-6.1 {CompileBitXorExpr: just bitand expr} {expr 7&0x13} 3test expr-6.2 {CompileBitXorExpr: error in bitand expr} { catch {expr x|3} msg set msg} {syntax error in expression "x|3": variable references require preceding $} test expr-6.3 {CompileBitXorExpr: simple bitxor exprs} {expr 7^0x13} 20test expr-6.4 {CompileBitXorExpr: simple bitxor exprs} {expr 3^0x10} 19test 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": unexpected operator *}test expr-6.8 {CompileBitXorExpr: error compiling bitxor arm} { catch {expr 2^x} msg set msg} {syntax error in expression "2^x": variable references require preceding $}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": variable references require preceding $}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": unexpected operator *}test expr-7.11 {CompileBitAndExpr: error compiling bitand arm} { catch {expr 2&x} msg set msg} {syntax error in expression "2&x": variable references require preceding $}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-7.14 {CompileBitAndExpr: equality expr} {expr 3eq2} 0test expr-7.18 {CompileBitAndExpr: equality expr} {expr {"abc" eq "abd"}} 0test expr-7.20 {CompileBitAndExpr: error in equality expr} { catch {expr xne3} msg set msg} {syntax error in expression "xne3": variable references require preceding $} 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": variable references require preceding $}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": unexpected operator *}test expr-8.11 {CompileEqualityExpr: error compiling equality arm} { catch {expr 2!=x} msg set msg} {syntax error in expression "2!=x": variable references require preceding $}test expr-8.14 {CompileBitAndExpr: equality expr} {expr {"a"eq"a"}} 1test expr-8.14 {CompileBitAndExpr: equality expr} {expr {"\374" eq "
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?