os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/macFCmd.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # This file tests the tclfCmd.c file.
     2 #
     3 # This file contains a collection of tests for one or more of the Tcl
     4 # built-in commands.  Sourcing this file into Tcl runs the tests and
     5 # generates output for errors.  No output means no errors were found.
     6 #
     7 # Copyright (c) 1997 Sun Microsystems, Inc.
     8 # Copyright (c) 1998-1999 by Scriptics Corporation.
     9 #
    10 # See the file "license.terms" for information on usage and redistribution
    11 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    12 #
    13 # RCS: @(#) $Id: macFCmd.test,v 1.10 2002/07/05 10:38:43 dkf Exp $
    14 #
    15 
    16 if {[lsearch [namespace children] ::tcltest] == -1} {
    17     package require tcltest
    18     namespace import -force ::tcltest::*
    19 }
    20 
    21 # These tests really need to be run from a writable directory, which
    22 # it is assumed [temporaryDirectory] is.
    23 set oldcwd [pwd]
    24 cd [temporaryDirectory]
    25 
    26 catch {file delete -force foo.dir}
    27 file mkdir foo.dir
    28 if {[catch {file attributes foo.dir -readonly 1}]} {
    29     set ::tcltest::testConstraints(fileSharing) 0
    30     set ::tcltest::testConstraints(notFileSharing) 1
    31 } else {
    32     set ::tcltest::testConstraints(fileSharing) 1
    33     set ::tcltest::testConstraints(notFileSharing) 0
    34 }
    35 file delete -force foo.dir
    36 
    37 test macFCmd-1.1 {GetFileFinderAttributes - no file} {macOnly} {
    38     catch {file delete -force foo.file}
    39     list [catch {file attributes foo.file -creator} msg] $msg
    40 } {1 {could not read "foo.file": no such file or directory}}
    41 test macFCmd-1.2 {GetFileFinderAttributes - creator} {macOnly} {
    42     catch {file delete -force foo.file}
    43     catch {close [open foo.file w]}
    44     list [catch {file attributes foo.file -creator} msg] \
    45 	    [regexp {MPW |CWIE} $msg] [file delete -force foo.file]
    46 } {0 1 {}}
    47 test macFCmd-1.3 {GetFileFinderAttributes - type} {macOnly} {
    48     catch {file delete -force foo.file}
    49     catch {close [open foo.file w]}
    50     list [catch {file attributes foo.file -type} msg] $msg \
    51 	    [file delete -force foo.file]
    52 } {0 TEXT {}}
    53 test macFCmd-1.4 {GetFileFinderAttributes - not hidden} {macOnly} {
    54     catch {file delete -force foo.file}
    55     catch {close [open foo.file w]}
    56     list [catch {file attributes foo.file -hidden} msg] $msg \
    57 	    [file delete -force foo.file]
    58 } {0 0 {}}
    59 test macFCmd-1.5 {GetFileFinderAttributes - hidden} {macOnly} {
    60     catch {file delete -force foo.file}
    61     catch {close [open foo.file w]}
    62     file attributes foo.file -hidden 1
    63     list [catch {file attributes foo.file -hidden} msg] $msg \
    64 	    [file delete -force foo.file]
    65 } {0 1 {}}
    66 test macFCmd-1.6 {GetFileFinderAttributes - folder creator} {macOnly} {
    67     catch {file delete -force foo.dir}
    68     file mkdir foo.dir
    69     list [catch {file attributes foo.dir -creator} msg] $msg \
    70 	    [file delete -force foo.dir]
    71 } {0 Fldr {}}
    72 test macFCmd-1.7 {GetFileFinderAttributes - folder type} {macOnly} {
    73     catch {file delete -force foo.dir}
    74     file mkdir foo.dir
    75     list [catch {file attributes foo.dir -type} msg] $msg \
    76 	    [file delete -force foo.dir]
    77 } {0 Fldr {}}
    78 test macFCmd-1.8 {GetFileFinderAttributes - folder hidden} {macOnly} {
    79     catch {file delete -force foo.dir}
    80     file mkdir foo.dir
    81     list [catch {file attributes foo.dir -hidden} msg] $msg \
    82 	    [file delete -force foo.dir]
    83 } {0 0 {}}
    84 
    85 test macFCmd-2.1 {GetFileReadOnly - bad file} {macOnly} {
    86     catch {file delete -force foo.file}
    87     list [catch {file attributes foo.file -readonly} msg] $msg
    88 } {1 {could not read "foo.file": no such file or directory}}
    89 test macFCmd-2.2 {GetFileReadOnly - file not read only} {macOnly} {
    90     catch {file delete -force foo.file}
    91     close [open foo.file w]
    92     list [catch {file attributes foo.file -readonly} msg] $msg \
    93 	    [file delete -force foo.file]
    94 } {0 0 {}}
    95 test macFCmd-2.3 {GetFileReadOnly - file read only} {macOnly} {
    96     catch {file delete -force foo.file}
    97     close [open foo.file w]
    98     file attributes foo.file -readonly 1
    99     list [catch {file attributes foo.file -readonly} msg] $msg \
   100 	    [file delete -force foo.file]
   101 } {0 1 {}}
   102 test macFCmd-2.4 {GetFileReadOnly - directory not read only} {macOnly} {
   103     catch {file delete -force foo.dir}
   104     file mkdir foo.dir
   105     list [catch {file attributes foo.dir -readonly} msg] $msg \
   106 	    [file delete -force foo.dir]
   107 } {0 0 {}}
   108 test macFCmd-2.5 {GetFileReadOnly - directory read only} {macOnly fileSharing} {
   109     catch {file delete -force foo.dir}
   110     file mkdir foo.dir
   111     file attributes foo.dir -readonly 1
   112     list [catch {file attributes foo.dir -readonly} msg] $msg \
   113 	    [file delete -force foo.dir]
   114 } {0 1 {}}
   115 
   116 test macFCmd-3.1 {SetFileFinderAttributes - bad file} {macOnly} {
   117     catch {file delete -force foo.file}
   118     list [catch {file attributes foo.file -creator FOOO} msg] $msg
   119 } {1 {could not read "foo.file": no such file or directory}}
   120 test macFCmd-3.2 {SetFileFinderAttributes - creator} {macOnly} {
   121     catch {file delete -force foo.file}
   122     close [open foo.file w]
   123     list [catch {file attributes foo.file -creator FOOO} msg] $msg \
   124 	    [file attributes foo.file -creator] [file delete -force foo.file]
   125 } {0 {} FOOO {}}
   126 test macFCmd-3.3 {SetFileFinderAttributes - bad creator} {macOnly} {
   127     catch {file delete -force foo.file}
   128     close [open foo.file w]
   129     list [catch {file attributes foo.file -creator 0} msg] $msg \
   130 	    [file delete -force foo.file]
   131 } {1 {expected Macintosh OS type but got "0"} {}}
   132 test macFCmd-3.4 {SetFileFinderAttributes - hidden} {macOnly} {
   133     catch {file delete -force foo.file}
   134     close [open foo.file w]
   135     list [catch {file attributes foo.file -hidden 1} msg] $msg \
   136 	    [file attributes foo.file -hidden] [file delete -force foo.file]
   137 } {0 {} 1 {}}
   138 test macFCmd-3.5 {SetFileFinderAttributes - type} {macOnly} {
   139     catch {file delete -force foo.file}
   140     close [open foo.file w]
   141     list [catch {file attributes foo.file -type FOOO} msg] $msg \
   142 	    [file attributes foo.file -type] [file delete -force foo.file]
   143 } {0 {} FOOO {}}
   144 test macFCmd-3.6 {SetFileFinderAttributes - bad type} {macOnly} {
   145     catch {file delete -force foo.file}
   146     close [open foo.file w]
   147     list [catch {file attributes foo.file -type 0} msg] $msg \
   148 	    [file delete -force foo.file]
   149 } {1 {expected Macintosh OS type but got "0"} {}}
   150 test macFCmd-3.7 {SetFileFinderAttributes - directory} {macOnly} {
   151     catch {file delete -force foo.dir}
   152     file mkdir foo.dir
   153     list [catch {file attributes foo.dir -creator FOOO} msg] \
   154 	    $msg [file delete -force foo.dir]
   155 } {1 {cannot set -creator: "foo.dir" is a directory} {}}
   156 
   157 test macFCmd-4.1 {SetFileReadOnly - bad file} {macOnly} {
   158     catch {file delete -force foo.file}
   159     list [catch {file attributes foo.file -readonly 1} msg] $msg
   160 } {1 {could not read "foo.file": no such file or directory}}
   161 test macFCmd-4.2 {SetFileReadOnly - file not readonly} {macOnly} {
   162     catch {file delete -force foo.file}
   163     close [open foo.file w]
   164     list [catch {file attributes foo.file -readonly 0} msg] \
   165 	    $msg [file attributes foo.file -readonly] [file delete -force foo.file]
   166 } {0 {} 0 {}}
   167 test macFCmd-4.3 {SetFileReadOnly - file readonly} {macOnly} {
   168     catch {file delete -force foo.file}
   169     close [open foo.file w]
   170     list [catch {file attributes foo.file -readonly 1} msg] \
   171 	    $msg [file attributes foo.file -readonly] [file delete -force foo.file]
   172 } {0 {} 1 {}}
   173 test macFCmd-4.4 {SetFileReadOnly - directory not readonly} \
   174 	{macOnly fileSharing} {
   175     catch {file delete -force foo.dir}
   176     file mkdir foo.dir
   177     list [catch {file attributes foo.dir -readonly 0} msg] \
   178 	    $msg [file attributes foo.dir -readonly] [file delete -force foo.dir]
   179 } {0 {} 0 {}}
   180 test macFCmd-4.5 {SetFileReadOnly - directory not readonly} \
   181 	{macOnly notFileSharing} {
   182     catch {file delete -force foo.dir}
   183     file mkdir foo.dir
   184     list [catch {file attributes foo.dir -readonly 0} msg] $msg \
   185 	    [file delete -force foo.dir]
   186 } {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
   187 test macFCmd-4.6 {SetFileReadOnly - directory readonly} {macOnly fileSharing} {
   188     catch {file delete -force foo.dir}
   189     file mkdir foo.dir
   190     list [catch {file attributes foo.dir -readonly 1} msg] $msg \
   191 	    [file attributes foo.dir -readonly] [file delete -force foo.dir]
   192 } {0 {} 1 {}}
   193 test macFCmd-4.7 {SetFileReadOnly - directory readonly} {macOnly notFileSharing} {
   194     catch {file delete -force foo.dir}
   195     file mkdir foo.dir
   196     list [catch {file attributes foo.dir -readonly 1} msg] $msg \
   197 	    [file delete -force foo.dir]
   198 } {1 {cannot set a directory to read-only when File Sharing is turned off} {}}
   199 
   200 # cleanup
   201 cd $oldcwd
   202 ::tcltest::cleanupTests
   203 return