summaryrefslogtreecommitdiffstats
path: root/tests/fCmd.test
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2022-08-19 16:52:07 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2022-08-19 16:52:07 (GMT)
commite52c7c3a41a6fb4a3deeade3447de39ee569f0fd (patch)
treea663853f6c59c39da276963ebfabf7c205a93a16 /tests/fCmd.test
parentff9ac0bfbdf42dea8bdffaaabc02977bba867a55 (diff)
downloadtcl-e52c7c3a41a6fb4a3deeade3447de39ee569f0fd.zip
tcl-e52c7c3a41a6fb4a3deeade3447de39ee569f0fd.tar.gz
tcl-e52c7c3a41a6fb4a3deeade3447de39ee569f0fd.tar.bz2
Implement file tildeexpand
Diffstat (limited to 'tests/fCmd.test')
-rw-r--r--tests/fCmd.test79
1 files changed, 77 insertions, 2 deletions
diff --git a/tests/fCmd.test b/tests/fCmd.test
index e9d7667..dbbc154 100644
--- a/tests/fCmd.test
+++ b/tests/fCmd.test
@@ -2699,13 +2699,88 @@ test fCmd-31.6 {file home USER} -body {
# name, else not sure how to check
file home $::tcl_platform(user)
} -match glob -result "*$::tcl_platform(user)*"
-test fCmd-31.6 {file home UNKNOWNUSER} -body {
+test fCmd-31.7 {file home UNKNOWNUSER} -body {
file home nosuchuser
} -returnCodes error -result {user "nosuchuser" doesn't exist}
-test fCmd-31.7 {file home extra arg} -body {
+test fCmd-31.8 {file home extra arg} -body {
file home $::tcl_platform(user) arg
} -returnCodes error -result {wrong # args: should be "file home ?user?"}
+test fCmd-32.1 {file tildeexpand ~} -body {
+ file tildeexpand ~
+} -result [file join $::env(HOME)]
+test fCmd-32.2 {file tildeexpand ~ - obeys env} -setup {
+ set ::env(HOME) $::env(HOME)/xxx
+} -cleanup {
+ set ::env(HOME) [file dirname $::env(HOME)]
+} -body {
+ file tildeexpand ~
+} -result [file join $::env(HOME) xxx]
+test fCmd-32.3 {file tildeexpand ~ - error} -setup {
+ set saved $::env(HOME)
+ unset ::env(HOME)
+} -cleanup {
+ set ::env(HOME) $saved
+} -body {
+ file tildeexpand ~
+} -returnCodes error -result {couldn't find HOME environment variable to expand path}
+test fCmd-32.4 {
+ file tildeexpand ~ - relative path. Following 8.x ~ expansion behavior, relative
+ paths are not made absolute
+} -setup {
+ set saved $::env(HOME)
+ set ::env(HOME) relative/path
+} -cleanup {
+ set ::env(HOME) $saved
+} -body {
+ file tildeexpand ~
+} -result relative/path
+test fCmd-32.5 {file tildeexpand ~USER} -body {
+ # Note - as in 8.x this form does NOT necessarily give same result as
+ # env(HOME) even when user is current user. Assume result contains user
+ # name, else not sure how to check
+ file tildeexpand ~$::tcl_platform(user)
+} -match glob -result "*$::tcl_platform(user)*"
+test fCmd-32.6 {file tildeexpand ~UNKNOWNUSER} -body {
+ file tildeexpand ~nosuchuser
+} -returnCodes error -result {user "nosuchuser" doesn't exist}
+test fCmd-32.7 {file tildeexpand ~extra arg} -body {
+ file tildeexpand ~ arg
+} -returnCodes error -result {wrong # args: should be "file tildeexpand path"}
+test fCmd-32.8 {file tildeexpand ~/path} -body {
+ file tildeexpand ~/foo
+} -result [file join $::env(HOME)/foo]
+test fCmd-32.9 {file tildeexpand ~USER/bar} -body {
+ # Note - as in 8.x this form does NOT necessarily give same result as
+ # env(HOME) even when user is current user. Assume result contains user
+ # name, else not sure how to check
+ file tildeexpand ~$::tcl_platform(user)/bar
+} -match glob -result "*$::tcl_platform(user)*/bar"
+test fCmd-32.10 {file tildeexpand ~UNKNOWNUSER} -body {
+ file tildeexpand ~nosuchuser/foo
+} -returnCodes error -result {user "nosuchuser" doesn't exist}
+test fCmd-32.11 {file tildeexpand /~/path} -body {
+ file tildeexpand /~/foo
+} -result /~/foo
+test fCmd-32.12 {file tildeexpand /~user/path} -body {
+ file tildeexpand /~$::tcl_platform(user)/foo
+} -result /~$::tcl_platform(user)/foo
+test fCmd-32.13 {file tildeexpand ./~} -body {
+ file tildeexpand ./~
+} -result ./~
+test fCmd-32.14 {file tildeexpand relative/path} -body {
+ file tildeexpand relative/path
+} -result relative/path
+test fCmd-32.15 {file tildeexpand ~\\path} -body {
+ file tildeexpand ~\\foo
+} -constraints win -result [file join $::env(HOME)/foo]
+test fCmd-32.16 {file tildeexpand ~USER\\bar} -body {
+ # Note - as in 8.x this form does NOT necessarily give same result as
+ # env(HOME) even when user is current user. Assume result contains user
+ # name, else not sure how to check
+ file tildeexpand ~$::tcl_platform(user)\\bar
+} -constraints win -match glob -result "*$::tcl_platform(user)*/bar"
+
# cleanup
cleanup