📄 parse.test
字号:
} "abc\\"test parse-6.7 {backslash substitution} { eval "concat \\\na"} "a"test parse-6.8 {backslash substitution} { eval "concat x\\\n a"} "x a"test parse-6.9 {backslash substitution} { eval "concat \\x"} "x"test parse-6.10 {backslash substitution} { eval "list a b\\\nc d"} {a b c d}test parse-6.11 {backslash substitution} { eval "list a \"b c\"\\\nd e"} {a {b c} d e}# Semi-colon.test parse-7.1 {semi-colons} { set b 0 getArgs a;set b 2 set argv} atest parse-7.2 {semi-colons} { set b 0 getArgs a;set b 2 set b} 2test parse-7.3 {semi-colons} { getArgs a b ; set b 1 set argv} {a b}test parse-7.4 {semi-colons} { getArgs a b ; set b 1 set b} 1# The following checks are to ensure that the interpreter's result# gets re-initialized by Tcl_Eval in all the right places.test parse-8.1 {result initialization} {concat abc} abctest parse-8.2 {result initialization} {concat abc; proc foo {} {}} {}test parse-8.3 {result initialization} {concat abc; proc foo {} $a} {}test parse-8.4 {result initialization} {proc foo {} [concat abc]} {}test parse-8.5 {result initialization} {concat abc; } abctest parse-8.6 {result initialization} { eval { concat abc}} abctest parse-8.7 {result initialization} {} {}test parse-8.8 {result initialization} {concat abc; ; ;} abc# Syntax errors.test parse-9.1 {syntax errors} {catch "set a \{bcd" msg} 1test parse-9.2 {syntax errors} { catch "set a \{bcd" msg set msg} {missing close-brace}test parse-9.3 {syntax errors} {catch {set a "bcd} msg} 1test parse-9.4 {syntax errors} { catch {set a "bcd} msg set msg} {quoted string doesn't terminate properly}test parse-9.5 {syntax errors} {catch {set a "bcd"xy} msg} 1test parse-9.6 {syntax errors} { catch {set a "bcd"xy} msg set msg} {quoted string doesn't terminate properly}test parse-9.7 {syntax errors} {catch "set a {bcd}xy" msg} 1test parse-9.8 {syntax errors} { catch "set a {bcd}xy" msg set msg} {argument word in braces doesn't terminate properly}test parse-9.9 {syntax errors} {catch {set a [format abc} msg} 1test parse-9.10 {syntax errors} { catch {set a [format abc} msg set msg} {missing close-bracket or close-brace}test parse-9.11 {syntax errors} {catch gorp-a-lot msg} 1test parse-9.12 {syntax errors} { catch gorp-a-lot msg set msg} {invalid command name "gorp-a-lot"}test parse-9.13 {syntax errors} { set a [concat {a}\ {b}] set a} {a b}test parse-9.14 {syntax errors} { list [catch {eval \$x[format "%01000d" 0](} msg] $msg $errorInfo} {1 {missing )} {missing ) (parsing index for array "x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") while compiling"$x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ..." ("eval" body line 1) invoked from within"eval \$x[format "%01000d" 0]("}}test parse-9.15 {syntax errors, missplaced braces} { catch { proc misplaced_end_brace {} { set what foo set when [expr ${what}size - [set off$what]}] } msg set msg} {wrong # args: should be "proc name args body"}test parse-9.16 {syntax errors, missplaced braces} { catch { set a { set what foo set when [expr ${what}size - [set off$what]}] } msg set msg} {argument word in braces doesn't terminate properly}# Long values (stressing storage management)set a {1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH}test parse-10.1 {long values} { string length $a} 214test parse-10.2 {long values} { llength $a} 43test parse-10.3 {long values} { set b "1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH" set b} $atest parse-10.4 {long values} { set b "$a" set b} $atest parse-10.5 {long values} { set b [set a] set b} $atest parse-10.6 {long values} { set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH] string length $b} 214test parse-10.7 {long values} { set b [concat 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH] llength $b} 43test parse-10.8 {long values} { set b} $atest parse-10.9 {long values} { set a [concat 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ] llength $a} 62set i 0foreach j [concat 0000 1111 2222 3333 4444 5555 6666 7777 8888 9999 aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll mmmm nnnn oooo pppp qqqq rrrr ssss tttt uuuu vvvv wwww xxxx yyyy zzzz AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ] { set test [string index 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ $i] set test $test$test$test$test set i [expr $i+1] test parse-10.10 {long values} { set j } $test}test parse-10.11 {test buffer overflow in backslashes in braces} { expr {"a" == {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101\101}}} 0test parse-11.1 {comments} { set a old eval { # set a new} set a} {old}test parse-11.2 {comments} { set a old eval " # set a new\nset a new" set a} {new}test parse-11.3 {comments} { set a old eval " # set a new\\\nset a new" set a} {old}test parse-11.4 {comments} { set a old eval " # set a new\\\\\nset a new" set a} {new}test parse-12.1 {comments at the end of a bracketed script} { set x "[expr 1+1# skip this!]"} {2}if {[info command testwordend] == "testwordend"} { test parse-13.1 {TclWordEnd procedure} { testwordend " \n abc" } {c} test parse-13.2 {TclWordEnd procedure} { testwordend " \\\n" } {} test parse-13.3 {TclWordEnd procedure} { testwordend " \\\n " } { } test parse-13.4 {TclWordEnd procedure} { testwordend {"abc"} } {"} test parse-13.5 {TclWordEnd procedure} { testwordend {{xyz}} } \} test parse-13.6 {TclWordEnd procedure} { testwordend {{a{}b{}\}} xyz} } "\} xyz" test parse-13.7 {TclWordEnd procedure} { testwordend {abc[this is a]def ghi} } {f ghi} test parse-13.8 {TclWordEnd procedure} { testwordend "puts\\\n\n " } "s\\\n\n " test parse-13.9 {TclWordEnd procedure} { testwordend "puts\\\n " } "s\\\n " test parse-13.10 {TclWordEnd procedure} { testwordend "puts\\\n xyz" } "s\\\n xyz" test parse-13.11 {TclWordEnd procedure} { testwordend {a$x.$y(a long index) foo} } ") foo" test parse-13.12 {TclWordEnd procedure} { testwordend {abc; def} } {; def} test parse-13.13 {TclWordEnd procedure} { testwordend {abc def} } {c def} test parse-13.14 {TclWordEnd procedure} { testwordend {abc def} } {c def} test parse-13.15 {TclWordEnd procedure} { testwordend "abc\ndef" } "c\ndef" test parse-13.16 {TclWordEnd procedure} { testwordend "abc" } {c} test parse-13.17 {TclWordEnd procedure} { testwordend "a\000bc" } {c} test parse-13.18 {TclWordEnd procedure} { testwordend \[a\000\] } {]} test parse-13.19 {TclWordEnd procedure} { testwordend \"a\000\" } {"} test parse-13.20 {TclWordEnd procedure} { testwordend a{\000}b } {b} test parse-13.21 {TclWordEnd procedure} { testwordend " \000b" } {b}}test parse-14.1 {TclScriptEnd procedure} { info complete {puts [ expr 1+1 #this is a comment ]}} {0}test parse-14.2 {TclScriptEnd procedure} { info complete "abc\\\n"} {0}test parse-14.3 {TclScriptEnd procedure} { info complete "abc\\\\\n"} {1}test parse-14.4 {TclScriptEnd procedure} { info complete "xyz \[abc \{abc\]"} {0}test parse-14.5 {TclScriptEnd procedure} { info complete "xyz \[abc"} {0}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -