aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2022-08-21 10:27:27 +1000
committerSteve Bennett <steveb@workware.net.au>2022-08-21 10:27:27 +1000
commitc490451362b7082a02d4c2afea24d6c568259d0b (patch)
treecefcb8f55cd621291e29f3c30750c07641174f10 /tests
parent74ccdcd06a13d7939130668dfb7f7c3377d05430 (diff)
downloadjimtcl-c490451362b7082a02d4c2afea24d6c568259d0b.zip
jimtcl-c490451362b7082a02d4c2afea24d6c568259d0b.tar.gz
jimtcl-c490451362b7082a02d4c2afea24d6c568259d0b.tar.bz2
tests: file.test - increase code coverage
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/file.test50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/file.test b/tests/file.test
index cf54c05..f3d32c0 100644
--- a/tests/file.test
+++ b/tests/file.test
@@ -5,10 +5,16 @@ catch {file link} msg
testConstraint filelink [string match "wrong # args:*" $msg]
catch {file lstat} msg
testConstraint filelstat [string match "wrong # args:*" $msg]
+catch {file mtimeus} msg
+testConstraint mtimeus [string match "wrong # args:*" $msg]
testConstraint unix [expr {$tcl_platform(platform) eq "unix"}]
+testConstraint normalize 1
if {[testConstraint jim]} {
testConstraint mtimeset [expr {!$tcl_platform(bootstrap)}]
testConstraint aiostat [expr {!$tcl_platform(bootstrap)}]
+ if {[catch {file normalize .}]} {
+ testConstraint normalize 0
+ }
} else {
testConstraint mtimeset 1
testConstraint aiostat 0
@@ -253,6 +259,14 @@ test writable-1.1 {file writable} -body {
file delete $name
}
+test executable-1.1 {file executable} -body {
+ file executable [info nameofexecutable]
+} -result 1
+
+test executable-1.2 {file executable} -body {
+ file executable [info script]
+} -result 0
+
test rename-1.1 {file rename usage} -body {
file rename
} -returnCodes error -match glob -result {wrong # args: should be *}
@@ -399,6 +413,26 @@ test mtime-1.5 {file mtime} -constraints {mtimeset unix} -body {
file delete $name
}
+test mtimeus-1.1 {file mtimeus} -constraints mtimeus -body {
+ file mtimeus
+} -returnCodes error -result {wrong # args: should be "file mtimeus name ?time?"}
+
+test mtimeus-1.2 {file mtimeus} -constraints mtimeus -body {
+ file mtimeus nonexistent
+} -returnCodes error -match glob -result {could not read "nonexistent":*}
+
+test mtimeus-1.3 {file mtimeus} -constraints mtimeus -body {
+ file mtimeus [info script] bad
+} -returnCodes error -result {expected integer but got "bad"}
+
+test mtimeus-1.4 {file mtimeus} -constraints mtimeus -body {
+ set mtimeus [file mtimeus [info script]]
+ file stat [info script] s
+ if {$mtimeus != $s(mtimeus)} {
+ error "mtimeus was $mtimeus but s(mtimeus) was $s(mtimeus)"
+ }
+}
+
test atime-1.1 {file atime} -body {
file atime
} -returnCodes error -match glob -result {wrong # args: should be "file atime name*}
@@ -449,4 +483,20 @@ test file.20 "picol test" {file split {foo/space station/bar}} {foo {space st
test file.21 "picol test" {file split foo///bar} {foo bar}
test file.22 "picol test" {file split foo} foo
+test normalize-1.1 {normalize usage} -body {
+ file normalize
+} -returnCodes error -match glob -result {wrong # args: should be "file normalize *"}
+
+test normalize-1.2 {normalize usage} -body {
+ file normalize abc def
+} -returnCodes error -match glob -result {wrong # args: should be "file normalize *"}
+
+test normalize-1.3 {normalize simple} -constraints normalize -body {
+ file tail [file normalize [info script]]
+} -result file.test
+
+test normalize-1.4 {normalize simple} -constraints normalize -body {
+ file tail [file normalize [file dirname [info script]]]
+} -result tests
+
testreport