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

📄 iocmd.test

📁 tcl是工具命令语言
💻 TEST
📖 第 1 页 / 共 2 页
字号:
    uplevel {	close $cli	close $srv	unset cli srv port	rename iocmdSRV {}    }}test iocmd-8.15.0 {fconfigure command / tcp channel} {socket macOnly} {	iocmdSSETUP	set r [list [catch {fconfigure $cli -blah} msg] $msg]	iocmdSSHTDWN	set r} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -error, -peername, or -sockname}}test iocmd-8.15.1 {fconfigure command / tcp channel} {socket unixOrPc} {	iocmdSSETUP	set r [list [catch {fconfigure $cli -blah} msg] $msg]	iocmdSSHTDWN	set r} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -peername, or -sockname}}test iocmd-8.16 {fconfigure command / tcp channel} {socket} {	iocmdSSETUP	set r [expr [lindex [fconfigure $cli -peername] 2]==$port]	iocmdSSHTDWN	set r} 1test iocmd-8.17 {fconfigure command / tcp channel} {nonPortable} {	# It is possible that you don't get the connection reset by peer        # error but rather a valid answer. depends of the tcp implementation	iocmdSSETUP	update;	puts $cli "blah"; flush $cli; # that flush could/should fail too	update;	set r [catch {fconfigure $cli -peername} msg]	iocmdSSHTDWN	regsub -all {can([^:])+: } $r {} r;	set r} 1test iocmd-8.18 {fconfigure command / unix tty channel} {nonPortable unixOnly} {	# might fail if /dev/ttya is unavailable	set tty [open /dev/ttya]	set r [list [catch {fconfigure $tty -blah blih} msg] $msg];	close $tty;	set r;} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, or -mode}}test iocmd-8.19 {fconfigure command / win tty channel} {nonPortable pcOnly} {	# might fail if com1 is unavailable	set tty [open com1]	set r [list [catch {fconfigure $tty -blah blih} msg] $msg];	close $tty;	set r;} {1 {bad option "-blah": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -translation, -mode, or -pollinterval}}test iocmd-9.1 {eof command} {    list [catch {eof} msg] $msg $errorCode} {1 {wrong # args: should be "eof channelId"} NONE}test iocmd-9.2 {eof command} {    list [catch {eof a b} msg] $msg $errorCode} {1 {wrong # args: should be "eof channelId"} NONE}test iocmd-9.3 {eof command} {    catch {close file100}    list [catch {eof file100} msg] $msg $errorCode} {1 {can not find channel named "file100"} NONE}# The tests for Tcl_ExecObjCmd are in exec.testtest iocmd-10.1 {fblocked command} {    list [catch {fblocked} msg] $msg} {1 {wrong # args: should be "fblocked channelId"}}test iocmd-10.2 {fblocked command} {    list [catch {fblocked a b c d e f g} msg] $msg} {1 {wrong # args: should be "fblocked channelId"}}test iocmd-10.3 {fblocked command} {    list [catch {fblocked file1000} msg] $msg} {1 {can not find channel named "file1000"}}test iocmd-10.4 {fblocked command} {    list [catch {fblocked stdout} msg] $msg} {1 {channel "stdout" wasn't opened for reading}}test iocmd-10.5 {fblocked command} {    fblocked stdin} 0set path(test4) [makeFile {} test4]set path(test5) [makeFile {} test5]removeFile test5test iocmd-11.1 {I/O to command pipelines} {unixOrPc unixExecs} {    set f [open $path(test4) w]    close $f    list [catch {open "| cat < $path(test4) > $path(test5)" w} msg] $msg $errorCode} {1 {can't write input to command: standard input was redirected} NONE}test iocmd-11.2 {I/O to command pipelines} {unixOrPc unixExecs} {    list [catch {open "| echo > $path(test5)" r} msg] $msg $errorCode} {1 {can't read output from command: standard output was redirected} NONE}test iocmd-11.3 {I/O to command pipelines} {unixOrPc unixExecs} {    list [catch {open "| echo > $path(test5)" r+} msg] $msg $errorCode} {1 {can't read output from command: standard output was redirected} NONE}test iocmd-12.1 {POSIX open access modes: RDONLY} {    removeFile test1    set f [open $path(test1) w]    puts $f "Two lines: this one"    puts $f "and this one"    close $f    set f [open $path(test1) RDONLY]    set x [list [gets $f] [catch {puts $f Test} msg] $msg]    close $f    string compare $x \	"{Two lines: this one} 1 [list [format "channel \"%s\" wasn't opened for writing" $f]]"} 0test iocmd-12.2 {POSIX open access modes: RDONLY} {    removeFile test3    set msg [list [catch {open $path(test3) RDONLY} msg] $msg]    regsub [file join {} $path(test3)] $msg "test3" msg	string tolower $msg} {1 {couldn't open "test3": no such file or directory}}test iocmd-12.3 {POSIX open access modes: WRONLY} {    removeFile test3    set msg [list [catch {open $path(test3) WRONLY} msg] $msg]    regsub [file join {} $path(test3)] $msg "test3" msg	string tolower $msg} {1 {couldn't open "test3": no such file or directory}}## Test 13.4 relies on assigning the same channel name twice.#test iocmd-12.4 {POSIX open access modes: WRONLY} {unixOnly} {    removeFile test3    set f [open $path(test3) w]    fconfigure $f -eofchar {}    puts $f xyzzy    close $f    set f [open $path(test3) WRONLY]    fconfigure $f -eofchar {}    puts -nonewline $f "ab"    seek $f 0 current    set x [list [catch {gets $f} msg] $msg]    close $f    set f [open $path(test3) r]    fconfigure $f -eofchar {}    lappend x [gets $f]    close $f    set y [list 1 [format "channel \"%s\" wasn't opened for reading" $f] abzzy]    string compare $x $y} 0test iocmd-12.5 {POSIX open access modes: RDWR} {    removeFile test3    set msg [list [catch {open $path(test3) RDWR} msg] $msg]    regsub [file join {} $path(test3)] $msg "test3" msg	string tolower $msg} {1 {couldn't open "test3": no such file or directory}}test iocmd-12.6 {POSIX open access modes: errors} {    concat [catch {open $path(test3) "FOO \{BAR BAZ"} msg] $msg\n$errorInfo} "1 unmatched open brace in listunmatched open brace in list    while processing open access modes \"FOO {BAR BAZ\"    invoked from within\"open \$path(test3) \"FOO \\{BAR BAZ\"\""test iocmd-12.7 {POSIX open access modes: errors} {  list [catch {open $path(test3) {FOO BAR BAZ}} msg] $msg} {1 {invalid access mode "FOO": must be RDONLY, WRONLY, RDWR, APPEND, CREAT EXCL, NOCTTY, NONBLOCK, or TRUNC}}test iocmd-12.8 {POSIX open access modes: errors} {    list [catch {open $path(test3) {TRUNC CREAT}} msg] $msg} {1 {access mode must include either RDONLY, WRONLY, or RDWR}}test iocmd-13.1 {errors in open command} {    list [catch {open} msg] $msg} {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}test iocmd-13.2 {errors in open command} {    list [catch {open a b c d} msg] $msg} {1 {wrong # args: should be "open fileName ?access? ?permissions?"}}test iocmd-13.3 {errors in open command} {    list [catch {open $path(test1) x} msg] $msg} {1 {illegal access mode "x"}}test iocmd-13.4 {errors in open command} {    list [catch {open $path(test1) rw} msg] $msg} {1 {illegal access mode "rw"}}test iocmd-13.5 {errors in open command} {    list [catch {open $path(test1) r+1} msg] $msg} {1 {illegal access mode "r+1"}}test iocmd-13.6 {errors in open command} {    set msg [list [catch {open _non_existent_} msg] $msg $errorCode]    regsub [file join {} _non_existent_] $msg "_non_existent_" msg	string tolower $msg} {1 {couldn't open "_non_existent_": no such file or directory} {posix enoent {no such file or directory}}}test iocmd-14.1 {file id parsing errors} {    list [catch {eof gorp} msg] $msg $errorCode} {1 {can not find channel named "gorp"} NONE}test iocmd-14.2 {file id parsing errors} {    list [catch {eof filex} msg] $msg} {1 {can not find channel named "filex"}}test iocmd-14.3 {file id parsing errors} {    list [catch {eof file12a} msg] $msg} {1 {can not find channel named "file12a"}}test iocmd-14.4 {file id parsing errors} {    list [catch {eof file123} msg] $msg} {1 {can not find channel named "file123"}}test iocmd-14.5 {file id parsing errors} {    list [catch {eof stdout} msg] $msg} {0 0}test iocmd-14.6 {file id parsing errors} {    list [catch {eof stdin} msg] $msg} {0 0}test iocmd-14.7 {file id parsing errors} {    list [catch {eof stdout} msg] $msg} {0 0}test iocmd-14.8 {file id parsing errors} {    list [catch {eof stderr} msg] $msg} {0 0}test iocmd-14.9 {file id parsing errors} {    list [catch {eof stderr1} msg] $msg} {1 {can not find channel named "stderr1"}}set f [open $path(test1) w]close $fset expect "1 {can not find channel named \"$f\"}"test iocmd-14.10 {file id parsing errors} {    list [catch {eof $f} msg] $msg} $expecttest iocmd-15.1 {Tcl_FcopyObjCmd} {    list [catch {fcopy} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.2 {Tcl_FcopyObjCmd} {    list [catch {fcopy 1} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.3 {Tcl_FcopyObjCmd} {    list [catch {fcopy 1 2 3 4 5 6 7} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.4 {Tcl_FcopyObjCmd} {    list [catch {fcopy 1 2 3} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}test iocmd-15.5 {Tcl_FcopyObjCmd} {    list [catch {fcopy 1 2 3 4 5} msg] $msg} {1 {wrong # args: should be "fcopy input output ?-size size? ?-command callback?"}}set path(test2) [makeFile {} test2]set f [open $path(test1) w]close $fset rfile [open $path(test1) r]set wfile [open $path(test2) w]test iocmd-15.6 {Tcl_FcopyObjCmd} {    list [catch {fcopy foo $wfile} msg] $msg} {1 {can not find channel named "foo"}}test iocmd-15.7 {Tcl_FcopyObjCmd} {    list [catch {fcopy $rfile foo} msg] $msg} {1 {can not find channel named "foo"}}test iocmd-15.8 {Tcl_FcopyObjCmd} {    list [catch {fcopy $wfile $wfile} msg] $msg} "1 {channel \"$wfile\" wasn't opened for reading}"test iocmd-15.9 {Tcl_FcopyObjCmd} {    list [catch {fcopy $rfile $rfile} msg] $msg} "1 {channel \"$rfile\" wasn't opened for writing}"test iocmd-15.10 {Tcl_FcopyObjCmd} {    list [catch {fcopy $rfile $wfile foo bar} msg] $msg} {1 {bad switch "foo": must be -size or -command}}test iocmd-15.11 {Tcl_FcopyObjCmd} {    list [catch {fcopy $rfile $wfile -size foo} msg] $msg} {1 {expected integer but got "foo"}}test iocmd-15.12 {Tcl_FcopyObjCmd} {    list [catch {fcopy $rfile $wfile -command bar -size foo} msg] $msg} {1 {expected integer but got "foo"}}close $rfileclose $wfile# cleanupforeach file [list test1 test2 test3 test4] {    catch {::tcltest::removeFile $file}}# delay long enough for background processes to finishafter 500foreach file [list test5 pipe output] {    catch {::tcltest::removeFile $file}}::tcltest::cleanupTestsreturn

⌨️ 快捷键说明

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