📄 filename.test
字号:
set temp $env(HOME) set env(HOME) "Root:home:" testsetplatform mac set result [list [catch {testtranslatefilename ~::foo} msg] $msg] set env(HOME) $temp set result} {0 Root:home::foo}test filename-10.16 {Tcl_TranslateFileName} { global env set temp $env(HOME) set env(HOME) "Root:home::" testsetplatform mac set result [list [catch {testtranslatefilename ~::foo} msg] $msg] set env(HOME) $temp set result} {0 Root:home:::foo}test filename-10.17 {Tcl_TranslateFileName} { global env set temp $env(HOME) set env(HOME) "\\home\\" testsetplatform windows set result [list [catch {testtranslatefilename ~/foo} msg] $msg] set env(HOME) $temp set result} {0 {\home\foo}}test filename-10.18 {Tcl_TranslateFileName} { global env set temp $env(HOME) set env(HOME) "\\home\\" testsetplatform windows set result [list [catch {testtranslatefilename ~/foo\\bar} msg] $msg] set env(HOME) $temp set result} {0 {\home\foo\bar}}test filename-10.19 {Tcl_TranslateFileName} { global env set temp $env(HOME) set env(HOME) "c:" testsetplatform windows set result [list [catch {testtranslatefilename ~/foo} msg] $msg] set env(HOME) $temp set result} {0 c:foo}test filename-10.20 {Tcl_TranslateFileName} { list [catch {testtranslatefilename ~blorp/foo} msg] $msg} {1 {user "blorp" doesn't exist}}test filename-10.21 {Tcl_TranslateFileName} { global env set temp $env(HOME) set env(HOME) "c:\\" testsetplatform windows set result [list [catch {testtranslatefilename ~/foo} msg] $msg] set env(HOME) $temp set result} {0 {c:\foo}}test filename-10.22 {Tcl_TranslateFileName} { testsetplatform windows list [catch {testtranslatefilename foo//bar} msg] $msg} {0 {foo\bar}}testsetplatform $platformtest filename-10.23 {Tcl_TranslateFileName} {nonPortable unixOnly} { # this test fails if ~ouster is not /home/ouster list [catch {testtranslatefilename ~ouster} msg] $msg} {0 /home/ouster}test filename-10.24 {Tcl_TranslateFileName} {nonPortable unixOnly} { # this test fails if ~ouster is not /home/ouster list [catch {testtranslatefilename ~ouster/foo} msg] $msg} {0 /home/ouster/foo}test filename-11.1 {Tcl_GlobCmd} { list [catch {glob} msg] $msg} {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}test filename-11.2 {Tcl_GlobCmd} { list [catch {glob -gorp} msg] $msg} {1 {bad switch "-gorp": must be -nocomplain or --}}test filename-11.3 {Tcl_GlobCmd} { list [catch {glob -nocomplai} msg] $msg} {1 {bad switch "-nocomplai": must be -nocomplain or --}}test filename-11.4 {Tcl_GlobCmd} { list [catch {glob -nocomplain} msg] $msg} {1 {wrong # args: should be "glob ?switches? name ?name ...?"}}test filename-11.5 {Tcl_GlobCmd} { list [catch {glob -nocomplain ~xyqrszzz} msg] $msg} {0 {}}test filename-11.6 {Tcl_GlobCmd} { list [catch {glob ~xyqrszzz} msg] $msg} {1 {user "xyqrszzz" doesn't exist}}test filename-11.7 {Tcl_GlobCmd} { list [catch {glob -- -nocomplain} msg] $msg} {1 {no files matched glob patterns "-nocomplain"}}test filename-11.8 {Tcl_GlobCmd} { list [catch {glob -nocomplain -- -nocomplain} msg] $msg} {0 {}}test filename-11.9 {Tcl_GlobCmd} { testsetplatform unix list [catch {glob ~\\xyqrszzz/bar} msg] $msg} {1 {globbing characters not supported in user names}}test filename-11.10 {Tcl_GlobCmd} { testsetplatform unix list [catch {glob -nocomplain ~\\xyqrszzz/bar} msg] $msg} {0 {}}test filename-11.11 {Tcl_GlobCmd} { testsetplatform unix list [catch {glob ~xyqrszzz\\/\\bar} msg] $msg} {1 {user "xyqrszzz" doesn't exist}}test filename-11.12 {Tcl_GlobCmd} { testsetplatform unix set home $env(HOME) unset env(HOME) set x [list [catch {glob ~/*} msg] $msg] set env(HOME) $home set x} {1 {couldn't find HOME environment variable to expand path}}testsetplatform $platformtest filename-11.13 {Tcl_GlobCmd} { list [catch {file join [lindex [glob ~] 0]} msg] $msg} [list 0 [file join $env(HOME)]]set oldhome $env(HOME)set env(HOME) [pwd]file delete -force globTestfile mkdir globTest/a1/b1file mkdir globTest/a1/b2file mkdir globTest/a2/b3file mkdir globTest/a3close [open globTest/x1.c w]close [open globTest/y1.c w]close [open globTest/z1.c w]close [open "globTest/weird name.c" w]close [open globTest/a1/b1/x2.c w]close [open globTest/a1/b2/y2.c w]# Cannot create a file with the following names under Win32s. We have to# skip the tests that are checking the difference between a "." or "," in# the file name vs. a "." or "," in the glob pattern.catch {close [open globTest/.1 w]}catch {close [open globTest/x,z1.c w]}test filename-11.14 {Tcl_GlobCmd} { list [catch {glob ~/globTest} msg] $msg} [list 0 [list [file join $env(HOME) globTest]]]test filename-11.15 {Tcl_GlobCmd} { list [catch {glob ~\\/globTest} msg] $msg} [list 0 [list [file join $env(HOME) globTest]]]test filename-11.16 {Tcl_GlobCmd} { list [catch {glob globTest} msg] $msg} {0 globTest}test filename-12.1 {simple globbing} {unixOrPc} { list [catch {glob {}} msg] $msg} {0 .}test filename-12.2 {simple globbing} {macOnly} { list [catch {glob {}} msg] $msg} {0 :}test filename-12.3 {simple globbing} { list [catch {glob -nocomplain \{a1,a2\}} msg] $msg} {0 {}}if {$tcl_platform(platform) == "macintosh"} { set globPreResult :globTest:} else { set globPreResult globTest/}set x1 x1.cset y1 y1.ctest filename-12.4 {simple globbing} {unixOrPc} { lsort [glob globTest/x1.c globTest/y1.c globTest/foo]} "$globPreResult$x1 $globPreResult$y1"test filename-12.5 {simple globbing} { list [catch {glob globTest\\/x1.c} msg] $msg} "0 $globPreResult$x1"test filename-12.6 {simple globbing} { list [catch {glob globTest\\/\\x1.c} msg] $msg} "0 $globPreResult$x1"test filename-13.1 {globbing with brace substitution} { list [catch {glob globTest/\{\}} msg] $msg} "0 $globPreResult"test filename-13.2 {globbing with brace substitution} { list [catch {glob globTest/\{} msg] $msg} {1 {unmatched open-brace in file name}}test filename-13.3 {globbing with brace substitution} { list [catch {glob globTest/\{\\\}} msg] $msg} {1 {unmatched open-brace in file name}}test filename-13.4 {globbing with brace substitution} { list [catch {glob globTest/\{\\} msg] $msg} {1 {unmatched open-brace in file name}}test filename-13.5 {globbing with brace substitution} { list [catch {glob globTest/\}} msg] $msg} {1 {unmatched close-brace in file name}}test filename-13.6 {globbing with brace substitution} { list [catch {glob globTest/\{\}x1.c} msg] $msg} "0 $globPreResult$x1"test filename-13.7 {globbing with brace substitution} { list [catch {glob globTest/\{x\}1.c} msg] $msg} "0 $globPreResult$x1"test filename-13.8 {globbing with brace substitution} { list [catch {glob globTest/\{x\{\}\}1.c} msg] $msg} "0 $globPreResult$x1"test filename-13.9 {globbing with brace substitution} {!win32s} { list [lsort [catch {glob globTest/\{x,y\}1.c} msg]] $msg} [list 0 [list $globPreResult$x1 $globPreResult$y1]]test filename-13.10 {globbing with brace substitution} {!win32s} { list [lsort [catch {glob globTest/\{x,,y\}1.c} msg]] $msg} [list 0 [list $globPreResult$x1 $globPreResult$y1]]test filename-13.11 {globbing with brace substitution} {unixOrPc && !win32s} { list [lsort [catch {glob globTest/\{x,x\\,z,z\}1.c} msg]] $msg} {0 {globTest/x1.c globTest/x,z1.c globTest/z1.c}}test filename-13.12 {globbing with brace substitution} {macOnly} { list [lsort [catch {glob globTest/\{x,x\\,z,z\}1.c} msg]] $msg} {0 {:globTest:x1.c :globTest:x,z1.c :globTest:z1.c}}test filename-13.13 {globbing with brace substitution} { lsort [glob globTest/{a,b,x,y}1.c]} [list $globPreResult$x1 $globPreResult$y1]test filename-13.14 {globbing with brace substitution} {unixOrPc} { lsort [glob {globTest/{x1,y2,weird name}.c}]} {{globTest/weird name.c} globTest/x1.c}test filename-13.15 {globbing with brace substitution} {macOnly} { lsort [glob {globTest/{x1,y2,weird name}.c}]} {{:globTest:weird name.c} :globTest:x1.c}test filename-13.16 {globbing with brace substitution} {unixOrPc} { lsort [glob globTest/{x1.c,a1/*}]} {globTest/a1/b1 globTest/a1/b2 globTest/x1.c}test filename-13.17 {globbing with brace substitution} {macOnly} { lsort [glob globTest/{x1.c,a1/*}]} {:globTest:a1:b1 :globTest:a1:b2 :globTest:x1.c}test filename-13.18 {globbing with brace substitution} {unixOrPc} { lsort [glob globTest/{x1.c,{a},a1/*}]} {globTest/a1/b1 globTest/a1/b2 globTest/x1.c}test filename-13.19 {globbing with brace substitution} {macOnly} { lsort [glob globTest/{x1.c,{a},a1/*}]} {:globTest:a1:b1 :globTest:a1:b2 :globTest:x1.c}test filename-13.20 {globbing with brace substitution} {unixOrPc} { lsort [glob globTest/{a,x}1/*/{x,y}*]} {globTest/a1/b1/x2.c globTest/a1/b2/y2.c}test filename-13.21 {globbing with brace substitution} {macOnly} { lsort [glob globTest/{a,x}1/*/{x,y}*]} {:globTest:a1:b1:x2.c :globTest:a1:b2:y2.c}test filename-13.22 {globbing with brace substitution} { list [catch {glob globTest/\{a,x\}1/*/\{} msg] $msg} {1 {unmatched open-brace in file name}}test filename-14.1 {asterisks, question marks, and brackets} {unixOrPc && !win32s} { lsort [glob g*/*.c]} {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}test filename-14.1 {asterisks, question marks, and brackets} {win32s} { lsort [glob g*/*.c]} {globtest/weirdn~1.c globtest/x1.c globtest/y1.c globtest/z1.c}test filename-14.2 {asterisks, question marks, and brackets} {macOnly} { lsort [glob g*/*.c]} {{:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}test filename-14.3 {asterisks, question marks, and brackets} {unixOrPc} { lsort [glob globTest/?1.c]} {globTest/x1.c globTest/y1.c globTest/z1.c}test filename-14.4 {asterisks, question marks, and brackets} {macOnly} { lsort [glob globTest/?1.c]} {:globTest:x1.c :globTest:y1.c :globTest:z1.c}test filename-14.5 {asterisks, question marks, and brackets} {unixOrPc && !win32s} { lsort [glob */*/*/*.c]} {globTest/a1/b1/x2.c globTest/a1/b2/y2.c}test filename-14.5 {asterisks, question marks, and brackets} {win32s} { lsort [glob */*/*/*.c]} {globtest/a1/b1/x2.c globtest/a1/b2/y2.c}test filename-14.6 {asterisks, question marks, and brackets} {macOnly} { lsort [glob */*/*/*.c]} {:globTest:a1:b1:x2.c :globTest:a1:b2:y2.c}test filename-14.7 {asterisks, question marks, and brackets} {unixOrPc && !win32s} { lsort [glob globTest/*]} {globTest/a1 globTest/a2 globTest/a3 {globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}test filename-14.7 {asterisks, question marks, and brackets} {win32s} { lsort [glob globTest/*]} {globTest/a1 globTest/a2 globTest/a3 globTest/weirdn~1.c globTest/x1.c globTest/y1.c globTest/z1.c}test filename-14.8 {asterisks, question marks, and brackets} {macOnly} { lsort [glob globTest/*]} {:globTest:.1 :globTest:a1 :globTest:a2 :globTest:a3 {:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}test filename-14.9 {asterisks, question marks, and brackets} {unixOrPc && !win32s} { lsort [glob globTest/.*]} {globTest/. globTest/.. globTest/.1}test filename-14.9 {asterisks, question marks, and brackets} {win32s} { lsort [glob globTest/.*]} {globTest/. globTest/..}test filename-14.10 {asterisks, question marks, and brackets} {macOnly} { lsort [glob globTest/.*]} {:globTest:.1}test filename-14.11 {asterisks, question marks, and brackets} {unixOrPc} { lsort [glob globTest/*/*]} {globTest/a1/b1 globTest/a1/b2 globTest/a2/b3}test filename-14.12 {asterisks, question marks, and brackets} {macOnly} { lsort [glob globTest/*/*]} {:globTest:a1:b1 :globTest:a1:b2 :globTest:a2:b3}test filename-14.13 {asterisks, question marks, and brackets} {unixOrPc} { lsort [glob {globTest/[xyab]1.*}]} {globTest/x1.c globTest/y1.c}test filename-14.14 {asterisks, question marks, and brackets} {macOnly} { lsort [glob {globTest/[xyab]1.*}]} {:globTest:x1.c :globTest:y1.c}test filename-14.15 {asterisks, question marks, and brackets} {unixOrPc} { lsort [glob globTest/*/]} {globTest/a1/ globTest/a2/ globTest/a3/}test filename-14.16 {asterisks, question marks, and brackets} {macOnly} { lsort [glob globTest/*/]} {:globTest:a1: :globTest:a2: :globTest:a3:}test filename-14.17 {asterisks, question marks, and brackets} { global env set temp $env(HOME) set env(HOME) [file join $env(HOME) globTest] set result [list [catch {glob ~/z*} msg] $msg] set env(HOME) $temp set result} [list 0 [list [file join $env(HOME) globTest z1.c]]]test filename-14.18 {asterisks, question marks, and brackets} {unixOrPc && !win32s} { list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg} {0 {{globTest/weird name.c} globTest/x,z1.c globTest/x1.c globTest/y1.c globTest/z1.c}}test filename-14.18 {asterisks, question marks, and brackets} {win32s} { list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg} {0 {globTest/weirdn~1.c globTest/x1.c globTest/y1.c globTest/z1.c}}test filename-14.19 {asterisks, question marks, and brackets} {macOnly} { list [catch {lsort [glob globTest/*.c goo/*]} msg] $msg} {0 {{:globTest:weird name.c} :globTest:x,z1.c :globTest:x1.c :globTest:y1.c :globTest:z1.c}}test filename-14.20 {asterisks, question marks, and brackets} { list [catch {glob -nocomplain goo/*} msg] $msg} {0 {}}test filename-14.21 {asterisks, question marks, and brackets} { list [catch {glob globTest/*/gorp} msg] $msg} {1 {no files matched glob pattern "globTest/*/gorp"}}test filename-14.22 {asterisks, question marks, and brackets} { list [catch {glob goo/* x*z foo?q} msg] $msg} {1 {no files matched glob patterns "goo/* x*z foo?q"}}test filename-14.23 {slash globbing} {unixOrPc} { glob /} /test filename-14.24 {slash globbing} {pcOnly} { glob {\\}} /# The following tests are only valid for Unix systems.if {$tcl_platform(platform) == "unix"} { # On some systems, like AFS, "000" protection doesn't prevent # access by owner, so the following test is not portable. exec chmod 000 globTest/a1 test filename-15.1 {unix specific globbing} {nonPortable} { string tolower [list [catch {glob globTest/a1/*} msg] $msg $errorCode] } {1 {couldn't read directory "globtest/a1": permission denied} {posix eacces {permission denied}}} test filename-15.2 {unix specific no complain: no errors} {nonPortable} { glob -nocomplain globTest/a1/* } {} test filename-15.3 {unix specific no complain: no errors, good result} {nonPortable knownBug} { # test fails because if an error occur , the interp's result # is reset... glob -nocomplain globTest/a2 globTest/a1/* globTest/a3 } {globTest/a2 globTest/a3} exec chmod 755 globTest/a1 test filename-15.4 {unix specific no complain: no errors, good result} {nonPortable knownBug} { # test fails because if an error occur , the interp's result # is reset... (or you don't run at sunscript where the # outser and demailly's users exists glob -nocomplain ~ouster ~foo ~demailly } {/home/ouster /home/demailly} test filename-15.5 {unix specific globbing} {nonPortable} { glob ~ouster/.csh* } "/home/ouster/.cshrc" close [open globTest/odd\\\[\]*?\{\}name w] test filename-15.6 {unix specific globbing} { global env set temp $env(HOME) set env(HOME) $env(HOME)/globTest/odd\\\[\]*?\{\}name set result [list [catch {glob ~} msg] $msg] set env(HOME) $temp set result } [list 0 [list [glob ~]/globTest/odd\\\[\]*?\{\}name]] exec rm -f globTest/odd\\\[\]*?\{\}name}# The following tests are only valid for Windows systems.if {$tcl_platform(platform) == "windows"} { set temp [pwd] cd c:/ catch { removeDirectory globTest makeDirectory globTest close [open globTest/x1.BAT w] close [open globTest/y1.Bat w] close [open globTest/z1.bat w] } test filename-16.1 {windows specific globbing} {!win32s} { lsort [glob globTest/*.bat] } {globTest/x1.BAT globTest/y1.Bat globTest/z1.bat} test filename-16.1 {windows specific globbing} {win32s} { lsort [glob globTest/*.bat] } {globTest/x1.bat globTest/y1.bat globTest/z1.bat} test filename-16.2 {windows specific globbing} { glob c: } c: test filename-16.3 {windows specific globbing} { glob c:\\\\ } c:/ test filename-16.4 {windows specific globbing} { glob c:/ } c:/ test filename-16.5 {windows specific globbing} {!win32s} { glob c:*Test } c:globTest test filename-16.5 {windows specific globbing} {win32s} { glob c:*Test } c:globtest test filename-16.6 {windows specific globbing} {!win32s} { glob c:\\\\*Test } c:/globTest test filename-16.6 {windows specific globbing} {win32s} { glob c:\\\\*Test } c:/globtest test filename-16.7 {windows specific globbing} {!win32s} { glob c:/*Test } c:/globTest test filename-16.7 {windows specific globbing} {win32s} { glob c:/*Test } c:/globtest test filename-16.8 {windows specific globbing} {!win32s} { lsort [glob c:globTest/*.bat] } {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat} test filename-16.8 {windows specific globbing} {win32s} { lsort [glob c:globTest/*.bat] } {c:globTest/x1.bat c:globTest/y1.bat c:globTest/z1.bat} test filename-16.9 {windows specific globbing} {!win32s} { lsort [glob c:/globTest/*.bat] } {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat} test filename-16.9 {windows specific globbing} {win32s} { lsort [glob c:/globTest/*.bat] } {c:/globTest/x1.bat c:/globTest/y1.bat c:/globTest/z1.bat} test filename-16.10 {windows specific globbing} {!win32s} { lsort [glob c:globTest\\\\*.bat] } {c:globTest/x1.BAT c:globTest/y1.Bat c:globTest/z1.bat} test filename-16.10 {windows specific globbing} {win32s} { lsort [glob c:globTest\\\\*.bat] } {c:globTest/x1.bat c:globTest/y1.bat c:globTest/z1.bat} test filename-16.11 {windows specific globbing} {!win32s} { lsort [glob c:\\\\globTest\\\\*.bat] } {c:/globTest/x1.BAT c:/globTest/y1.Bat c:/globTest/z1.bat} test filename-16.11 {windows specific globbing} {win32s} { lsort [glob c:\\\\globTest\\\\*.bat] } {c:/globTest/x1.bat c:/globTest/y1.bat c:/globTest/z1.bat} removeDirectory globTest if {($testConfig(nonPortable) != 0) && [catch {cd //gaspode/d}] == 0} { removeDirectory globTest makeDirectory globTest close [open globTest/x1.BAT w] close [open globTest/y1.Bat w] close [open globTest/z1.bat w] test filename-16.12 {windows specific globbing} { glob //gaspode/d/*Test } //gaspode/d/globTest test filename-16.13 {windows specific globbing} { glob {\\\\gaspode\\d\\*Test} } //gaspode/d/globTest removeDirectory globTest } cd $temp}removeDirectory globTestset env(HOME) $oldhometestsetplatform $platformcatch {unset oldhome platform temp result}concat ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -