📄 filename.test
字号:
# This file tests the filename manipulation routines.## 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) 1995-1996 Sun Microsystems, Inc.# Copyright (c) 1999 by Scriptics Corporation.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## RCS: @(#) $Id: fileName.test,v 1.30 2003/02/12 18:57:51 vincentdarley Exp $if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest namespace import -force ::tcltest::*}tcltest::testConstraint testsetplatform [string equal testsetplatform [info commands testsetplatform]]tcltest::testConstraint testtranslatefilename [string equal testtranslatefilename [info commands testtranslatefilename]]global envif {[tcltest::testConstraint testsetplatform]} { set platform [testgetplatform]}test filename-1.1 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype /} absolutetest filename-1.2 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype /foo} absolutetest filename-1.3 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype foo} relativetest filename-1.4 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype c:/foo} relativetest filename-1.5 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~} absolutetest filename-1.6 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~/foo} absolutetest filename-1.7 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ~foo} absolutetest filename-1.8 {Tcl_GetPathType: unix} {testsetplatform} { testsetplatform unix file pathtype ./~foo} relativetest filename-2.1 {Tcl_GetPathType: mac, denerate names} {testsetplatform} { testsetplatform mac file pathtype /} relativetest filename-2.2 {Tcl_GetPathType: mac, denerate names} {testsetplatform} { testsetplatform mac file pathtype /.} relativetest filename-2.3 {Tcl_GetPathType: mac, denerate names} {testsetplatform} { testsetplatform mac file pathtype /..} relativetest filename-2.4 {Tcl_GetPathType: mac, denerate names} {testsetplatform} { testsetplatform mac file pathtype //.//} relativetest filename-2.5 {Tcl_GetPathType: mac, denerate names} {testsetplatform} { testsetplatform mac file pathtype //.//../.} relativetest filename-2.6 {Tcl_GetPathType: mac, tilde names} {testsetplatform} { testsetplatform mac file pathtype ~} absolutetest filename-2.7 {Tcl_GetPathType: mac, tilde names} {testsetplatform} { testsetplatform mac file pathtype ~:} absolutetest filename-2.8 {Tcl_GetPathType: mac, tilde names} {testsetplatform} { testsetplatform mac file pathtype ~:foo} absolutetest filename-2.9 {Tcl_GetPathType: mac, tilde names} {testsetplatform} { testsetplatform mac file pathtype ~/} absolutetest filename-2.10 {Tcl_GetPathType: mac, tilde names} {testsetplatform} { testsetplatform mac file pathtype ~/foo} absolutetest filename-2.11 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} { testsetplatform mac file pathtype /foo} absolutetest filename-2.12 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} { testsetplatform mac file pathtype /./foo} absolutetest filename-2.13 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} { testsetplatform mac file pathtype /..//./foo} absolutetest filename-2.14 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} { testsetplatform mac file pathtype /foo/bar} absolutetest filename-2.15 {Tcl_GetPathType: mac, unix-style names} {testsetplatform} { testsetplatform mac file pathtype foo/bar} relativetest filename-2.16 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype :} relativetest filename-2.17 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype :foo} relativetest filename-2.18 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype foo:} absolutetest filename-2.19 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype foo:bar} absolutetest filename-2.20 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype :foo:bar} relativetest filename-2.21 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype ::foo:bar} relativetest filename-2.22 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype ~foo} absolutetest filename-2.23 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype :~foo} relativetest filename-2.24 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype ~foo:} absolutetest filename-2.25 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype foo/bar:} absolutetest filename-2.26 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype /foo:} absolutetest filename-2.27 {Tcl_GetPathType: mac, mac-style names} {testsetplatform} { testsetplatform mac file pathtype foo} relativetest filename-3.1 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype /} volumerelativetest filename-3.2 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype \\} volumerelativetest filename-3.3 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype /foo} volumerelativetest filename-3.4 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype \\foo} volumerelativetest filename-3.5 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype c:/} absolutetest filename-3.6 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype c:\\} absolutetest filename-3.7 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype c:/foo} absolutetest filename-3.8 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype c:\\foo} absolutetest filename-3.9 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype c:} volumerelativetest filename-3.10 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype c:foo} volumerelativetest filename-3.11 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype foo} relativetest filename-3.12 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype //foo/bar} absolutetest filename-3.13 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~foo} absolutetest filename-3.14 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~} absolutetest filename-3.15 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ~/foo} absolutetest filename-3.16 {Tcl_GetPathType: windows} {testsetplatform} { testsetplatform windows file pathtype ./~foo} relativetest filename-4.1 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split /} {/}test filename-4.2 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split /foo} {/ foo}test filename-4.3 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split /foo/bar} {/ foo bar}test filename-4.4 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split /foo/bar/baz} {/ foo bar baz}test filename-4.5 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split foo/bar} {foo bar}test filename-4.6 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ./foo/bar} {. foo bar}test filename-4.7 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split /foo/../././foo/bar} {/ foo .. . . foo bar}test filename-4.8 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ../foo/bar} {.. foo bar}test filename-4.9 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split {}} {}test filename-4.10 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split .} {.}test filename-4.11 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ../} {..}test filename-4.12 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ../..} {.. ..}test filename-4.13 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split //foo} {/ foo}test filename-4.14 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split foo//bar} {foo bar}test filename-4.15 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo} {~foo}test filename-4.16 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo/~bar} {~foo ./~bar}test filename-4.17 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split ~foo/~bar/~baz} {~foo ./~bar ./~baz}test filename-4.18 {Tcl_SplitPath: unix} {testsetplatform} { testsetplatform unix file split foo/bar~/baz} {foo bar~ baz}if {[tcltest::testConstraint testsetplatform]} { testsetplatform $platform}test filename-4.19 {Tcl_SplitPath} { set oldDir [pwd] set res [catch { cd [temporaryDirectory] file mkdir tildetmp set nastydir [file join tildetmp ./~tilde] file mkdir $nastydir set norm [file normalize $nastydir] cd tildetmp cd ./~tilde glob -nocomplain * set idx [string first tildetmp $norm] set norm [string range $norm $idx end] # fix path away so all platforms are the same regsub {(.*):$} $norm {\1} norm regsub -all ":" $norm "/" norm # make sure we can delete the directory we created cd $oldDir file delete -force $nastydir set norm } err] cd $oldDir catch {file delete -force tildetmp} list $res $err} {0 tildetmp/~tilde}test filename-5.1 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split a:b} {a: b}test filename-5.2 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split a:b:c} {a: b c}test filename-5.3 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split a:b:c:} {a: b c}test filename-5.4 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split a:} {a:}test filename-5.5 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split a::} {a: ::}test filename-5.6 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split a:::} {a: :: ::}test filename-5.7 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split :a} {a}test filename-5.8 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split :a::} {a ::}test filename-5.9 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split :} {:}test filename-5.10 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac file split ::} {::}test filename-5.11 {Tcl_SplitPath: mac} {testsetplatform} { testsetplatform mac
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -