summaryrefslogtreecommitdiffstats
path: root/tests/cmdAH.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cmdAH.test')
-rw-r--r--tests/cmdAH.test49
1 files changed, 41 insertions, 8 deletions
diff --git a/tests/cmdAH.test b/tests/cmdAH.test
index f463683..58bb728 100644
--- a/tests/cmdAH.test
+++ b/tests/cmdAH.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: cmdAH.test,v 1.8 1999/08/19 03:00:12 hobbs Exp $
+# RCS: @(#) $Id: cmdAH.test,v 1.9 1999/10/29 03:04:37 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -168,8 +168,8 @@ test cmdAH-5.2 {Tcl_FileObjCmd} {
list [catch {file x} msg] $msg
} {1 {bad option "x": must be atime, attributes, channels, 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-5.3 {Tcl_FileObjCmd} {
- list [catch {file atime} msg] $msg
-} {1 {wrong # args: should be "file atime name"}}
+ list [catch {file exists} msg] $msg
+} {1 {wrong # args: should be "file exists name"}}
#volume
@@ -1156,9 +1156,11 @@ catch {exec chmod 765 gorp.file}
# atime
+set file [makeFile "data" touch.me]
+
test cmdAH-20.1 {Tcl_FileObjCmd: atime} {
- list [catch {file atime a b} msg] $msg
-} {1 {wrong # args: should be "file atime name"}}
+ list [catch {file atime a b c} msg] $msg
+} {1 {wrong # args: should be "file atime name ?time?"}}
test cmdAH-20.2 {Tcl_FileObjCmd: atime} {
catch {unset stat}
file stat gorp.file stat
@@ -1169,6 +1171,26 @@ test cmdAH-20.3 {Tcl_FileObjCmd: atime} {
string tolower [list [catch {file atime _bogus_} msg] \
$msg $errorCode]
} {1 {could not read "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
+test cmdAH-20.4 {Tcl_FileObjCmd: atime} {
+ list [catch {file atime $file notint} msg] $msg
+} {1 {expected integer but got "notint"}}
+test cmdAH-20.5 {Tcl_FileObjCmd: atime touch} {
+ if {[string equal $tcl_platform(platform) "windows"]} {
+ set old [pwd]
+ cd $::tcltest::temporaryDirectory
+ if {![string equal "NTFS" [testvolumetype]]} {
+ # Windows FAT doesn't understand atime, but NTFS does
+ # May also fail for Windows on NFS mounted disks
+ cd $old
+ return 1
+ }
+ cd $old
+ }
+ set atime [file atime $file]
+ after 1100; # pause a sec to notice change in atime
+ set newatime [clock seconds]
+ expr {$newatime==[file atime $file $newatime]}
+} 1
# isdirectory
@@ -1223,9 +1245,11 @@ catch {unset stat}
# mtime
+set file [makeFile "data" touch.me]
+
test cmdAH-24.1 {Tcl_FileObjCmd: mtime} {
- list [catch {file mtime a b} msg] $msg
-} {1 {wrong # args: should be "file mtime name"}}
+ list [catch {file mtime a b c} msg] $msg
+} {1 {wrong # args: should be "file mtime name ?time?"}}
test cmdAH-24.2 {Tcl_FileObjCmd: mtime} {
set old [file mtime gorp.file]
after 2000
@@ -1249,7 +1273,7 @@ test cmdAH-24.5 {Tcl_FileObjCmd: mtime} {
# Under Unix, use a file in /tmp to avoid clock skew due to NFS.
# On other platforms, just use a file in the local directory.
- if {$tcl_platform(platform) == "unix"} {
+ if {[string equal $tcl_platform(platform) "unix"]} {
set name /tmp/tcl.test
} else {
set name tf
@@ -1264,6 +1288,15 @@ test cmdAH-24.5 {Tcl_FileObjCmd: mtime} {
file delete $name
set a
} {1}
+test cmdAH-24.7 {Tcl_FileObjCmd: mtime} {
+ list [catch {file mtime $file notint} msg] $msg
+} {1 {expected integer but got "notint"}}
+test cmdAH-24.8 {Tcl_FileObjCmd: mtime touch} {
+ set mtime [file mtime $file]
+ after 1100; # pause a sec to notice change in mtime
+ set newmtime [clock seconds]
+ expr {$newmtime==[file mtime $file $newmtime]}
+} 1
# owned