os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/macFCmd.test
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/macFCmd.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,203 @@
1.4 +# This file tests the tclfCmd.c file.
1.5 +#
1.6 +# This file contains a collection of tests for one or more of the Tcl
1.7 +# built-in commands. Sourcing this file into Tcl runs the tests and
1.8 +# generates output for errors. No output means no errors were found.
1.9 +#
1.10 +# Copyright (c) 1997 Sun Microsystems, Inc.
1.11 +# Copyright (c) 1998-1999 by Scriptics Corporation.
1.12 +#
1.13 +# See the file "license.terms" for information on usage and redistribution
1.14 +# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1.15 +#
1.16 +# RCS: @(#) $Id: macFCmd.test,v 1.10 2002/07/05 10:38:43 dkf Exp $
1.17 +#
1.18 +
1.19 +if {[lsearch [namespace children] ::tcltest] == -1} {
1.20 + package require tcltest
1.21 + namespace import -force ::tcltest::*
1.22 +}
1.23 +
1.24 +# These tests really need to be run from a writable directory, which
1.25 +# it is assumed [temporaryDirectory] is.
1.26 +set oldcwd [pwd]
1.27 +cd [temporaryDirectory]
1.28 +
1.29 +catch {file delete -force foo.dir}
1.30 +file mkdir foo.dir
1.31 +if {[catch {file attributes foo.dir -readonly 1}]} {
1.32 + set ::tcltest::testConstraints(fileSharing) 0
1.33 + set ::tcltest::testConstraints(notFileSharing) 1
1.34 +} else {
1.35 + set ::tcltest::testConstraints(fileSharing) 1
1.36 + set ::tcltest::testConstraints(notFileSharing) 0
1.37 +}
1.38 +file delete -force foo.dir
1.39 +
1.40 +test macFCmd-1.1 {GetFileFinderAttributes - no file} {macOnly} {
1.41 + catch {file delete -force foo.file}
1.42 + list [catch {file attributes foo.file -creator} msg] $msg
1.43 +} {1 {could not read "foo.file": no such file or directory}}
1.44 +test macFCmd-1.2 {GetFileFinderAttributes - creator} {macOnly} {
1.45 + catch {file delete -force foo.file}
1.46 + catch {close [open foo.file w]}
1.47 + list [catch {file attributes foo.file -creator} msg] \
1.48 + [regexp {MPW |CWIE} $msg] [file delete -force foo.file]
1.49 +} {0 1 {}}
1.50 +test macFCmd-1.3 {GetFileFinderAttributes - type} {macOnly} {
1.51 + catch {file delete -force foo.file}
1.52 + catch {close [open foo.file w]}
1.53 + list [catch {file attributes foo.file -type} msg] $msg \
1.54 + [file delete -force foo.file]
1.55 +} {0 TEXT {}}
1.56 +test macFCmd-1.4 {GetFileFinderAttributes - not hidden} {macOnly} {
1.57 + catch {file delete -force foo.file}
1.58 + catch {close [open foo.file w]}
1.59 + list [catch {file attributes foo.file -hidden} msg] $msg \
1.60 + [file delete -force foo.file]
1.61 +} {0 0 {}}
1.62 +test macFCmd-1.5 {GetFileFinderAttributes - hidden} {macOnly} {
1.63 + catch {file delete -force foo.file}
1.64 + catch {close [open foo.file w]}
1.65 + file attributes foo.file -hidden 1
1.66 + list [catch {file attributes foo.file -hidden} msg] $msg \
1.67 + [file delete -force foo.file]
1.68 +} {0 1 {}}
1.69 +test macFCmd-1.6 {GetFileFinderAttributes - folder creator} {macOnly} {
1.70 + catch {file delete -force foo.dir}
1.71 + file mkdir foo.dir
1.72 + list [catch {file attributes foo.dir -creator} msg] $msg \
1.73 + [file delete -force foo.dir]
1.74 +} {0 Fldr {}}
1.75 +test macFCmd-1.7 {GetFileFinderAttributes - folder type} {macOnly} {
1.76 + catch {file delete -force foo.dir}
1.77 + file mkdir foo.dir
1.78 + list [catch {file attributes foo.dir -type} msg] $msg \
1.79 + [file delete -force foo.dir]
1.80 +} {0 Fldr {}}
1.81 +test macFCmd-1.8 {GetFileFinderAttributes - folder hidden} {macOnly} {
1.82 + catch {file delete -force foo.dir}
1.83 + file mkdir foo.dir
1.84 + list [catch {file attributes foo.dir -hidden} msg] $msg \
1.85 + [file delete -force foo.dir]
1.86 +} {0 0 {}}
1.87 +
1.88 +test macFCmd-2.1 {GetFileReadOnly - bad file} {macOnly} {
1.89 + catch {file delete -force foo.file}
1.90 + list [catch {file attributes foo.file -readonly} msg] $msg
1.91 +} {1 {could not read "foo.file": no such file or directory}}
1.92 +test macFCmd-2.2 {GetFileReadOnly - file not read only} {macOnly} {
1.93 + catch {file delete -force foo.file}
1.94 + close [open foo.file w]
1.95 + list [catch {file attributes foo.file -readonly} msg] $msg \
1.96 + [file delete -force foo.file]
1.97 +} {0 0 {}}
1.98 +test macFCmd-2.3 {GetFileReadOnly - file read only} {macOnly} {
1.99 + catch {file delete -force foo.file}
1.100 + close [open foo.file w]
1.101 + file attributes foo.file -readonly 1
1.102 + list [catch {file attributes foo.file -readonly} msg] $msg \
1.103 + [file delete -force foo.file]
1.104 +} {0 1 {}}
1.105 +test macFCmd-2.4 {GetFileReadOnly - directory not read only} {macOnly} {
1.106 + catch {file delete -force foo.dir}
1.107 + file mkdir foo.dir
1.108 + list [catch {file attributes foo.dir -readonly} msg] $msg \
1.109 + [file delete -force foo.dir]
1.110 +} {0 0 {}}
1.111 +test macFCmd-2.5 {GetFileReadOnly - directory read only} {macOnly fileSharing} {
1.112 + catch {file delete -force foo.dir}
1.113 + file mkdir foo.dir
1.114 + file attributes foo.dir -readonly 1
1.115 + list [catch {file attributes foo.dir -readonly} msg] $msg \
1.116 + [file delete -force foo.dir]
1.117 +} {0 1 {}}
1.118 +
1.119 +test macFCmd-3.1 {SetFileFinderAttributes - bad file} {macOnly} {
1.120 + catch {file delete -force foo.file}
1.121 + list [catch {file attributes foo.file -creator FOOO} msg] $msg
1.122 +} {1 {could not read "foo.file": no such file or directory}}
1.123 +test macFCmd-3.2 {SetFileFinderAttributes - creator} {macOnly} {
1.124 + catch {file delete -force foo.file}
1.125 + close [open foo.file w]
1.126 + list [catch {file attributes foo.file -creator FOOO} msg] $msg \
1.127 + [file attributes foo.file -creator] [file delete -force foo.file]
1.128 +} {0 {} FOOO {}}
1.129 +test macFCmd-3.3 {SetFileFinderAttributes - bad creator} {macOnly} {
1.130 + catch {file delete -force foo.file}
1.131 + close [open foo.file w]
1.132 + list [catch {file attributes foo.file -creator 0} msg] $msg \
1.133 + [file delete -force foo.file]
1.134 +} {1 {expected Macintosh OS type but got "0"} {}}
1.135 +test macFCmd-3.4 {SetFileFinderAttributes - hidden} {macOnly} {
1.136 + catch {file delete -force foo.file}
1.137 + close [open foo.file w]
1.138 + list [catch {file attributes foo.file -hidden 1} msg] $msg \
1.139 + [file attributes foo.file -hidden] [file delete -force foo.file]
1.140 +} {0 {} 1 {}}
1.141 +test macFCmd-3.5 {SetFileFinderAttributes - type} {macOnly} {
1.142 + catch {file delete -force foo.file}
1.143 + close [open foo.file w]
1.144 + list [catch {file attributes foo.file -type FOOO} msg] $msg \
1.145 + [file attributes foo.file -type] [file delete -force foo.file]
1.146 +} {0 {} FOOO {}}
1.147 +test macFCmd-3.6 {SetFileFinderAttributes - bad type} {macOnly} {
1.148 + catch {file delete -force foo.file}
1.149 + close [open foo.file w]
1.150 + list [catch {file attributes foo.file -type 0} msg] $msg \
1.151 + [file delete -force foo.file]
1.152 +} {1 {expected Macintosh OS type but got "0"} {}}
1.153 +test macFCmd-3.7 {SetFileFinderAttributes - directory} {macOnly} {
1.154 + catch {file delete -force foo.dir}
1.155 + file mkdir foo.dir
1.156 + list [catch {file attributes foo.dir -creator FOOO} msg] \
1.157 + $msg [file delete -force foo.dir]
1.158 +} {1 {cannot set -creator: "foo.dir" is a directory} {}}
1.159 +
1.160 +test macFCmd-4.1 {SetFileReadOnly - bad file} {macOnly} {
1.161 + catch {file delete -force foo.file}
1.162 + list [catch {file attributes foo.file -readonly 1} msg] $msg
1.163 +} {1 {could not read "foo.file": no such file or directory}}
1.164 +test macFCmd-4.2 {SetFileReadOnly - file not readonly} {macOnly} {
1.165 + catch {file delete -force foo.file}
1.166 + close [open foo.file w]
1.167 + list [catch {file attributes foo.file -readonly 0} msg] \
1.168 + $msg [file attributes foo.file -readonly] [file delete -force foo.file]
1.169 +} {0 {} 0 {}}
1.170 +test macFCmd-4.3 {SetFileReadOnly - file readonly} {macOnly} {
1.171 + catch {file delete -force foo.file}
1.172 + close [open foo.file w]
1.173 + list [catch {file attributes foo.file -readonly 1} msg] \
1.174 + $msg [file attributes foo.file -readonly] [file delete -force foo.file]
1.175 +} {0 {} 1 {}}
1.176 +test macFCmd-4.4 {SetFileReadOnly - directory not readonly} \
1.177 + {macOnly fileSharing} {
1.178 + catch {file delete -force foo.dir}
1.179 + file mkdir foo.dir
1.180 + list [catch {file attributes foo.dir -readonly 0} msg] \
1.181 + $msg [file attributes foo.dir -readonly] [file delete -force foo.dir]
1.182 +} {0 {} 0 {}}
1.183 +test macFCmd-4.5 {SetFileReadOnly - directory not readonly} \
1.184 + {macOnly notFileSharing} {
1.185 + catch {file delete -force foo.dir}
1.186 + file mkdir foo.dir
1.187 + list [catch {file attributes foo.dir -readonly 0} msg] $msg \
1.188 + [file delete -force foo.dir]
1.189 +} {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
1.190 +test macFCmd-4.6 {SetFileReadOnly - directory readonly} {macOnly fileSharing} {
1.191 + catch {file delete -force foo.dir}
1.192 + file mkdir foo.dir
1.193 + list [catch {file attributes foo.dir -readonly 1} msg] $msg \
1.194 + [file attributes foo.dir -readonly] [file delete -force foo.dir]
1.195 +} {0 {} 1 {}}
1.196 +test macFCmd-4.7 {SetFileReadOnly - directory readonly} {macOnly notFileSharing} {
1.197 + catch {file delete -force foo.dir}
1.198 + file mkdir foo.dir
1.199 + list [catch {file attributes foo.dir -readonly 1} msg] $msg \
1.200 + [file delete -force foo.dir]
1.201 +} {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
1.202 +
1.203 +# cleanup
1.204 +cd $oldcwd
1.205 +::tcltest::cleanupTests
1.206 +return