⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parseold.test

📁 tcl是工具命令语言
💻 TEST
📖 第 1 页 / 共 2 页
字号:
    getArgs a;set b 2    set argv} atest parseOld-8.2 {semi-colons} {    set b 0    getArgs a;set b 2    set b} 2test parseOld-8.3 {semi-colons} {    getArgs a b ; set b 1    set argv} {a b}test parseOld-8.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 parseOld-9.1 {result initialization} {concat abc} abctest parseOld-9.2 {result initialization} {concat abc; proc foo {} {}} {}test parseOld-9.3 {result initialization} {concat abc; proc foo {} $a} {}test parseOld-9.4 {result initialization} {proc foo {} [concat abc]} {}test parseOld-9.5 {result initialization} {concat abc; } abctest parseOld-9.6 {result initialization} {    eval {    concat abc}} abctest parseOld-9.7 {result initialization} {} {}test parseOld-9.8 {result initialization} {concat abc; ; ;} abc# Syntax errors.test parseOld-10.1 {syntax errors} {catch "set a \{bcd" msg} 1test parseOld-10.2 {syntax errors} {	catch "set a \{bcd" msg	set msg} {missing close-brace}test parseOld-10.3 {syntax errors} {catch {set a "bcd} msg} 1test parseOld-10.4 {syntax errors} {	catch {set a "bcd} msg	set msg} {missing "}test parseOld-10.5 {syntax errors} {catch {set a "bcd"xy} msg} 1test parseOld-10.6 {syntax errors} {	catch {set a "bcd"xy} msg	set msg} {extra characters after close-quote}test parseOld-10.7 {syntax errors} {catch "set a {bcd}xy" msg} 1test parseOld-10.8 {syntax errors} {	catch "set a {bcd}xy" msg	set msg} {extra characters after close-brace}test parseOld-10.9 {syntax errors} {catch {set a [format abc} msg} 1test parseOld-10.10 {syntax errors} {	catch {set a [format abc} msg	set msg} {missing close-bracket}test parseOld-10.11 {syntax errors} {catch gorp-a-lot msg} 1test parseOld-10.12 {syntax errors} {	catch gorp-a-lot msg	set msg} {invalid command name "gorp-a-lot"}test parseOld-10.13 {syntax errors} {    set a [concat {a}\ {b}]    set a} {a b}# The next test will fail on the Mac, 'cause the MSL uses a fixed sized# buffer for %d conversions (LAME!).  I won't leave the test out, however,# since MetroWerks may some day fix this.test parseOld-10.14 {syntax errors} {    list [catch {eval \$x[format "%01000d" 0](} msg] $msg $errorInfo} {1 {missing )} {missing )    while executing"$x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000..."    ("eval" body line 1)    invoked from within"eval \$x[format "%01000d" 0]("}}test parseOld-10.15 {syntax errors, missplaced braces} {    catch {        proc misplaced_end_brace {} {            set what foo            set when [expr ${what}size - [set off$what]}]    } msg    set msg} {extra characters after close-brace}test parseOld-10.16 {syntax errors, missplaced braces} {    catch {        set a {            set what foo            set when [expr ${what}size - [set off$what]}]    } msg    set msg} {extra characters after close-brace}test parseOld-10.17 {syntax errors, unusual spacing} {    list [catch {return [ [1]]} msg] $msg} {1 {invalid command name "1"}}# 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 parseOld-11.1 {long values} {    string length $a} 214test parseOld-11.2 {long values} {    llength $a} 43test parseOld-11.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 parseOld-11.4 {long values} {    set b "$a"    set b} $atest parseOld-11.5 {long values} {    set b [set a]    set b} $atest parseOld-11.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 parseOld-11.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 parseOld-11.8 {long values} {    set b} $atest parseOld-11.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 parseOld-11.10 {long values} {	set j    } $test}test parseOld-11.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 parseOld-12.1 {comments} {    set a old    eval {  # set a new}    set a} {old}test parseOld-12.2 {comments} {    set a old    eval "  # set a new\nset a new"    set a} {new}test parseOld-12.3 {comments} {    set a old    eval "  # set a new\\\nset a new"    set a} {old}test parseOld-12.4 {comments} {    set a old    eval "  # set a new\\\\\nset a new"    set a} {new}test parseOld-13.1 {comments at the end of a bracketed script} {    set x "[expr 1+1# skip this!]"} {2}test parseOld-14.1 {TclWordEnd procedure} {testwordend} {    testwordend " 	\n abc"} {c}test parseOld-14.2 {TclWordEnd procedure} {testwordend} {    testwordend "   \\\n"} {}test parseOld-14.3 {TclWordEnd procedure} {testwordend} {    testwordend "   \\\n "} { }test parseOld-14.4 {TclWordEnd procedure} {testwordend} {    testwordend {"abc"}} {"}test parseOld-14.5 {TclWordEnd procedure} {testwordend} {    testwordend {{xyz}}} \}test parseOld-14.6 {TclWordEnd procedure} {testwordend} {    testwordend {{a{}b{}\}} xyz}} "\} xyz"test parseOld-14.7 {TclWordEnd procedure} {testwordend} {    testwordend {abc[this is a]def ghi}} {f ghi}test parseOld-14.8 {TclWordEnd procedure} {testwordend} {    testwordend "puts\\\n\n  "} "s\\\n\n  "test parseOld-14.9 {TclWordEnd procedure} {testwordend} {    testwordend "puts\\\n   	"} "s\\\n   	"test parseOld-14.10 {TclWordEnd procedure} {testwordend} {    testwordend "puts\\\n   	xyz"} "s\\\n   	xyz"test parseOld-14.11 {TclWordEnd procedure} {testwordend} {    testwordend {a$x.$y(a long index) foo}} ") foo"test parseOld-14.12 {TclWordEnd procedure} {testwordend} {    testwordend {abc; def}} {; def}test parseOld-14.13 {TclWordEnd procedure} {testwordend} {    testwordend {abc def}} {c def}test parseOld-14.14 {TclWordEnd procedure} {testwordend} {    testwordend {abc	def}} {c	def}test parseOld-14.15 {TclWordEnd procedure} {testwordend} {    testwordend "abc\ndef"} "c\ndef"test parseOld-14.16 {TclWordEnd procedure} {testwordend} {    testwordend "abc"} {c}test parseOld-14.17 {TclWordEnd procedure} {testwordend} {    testwordend "a\000bc"} {c}test parseOld-14.18 {TclWordEnd procedure} {testwordend} {    testwordend \[a\000\]} {]}test parseOld-14.19 {TclWordEnd procedure} {testwordend} {    testwordend \"a\000\"} {"}test parseOld-14.20 {TclWordEnd procedure} {testwordend} {    testwordend a{\000}b} {b}test parseOld-14.21 {TclWordEnd procedure} {testwordend} {    testwordend "   \000b"} {b}test parseOld-15.1 {TclScriptEnd procedure} {    info complete {puts [	expr 1+1	#this is a comment ]}} {0}test parseOld-15.2 {TclScriptEnd procedure} {    info complete "abc\\\n"} {0}test parseOld-15.3 {TclScriptEnd procedure} {    info complete "abc\\\\\n"} {1}test parseOld-15.4 {TclScriptEnd procedure} {    info complete "xyz \[abc \{abc\]"} {0}test parseOld-15.5 {TclScriptEnd procedure} {    info complete "xyz \[abc"} {0}# cleanupset argv $savedArgv::tcltest::cleanupTestsreturn

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -