📄 cmdah.test
字号:
# The file tests the tclCmdAH.c file.## This file contains a collection of tests for one or more of the Tcl# built-in commands. Sourcing this file into Tcl runs the tests and# generates output for errors. No output means no errors were found.## Copyright (c) 1996-1997 by Sun Microsystems, Inc.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## SCCS: @(#) cmdAH.test 1.35 97/07/22 14:07:43if {[string compare test [info procs test]] == 1} then {source defs}global envcatch {set platform [testgetplatform]}test cmdAH-1.1 {Tcl_FileObjCmd} { list [catch file msg] $msg} {1 {wrong # args: should be "file option ?arg ...?"}}test cmdAH-1.2 {Tcl_FileObjCmd} { list [catch {file x} msg] $msg} {1 {bad option "x": must be atime, attributes, copy, delete, dirname, executable, exists, extension, isdirectory, isfile, join, lstat, mtime, mkdir, nativename, owned, pathtype, readable, readlink, rename, rootname, size, split, stat, tail, type, volumes, or writable}}test cmdAH-1.3 {Tcl_FileObjCmd} { list [catch {file atime} msg] $msg} {1 {wrong # args: should be "file atime name ?arg ...?"}}#volumetest cmdAH-2.1 {Tcl_FileObjCmd: volumes} { list [catch {file volumes x} msg] $msg } {1 {wrong # args: should be "file volumes"}}test cmdAH-2.2 {Tcl_FileObjCmd: volumes} { set volumeList [file volumes] if { [llength $volumeList] == 0 } { set result 0 } else { set result 1 } } {1}test cmdAH-2.3 {Tcl_FileObjCmd: volumes} {macOrUnix} { set volumeList [file volumes] catch [list glob -nocomplain [lindex $volumeList 0]*]} {0}test cmdAH-2.4 {Tcl_FileObjCmd: volumes} {pcOnly} { set volumeList [file volumes] list [catch {lsearch $volumeList "c:/"} element] [expr $element != -1] [catch {list glob -nocomplain [lindex $volumeList $element]*}]} {0 1 0}# attributestest cmdAH-3.1 {Tcl_FileObjCmd - file attrs} { catch {file delete -force foo.file} close [open foo.file w] list [catch {file attributes foo.file}] [file delete -force foo.file]} {0 {}}# dirnameif {[info commands testsetplatform] == {}} { puts "This application hasn't been compiled with the \"testsetplatform\"" puts "command, so I can't test Tcl_FileObjCmd etc."} else {test cmdAH-4.1 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname a b} msg] $msg} {1 {wrong # args: should be "file dirname name"}}test cmdAH-4.2 {Tcl_FileObjCmd: dirname} { testsetplatform unix file dirname /a/b} /atest cmdAH-4.3 {Tcl_FileObjCmd: dirname} { testsetplatform unix file dirname {}} .test cmdAH-4.4 {Tcl_FileObjCmd: dirname} { testsetplatform mac file dirname {}} :test cmdAH-4.5 {Tcl_FileObjCmd: dirname} { testsetplatform win file dirname {}} .test cmdAH-4.6 {Tcl_FileObjCmd: dirname} { testsetplatform unix file dirname .def} .test cmdAH-4.7 {Tcl_FileObjCmd: dirname} { testsetplatform mac file dirname a} :test cmdAH-4.8 {Tcl_FileObjCmd: dirname} { testsetplatform win file dirname a} .test cmdAH-4.9 {Tcl_FileObjCmd: dirname} { testsetplatform unix file dirname a/b/c.d} a/btest cmdAH-4.10 {Tcl_FileObjCmd: dirname} { testsetplatform unix file dirname a/b.c/d} a/b.ctest cmdAH-4.11 {Tcl_FileObjCmd: dirname} { testsetplatform unix file dirname /.} /test cmdAH-4.12 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname /} msg] $msg} {0 /}test cmdAH-4.13 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname /foo} msg] $msg} {0 /}test cmdAH-4.14 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname //foo} msg] $msg} {0 /}test cmdAH-4.15 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname //foo/bar} msg] $msg} {0 /foo}test cmdAH-4.16 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname {//foo\/bar/baz}} msg] $msg} {0 {/foo\/bar}}test cmdAH-4.17 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname {//foo\/bar/baz/blat}} msg] $msg} {0 {/foo\/bar/baz}}test cmdAH-4.18 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname /foo//} msg] $msg} {0 /}test cmdAH-4.19 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname ./a} msg] $msg} {0 .}test cmdAH-4.20 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname a/.a} msg] $msg} {0 a}test cmdAH-4.21 {Tcl_FileObjCmd: dirname} { testsetplatform windows list [catch {file dirname c:foo} msg] $msg} {0 c:}test cmdAH-4.22 {Tcl_FileObjCmd: dirname} { testsetplatform windows list [catch {file dirname c:} msg] $msg} {0 c:}test cmdAH-4.23 {Tcl_FileObjCmd: dirname} { testsetplatform windows list [catch {file dirname c:/} msg] $msg} {0 c:/}test cmdAH-4.24 {Tcl_FileObjCmd: dirname} { testsetplatform windows list [catch {file dirname {c:\foo}} msg] $msg} {0 c:/}test cmdAH-4.25 {Tcl_FileObjCmd: dirname} { testsetplatform windows list [catch {file dirname {//foo/bar/baz}} msg] $msg} {0 //foo/bar}test cmdAH-4.26 {Tcl_FileObjCmd: dirname} { testsetplatform windows list [catch {file dirname {//foo/bar}} msg] $msg} {0 //foo/bar}test cmdAH-4.27 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname :} msg] $msg} {0 :}test cmdAH-4.28 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname :Foo} msg] $msg} {0 :}test cmdAH-4.29 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname Foo:} msg] $msg} {0 Foo:}test cmdAH-4.30 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname Foo:bar} msg] $msg} {0 Foo:}test cmdAH-4.31 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname :Foo:bar} msg] $msg} {0 :Foo}test cmdAH-4.32 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname ::} msg] $msg} {0 :}test cmdAH-4.33 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname :::} msg] $msg} {0 ::}test cmdAH-4.34 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname /foo/bar/} msg] $msg} {0 foo:}test cmdAH-4.35 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname /foo/bar} msg] $msg} {0 foo:}test cmdAH-4.36 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname /foo} msg] $msg} {0 foo:}test cmdAH-4.37 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname foo} msg] $msg} {0 :}test cmdAH-4.38 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname ~/foo} msg] $msg} {0 ~}test cmdAH-4.39 {Tcl_FileObjCmd: dirname} { testsetplatform unix list [catch {file dirname ~bar/foo} msg] $msg} {0 ~bar}test cmdAH-4.40 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname ~bar/foo} msg] $msg} {0 ~bar:}test cmdAH-4.41 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname ~/foo} msg] $msg} {0 ~:}test cmdAH-4.42 {Tcl_FileObjCmd: dirname} { testsetplatform mac list [catch {file dirname ~:baz} msg] $msg} {0 ~:}test cmdAH-4.43 {Tcl_FileObjCmd: dirname} { global env set temp $env(HOME) set env(HOME) "/home/test" testsetplatform unix set result [list [catch {file dirname ~} msg] $msg] set env(HOME) $temp set result} {0 /home}test cmdAH-4.44 {Tcl_FileObjCmd: dirname} { global env set temp $env(HOME) set env(HOME) "~" testsetplatform unix set result [list [catch {file dirname ~} msg] $msg] set env(HOME) $temp set result} {0 ~}test cmdAH-4.45 {Tcl_FileObjCmd: dirname} { global env set temp $env(HOME) set env(HOME) "/home/test" testsetplatform windows set result [list [catch {file dirname ~} msg] $msg] set env(HOME) $temp set result} {0 /home}test cmdAH-4.46 {Tcl_FileObjCmd: dirname} { global env set temp $env(HOME) set env(HOME) "/home/test" testsetplatform mac set result [list [catch {file dirname ~} msg] $msg] set env(HOME) $temp set result} {0 home:}# tailtest cmdAH-5.1 {Tcl_FileObjCmd: tail} { testsetplatform unix list [catch {file tail a b} msg] $msg} {1 {wrong # args: should be "file tail name"}}test cmdAH-5.2 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail /a/b} btest cmdAH-5.3 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail {}} {}test cmdAH-5.4 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail {}} {}test cmdAH-5.5 {Tcl_FileObjCmd: tail} { testsetplatform win file tail {}} {}test cmdAH-5.6 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail .def} .deftest cmdAH-5.7 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail a} atest cmdAH-5.8 {Tcl_FileObjCmd: tail} { testsetplatform win file tail a} atest cmdAH-5.9 {Tcl_FileObjCmd: tail} { testsetplatform unix file ta a/b/c.d} c.dtest cmdAH-5.10 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail a/b.c/d} dtest cmdAH-5.11 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail /.} .test cmdAH-5.12 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail /} {}test cmdAH-5.13 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail /foo} footest cmdAH-5.14 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail //foo} footest cmdAH-5.15 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail //foo/bar} bartest cmdAH-5.16 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail {//foo\/bar/baz}} baztest cmdAH-5.17 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail {//foo\/bar/baz/blat}} blattest cmdAH-5.18 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail /foo//} footest cmdAH-5.19 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail ./a} atest cmdAH-5.20 {Tcl_FileObjCmd: tail} { testsetplatform unix file tail a/.a} .atest cmdAH-5.21 {Tcl_FileObjCmd: tail} { testsetplatform windows file tail c:foo} footest cmdAH-5.22 {Tcl_FileObjCmd: tail} { testsetplatform windows file tail c:} {}test cmdAH-5.23 {Tcl_FileObjCmd: tail} { testsetplatform windows file tail c:/} {}test cmdAH-5.24 {Tcl_FileObjCmd: tail} { testsetplatform windows file tail {c:\foo}} footest cmdAH-5.25 {Tcl_FileObjCmd: tail} { testsetplatform windows file tail {//foo/bar/baz}} baztest cmdAH-5.26 {Tcl_FileObjCmd: tail} { testsetplatform windows file tail {//foo/bar}} {}test cmdAH-5.27 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail :} :test cmdAH-5.28 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail :Foo} Footest cmdAH-5.29 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail Foo:} {}test cmdAH-5.30 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail Foo:bar} bartest cmdAH-5.31 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail :Foo:bar} bartest cmdAH-5.32 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail ::} ::test cmdAH-5.33 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail :::} ::test cmdAH-5.34 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail /foo/bar/} bartest cmdAH-5.35 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail /foo/bar} bartest cmdAH-5.36 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail /foo} {}test cmdAH-5.37 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail foo} footest cmdAH-5.38 {Tcl_FileObjCmd: tail} { testsetplatform mac file tail ~:foo} footest cmdAH-5.39 {Tcl_FileObjCmd: tail} {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -