home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / cmdAH.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  36.4 KB  |  1,257 lines  |  [TEXT/ALFA]

  1. # The file tests the tclCmdAH.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) 1996-1997 by Sun Microsystems, Inc.
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12. # SCCS: @(#) cmdAH.test 1.35 97/07/22 14:07:43
  13.  
  14. if {[string compare test [info procs test]] == 1} then {source defs}
  15.  
  16. global env
  17. set platform [testgetplatform]
  18.  
  19. test cmdAH-1.1 {Tcl_FileObjCmd} {
  20.     list [catch file msg] $msg
  21. } {1 {wrong # args: should be "file option ?arg ...?"}}
  22. test cmdAH-1.2 {Tcl_FileObjCmd} {
  23.     list [catch {file x} msg] $msg
  24. } {1 {bad option "x": must be atime, attributes, 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}}
  25. test cmdAH-1.3 {Tcl_FileObjCmd} {
  26.     list [catch {file atime} msg] $msg
  27. } {1 {wrong # args: should be "file atime name ?arg ...?"}}
  28.  
  29.  
  30. #volume
  31.  
  32. test cmdAH-2.1 {Tcl_FileObjCmd: volumes} {
  33.     list [catch {file volumes x} msg] $msg    
  34. } {1 {wrong # args: should be "file volumes"}}
  35. test cmdAH-2.2 {Tcl_FileObjCmd: volumes} {
  36.     set volumeList [file volumes]
  37.     if { [llength $volumeList] == 0 } {
  38.         set result 0
  39.     } else {
  40.         set result 1
  41.     }    
  42. } {1}
  43. test cmdAH-2.3 {Tcl_FileObjCmd: volumes} {macOrUnix} {
  44.     set volumeList [file volumes]
  45.     catch [list glob -nocomplain [lindex $volumeList 0]*]
  46. } {0}
  47. test cmdAH-2.4 {Tcl_FileObjCmd: volumes} {pcOnly} {
  48.     set volumeList [file volumes]
  49.     list [catch {lsearch $volumeList "c:/"} element] [expr $element != -1] [catch {list glob -nocomplain [lindex $volumeList $element]*}]
  50. } {0 1 0}
  51.  
  52. # attributes
  53.  
  54. test cmdAH-3.1 {Tcl_FileObjCmd - file attrs} {
  55.     catch {file delete -force foo.file}
  56.     close [open foo.file w]
  57.     list [catch {file attributes foo.file}] [file delete -force foo.file]
  58. } {0 {}}
  59.  
  60. # dirname
  61.  
  62. test cmdAH-4.1 {Tcl_FileObjCmd: dirname} {
  63.     testsetplatform unix
  64.     list [catch {file dirname a b} msg] $msg
  65. } {1 {wrong # args: should be "file dirname name"}}
  66. test cmdAH-4.2 {Tcl_FileObjCmd: dirname} {
  67.     testsetplatform unix
  68.     file dirname /a/b
  69. } /a
  70. test cmdAH-4.3 {Tcl_FileObjCmd: dirname} {
  71.     testsetplatform unix
  72.     file dirname {}
  73. } .
  74. test cmdAH-4.4 {Tcl_FileObjCmd: dirname} {
  75.     testsetplatform mac
  76.     file dirname {}
  77. } :
  78. test cmdAH-4.5 {Tcl_FileObjCmd: dirname} {
  79.     testsetplatform win
  80.     file dirname {}
  81. } .
  82. test cmdAH-4.6 {Tcl_FileObjCmd: dirname} {
  83.     testsetplatform unix
  84.     file dirname .def
  85. } .
  86. test cmdAH-4.7 {Tcl_FileObjCmd: dirname} {
  87.     testsetplatform mac
  88.     file dirname a
  89. } :
  90. test cmdAH-4.8 {Tcl_FileObjCmd: dirname} {
  91.     testsetplatform win
  92.     file dirname a
  93. } .
  94. test cmdAH-4.9 {Tcl_FileObjCmd: dirname} {
  95.     testsetplatform unix
  96.     file dirname a/b/c.d
  97. } a/b
  98. test cmdAH-4.10 {Tcl_FileObjCmd: dirname} {
  99.     testsetplatform unix
  100.     file dirname a/b.c/d
  101. } a/b.c
  102. test cmdAH-4.11 {Tcl_FileObjCmd: dirname} {
  103.     testsetplatform unix
  104.     file dirname /.
  105. } /
  106. test cmdAH-4.12 {Tcl_FileObjCmd: dirname} {
  107.     testsetplatform unix
  108.     list [catch {file dirname /} msg] $msg
  109. } {0 /}
  110. test cmdAH-4.13 {Tcl_FileObjCmd: dirname} {
  111.     testsetplatform unix
  112.     list [catch {file dirname /foo} msg] $msg
  113. } {0 /}
  114. test cmdAH-4.14 {Tcl_FileObjCmd: dirname} {
  115.     testsetplatform unix
  116.     list [catch {file dirname //foo} msg] $msg
  117. } {0 /}
  118. test cmdAH-4.15 {Tcl_FileObjCmd: dirname} {
  119.     testsetplatform unix
  120.     list [catch {file dirname //foo/bar} msg] $msg
  121. } {0 /foo}
  122. test cmdAH-4.16 {Tcl_FileObjCmd: dirname} {
  123.     testsetplatform unix
  124.     list [catch {file dirname {//foo\/bar/baz}} msg] $msg
  125. } {0 {/foo\/bar}}
  126. test cmdAH-4.17 {Tcl_FileObjCmd: dirname} {
  127.     testsetplatform unix
  128.     list [catch {file dirname {//foo\/bar/baz/blat}} msg] $msg
  129. } {0 {/foo\/bar/baz}}
  130. test cmdAH-4.18 {Tcl_FileObjCmd: dirname} {
  131.     testsetplatform unix
  132.     list [catch {file dirname /foo//} msg] $msg
  133. } {0 /}
  134. test cmdAH-4.19 {Tcl_FileObjCmd: dirname} {
  135.     testsetplatform unix
  136.     list [catch {file dirname ./a} msg] $msg
  137. } {0 .}
  138. test cmdAH-4.20 {Tcl_FileObjCmd: dirname} {
  139.     testsetplatform unix
  140.     list [catch {file dirname a/.a} msg] $msg
  141. } {0 a}
  142. test cmdAH-4.21 {Tcl_FileObjCmd: dirname} {
  143.     testsetplatform windows
  144.     list [catch {file dirname c:foo} msg] $msg
  145. } {0 c:}
  146. test cmdAH-4.22 {Tcl_FileObjCmd: dirname} {
  147.     testsetplatform windows
  148.     list [catch {file dirname c:} msg] $msg
  149. } {0 c:}
  150. test cmdAH-4.23 {Tcl_FileObjCmd: dirname} {
  151.     testsetplatform windows
  152.     list [catch {file dirname c:/} msg] $msg
  153. } {0 c:/}
  154. test cmdAH-4.24 {Tcl_FileObjCmd: dirname} {
  155.     testsetplatform windows
  156.     list [catch {file dirname {c:\foo}} msg] $msg
  157. } {0 c:/}
  158. test cmdAH-4.25 {Tcl_FileObjCmd: dirname} {
  159.     testsetplatform windows
  160.     list [catch {file dirname {//foo/bar/baz}} msg] $msg
  161. } {0 //foo/bar}
  162. test cmdAH-4.26 {Tcl_FileObjCmd: dirname} {
  163.     testsetplatform windows
  164.     list [catch {file dirname {//foo/bar}} msg] $msg
  165. } {0 //foo/bar}
  166. test cmdAH-4.27 {Tcl_FileObjCmd: dirname} {
  167.     testsetplatform mac
  168.     list [catch {file dirname :} msg] $msg
  169. } {0 :}
  170. test cmdAH-4.28 {Tcl_FileObjCmd: dirname} {
  171.     testsetplatform mac
  172.     list [catch {file dirname :Foo} msg] $msg
  173. } {0 :}
  174. test cmdAH-4.29 {Tcl_FileObjCmd: dirname} {
  175.     testsetplatform mac
  176.     list [catch {file dirname Foo:} msg] $msg
  177. } {0 Foo:}
  178. test cmdAH-4.30 {Tcl_FileObjCmd: dirname} {
  179.     testsetplatform mac
  180.     list [catch {file dirname Foo:bar} msg] $msg
  181. } {0 Foo:}
  182. test cmdAH-4.31 {Tcl_FileObjCmd: dirname} {
  183.     testsetplatform mac
  184.     list [catch {file dirname :Foo:bar} msg] $msg
  185. } {0 :Foo}
  186. test cmdAH-4.32 {Tcl_FileObjCmd: dirname} {
  187.     testsetplatform mac
  188.     list [catch {file dirname ::} msg] $msg
  189. } {0 :}
  190. test cmdAH-4.33 {Tcl_FileObjCmd: dirname} {
  191.     testsetplatform mac
  192.     list [catch {file dirname :::} msg] $msg
  193. } {0 ::}
  194. test cmdAH-4.34 {Tcl_FileObjCmd: dirname} {
  195.     testsetplatform mac
  196.     list [catch {file dirname /foo/bar/} msg] $msg
  197. } {0 foo:}
  198. test cmdAH-4.35 {Tcl_FileObjCmd: dirname} {
  199.     testsetplatform mac
  200.     list [catch {file dirname /foo/bar} msg] $msg
  201. } {0 foo:}
  202. test cmdAH-4.36 {Tcl_FileObjCmd: dirname} {
  203.     testsetplatform mac
  204.     list [catch {file dirname /foo} msg] $msg
  205. } {0 foo:}
  206. test cmdAH-4.37 {Tcl_FileObjCmd: dirname} {
  207.     testsetplatform mac
  208.     list [catch {file dirname foo} msg] $msg
  209. } {0 :}
  210. test cmdAH-4.38 {Tcl_FileObjCmd: dirname} {
  211.     testsetplatform unix
  212.     list [catch {file dirname ~/foo} msg] $msg
  213. } {0 ~}
  214. test cmdAH-4.39 {Tcl_FileObjCmd: dirname} {
  215.     testsetplatform unix
  216.     list [catch {file dirname ~bar/foo} msg] $msg
  217. } {0 ~bar}
  218. test cmdAH-4.40 {Tcl_FileObjCmd: dirname} {
  219.     testsetplatform mac
  220.     list [catch {file dirname ~bar/foo} msg] $msg
  221. } {0 ~bar:}
  222. test cmdAH-4.41 {Tcl_FileObjCmd: dirname} {
  223.     testsetplatform mac
  224.     list [catch {file dirname ~/foo} msg] $msg
  225. } {0 ~:}
  226. test cmdAH-4.42 {Tcl_FileObjCmd: dirname} {
  227.     testsetplatform mac
  228.     list [catch {file dirname ~:baz} msg] $msg
  229. } {0 ~:}
  230. test cmdAH-4.43 {Tcl_FileObjCmd: dirname} {
  231.     global env
  232.     set temp $env(HOME)
  233.     set env(HOME) "/home/test"
  234.     testsetplatform unix
  235.     set result [list [catch {file dirname ~} msg] $msg]
  236.     set env(HOME) $temp
  237.     set result
  238. } {0 /home}
  239. test cmdAH-4.44 {Tcl_FileObjCmd: dirname} {
  240.     global env
  241.     set temp $env(HOME)
  242.     set env(HOME) "~"
  243.     testsetplatform unix
  244.     set result [list [catch {file dirname ~} msg] $msg]
  245.     set env(HOME) $temp
  246.     set result
  247. } {0 ~}
  248. test cmdAH-4.45 {Tcl_FileObjCmd: dirname} {
  249.     global env
  250.     set temp $env(HOME)
  251.     set env(HOME) "/home/test"
  252.     testsetplatform windows
  253.     set result [list [catch {file dirname ~} msg] $msg]
  254.     set env(HOME) $temp
  255.     set result
  256. } {0 /home}
  257. test cmdAH-4.46 {Tcl_FileObjCmd: dirname} {
  258.     global env
  259.     set temp $env(HOME)
  260.     set env(HOME) "/home/test"
  261.     testsetplatform mac
  262.     set result [list [catch {file dirname ~} msg] $msg]
  263.     set env(HOME) $temp
  264.     set result
  265. } {0 home:}
  266.  
  267. # tail
  268.  
  269. test cmdAH-5.1 {Tcl_FileObjCmd: tail} {
  270.     testsetplatform unix
  271.     list [catch {file tail a b} msg] $msg
  272. } {1 {wrong # args: should be "file tail name"}}
  273. test cmdAH-5.2 {Tcl_FileObjCmd: tail} {
  274.     testsetplatform unix
  275.     file tail /a/b
  276. } b
  277. test cmdAH-5.3 {Tcl_FileObjCmd: tail} {
  278.     testsetplatform unix
  279.     file tail {}
  280. } {}
  281. test cmdAH-5.4 {Tcl_FileObjCmd: tail} {
  282.     testsetplatform mac
  283.     file tail {}
  284. } {}
  285. test cmdAH-5.5 {Tcl_FileObjCmd: tail} {
  286.     testsetplatform win
  287.     file tail {}
  288. } {}
  289. test cmdAH-5.6 {Tcl_FileObjCmd: tail} {
  290.     testsetplatform unix
  291.     file tail .def
  292. } .def
  293. test cmdAH-5.7 {Tcl_FileObjCmd: tail} {
  294.     testsetplatform mac
  295.     file tail a
  296. } a
  297. test cmdAH-5.8 {Tcl_FileObjCmd: tail} {
  298.     testsetplatform win
  299.     file tail a
  300. } a
  301. test cmdAH-5.9 {Tcl_FileObjCmd: tail} {
  302.     testsetplatform unix
  303.     file ta a/b/c.d
  304. } c.d
  305. test cmdAH-5.10 {Tcl_FileObjCmd: tail} {
  306.     testsetplatform unix
  307.     file tail a/b.c/d
  308. } d
  309. test cmdAH-5.11 {Tcl_FileObjCmd: tail} {
  310.     testsetplatform unix
  311.     file tail /.
  312. } .
  313. test cmdAH-5.12 {Tcl_FileObjCmd: tail} {
  314.     testsetplatform unix
  315.     file tail /
  316. } {}
  317. test cmdAH-5.13 {Tcl_FileObjCmd: tail} {
  318.     testsetplatform unix
  319.     file tail /foo
  320. } foo
  321. test cmdAH-5.14 {Tcl_FileObjCmd: tail} {
  322.     testsetplatform unix
  323.     file tail //foo
  324. } foo
  325. test cmdAH-5.15 {Tcl_FileObjCmd: tail} {
  326.     testsetplatform unix
  327.     file tail //foo/bar
  328. } bar
  329. test cmdAH-5.16 {Tcl_FileObjCmd: tail} {
  330.     testsetplatform unix
  331.     file tail {//foo\/bar/baz}
  332. } baz
  333. test cmdAH-5.17 {Tcl_FileObjCmd: tail} {
  334.     testsetplatform unix
  335.     file tail {//foo\/bar/baz/blat}
  336. } blat
  337. test cmdAH-5.18 {Tcl_FileObjCmd: tail} {
  338.     testsetplatform unix
  339.     file tail /foo//
  340. } foo
  341. test cmdAH-5.19 {Tcl_FileObjCmd: tail} {
  342.     testsetplatform unix
  343.     file tail ./a
  344. } a
  345. test cmdAH-5.20 {Tcl_FileObjCmd: tail} {
  346.     testsetplatform unix
  347.     file tail a/.a
  348. } .a
  349. test cmdAH-5.21 {Tcl_FileObjCmd: tail} {
  350.     testsetplatform windows
  351.     file tail c:foo
  352. } foo
  353. test cmdAH-5.22 {Tcl_FileObjCmd: tail} {
  354.     testsetplatform windows
  355.     file tail c:
  356. } {}
  357. test cmdAH-5.23 {Tcl_FileObjCmd: tail} {
  358.     testsetplatform windows
  359.     file tail c:/
  360. } {}
  361. test cmdAH-5.24 {Tcl_FileObjCmd: tail} {
  362.     testsetplatform windows
  363.     file tail {c:\foo}
  364. } foo
  365. test cmdAH-5.25 {Tcl_FileObjCmd: tail} {
  366.     testsetplatform windows
  367.     file tail {//foo/bar/baz}
  368. } baz
  369. test cmdAH-5.26 {Tcl_FileObjCmd: tail} {
  370.     testsetplatform windows
  371.     file tail {//foo/bar}
  372. } {}
  373. test cmdAH-5.27 {Tcl_FileObjCmd: tail} {
  374.     testsetplatform mac
  375.     file tail :
  376. } :
  377. test cmdAH-5.28 {Tcl_FileObjCmd: tail} {
  378.     testsetplatform mac
  379.     file tail :Foo
  380. } Foo
  381. test cmdAH-5.29 {Tcl_FileObjCmd: tail} {
  382.     testsetplatform mac
  383.     file tail Foo:
  384. } {}
  385. test cmdAH-5.30 {Tcl_FileObjCmd: tail} {
  386.     testsetplatform mac
  387.     file tail Foo:bar
  388. } bar
  389. test cmdAH-5.31 {Tcl_FileObjCmd: tail} {
  390.     testsetplatform mac
  391.     file tail :Foo:bar
  392. } bar
  393. test cmdAH-5.32 {Tcl_FileObjCmd: tail} {
  394.     testsetplatform mac
  395.     file tail ::
  396. } ::
  397. test cmdAH-5.33 {Tcl_FileObjCmd: tail} {
  398.     testsetplatform mac
  399.     file tail :::
  400. } ::
  401. test cmdAH-5.34 {Tcl_FileObjCmd: tail} {
  402.     testsetplatform mac
  403.     file tail /foo/bar/
  404. } bar
  405. test cmdAH-5.35 {Tcl_FileObjCmd: tail} {
  406.     testsetplatform mac
  407.     file tail /foo/bar
  408. } bar
  409. test cmdAH-5.36 {Tcl_FileObjCmd: tail} {
  410.     testsetplatform mac
  411.     file tail /foo
  412. } {}
  413. test cmdAH-5.37 {Tcl_FileObjCmd: tail} {
  414.     testsetplatform mac
  415.     file tail foo
  416. } foo
  417. test cmdAH-5.38 {Tcl_FileObjCmd: tail} {
  418.     testsetplatform mac
  419.     file tail ~:foo
  420. } foo
  421. test cmdAH-5.39 {Tcl_FileObjCmd: tail} {
  422.     testsetplatform mac
  423.     file tail ~bar:foo
  424. } foo
  425. test cmdAH-5.40 {Tcl_FileObjCmd: tail} {
  426.     testsetplatform mac
  427.     file tail ~bar/foo
  428. } foo
  429. test cmdAH-5.41 {Tcl_FileObjCmd: tail} {
  430.     testsetplatform mac
  431.     file tail ~/foo
  432. } foo
  433. test cmdAH-5.42 {Tcl_FileObjCmd: tail} {
  434.     global env
  435.     set temp $env(HOME)
  436.     set env(HOME) "/home/test"
  437.     testsetplatform unix
  438.     set result [file tail ~]
  439.     set env(HOME) $temp
  440.     set result
  441. } test
  442. test cmdAH-5.43 {Tcl_FileObjCmd: tail} {
  443.     global env
  444.     set temp $env(HOME)
  445.     set env(HOME) "~"
  446.     testsetplatform unix
  447.     set result [file tail ~]
  448.     set env(HOME) $temp
  449.     set result
  450. } {}
  451. test cmdAH-5.44 {Tcl_FileObjCmd: tail} {
  452.     global env
  453.     set temp $env(HOME)
  454.     set env(HOME) "/home/test"
  455.     testsetplatform windows
  456.     set result [file tail ~]
  457.     set env(HOME) $temp
  458.     set result
  459. } test
  460. test cmdAH-5.45 {Tcl_FileObjCmd: tail} {
  461.     global env
  462.     set temp $env(HOME)
  463.     set env(HOME) "/home/test"
  464.     testsetplatform mac
  465.     set result [file tail ~]
  466.     set env(HOME) $temp
  467.     set result
  468. } test
  469. test cmdAH-5.46 {Tcl_FileObjCmd: tail} {
  470.     testsetplatform unix
  471.     file tail {f.oo\bar/baz.bat}
  472. } baz.bat
  473. test cmdAH-5.47 {Tcl_FileObjCmd: tail} {
  474.     testsetplatform windows
  475.     file tail c:foo
  476. } foo
  477. test cmdAH-5.48 {Tcl_FileObjCmd: tail} {
  478.     testsetplatform windows
  479.     file tail c:
  480. } {}
  481. test cmdAH-5.49 {Tcl_FileObjCmd: tail} {
  482.     testsetplatform windows
  483.     file tail c:/foo
  484. } foo
  485. test cmdAH-5.50 {Tcl_FileObjCmd: tail} {
  486.     testsetplatform windows
  487.     file tail {c:/foo\bar}
  488. } bar
  489. test cmdAH-5.51 {Tcl_FileObjCmd: tail} {
  490.     testsetplatform windows
  491.     file tail {foo\bar}
  492. } bar
  493.  
  494. # rootname
  495.  
  496. test cmdAH-6.1 {Tcl_FileObjCmd: rootname} {
  497.     testsetplatform unix
  498.     list [catch {file rootname a b} msg] $msg
  499. } {1 {wrong # args: should be "file rootname name"}}
  500. test cmdAH-6.2 {Tcl_FileObjCmd: rootname} {
  501.     testsetplatform unix
  502.     file rootname {}
  503. } {}
  504. test cmdAH-6.3 {Tcl_FileObjCmd: rootname} {
  505.     testsetplatform unix
  506.     file ro foo
  507. } foo
  508. test cmdAH-6.4 {Tcl_FileObjCmd: rootname} {
  509.     testsetplatform unix
  510.     file rootname foo.
  511. } foo
  512. test cmdAH-6.5 {Tcl_FileObjCmd: rootname} {
  513.     testsetplatform unix
  514.     file rootname .foo
  515. } {}
  516. test cmdAH-6.6 {Tcl_FileObjCmd: rootname} {
  517.     testsetplatform unix
  518.     file rootname abc.def
  519. } abc
  520. test cmdAH-6.7 {Tcl_FileObjCmd: rootname} {
  521.     testsetplatform unix
  522.     file rootname abc.def.ghi
  523. } abc.def
  524. test cmdAH-6.8 {Tcl_FileObjCmd: rootname} {
  525.     testsetplatform unix
  526.     file rootname a/b/c.d
  527. } a/b/c
  528. test cmdAH-6.9 {Tcl_FileObjCmd: rootname} {
  529.     testsetplatform unix
  530.     file rootname a/b.c/d
  531. } a/b.c/d
  532. test cmdAH-6.10 {Tcl_FileObjCmd: rootname} {
  533.     testsetplatform unix
  534.     file rootname a/b.c/
  535. } a/b.c/
  536. test cmdAH-6.11 {Tcl_FileObjCmd: rootname} {
  537.     testsetplatform mac
  538.     file ro foo
  539. } foo
  540. test cmdAH-6.12 {Tcl_FileObjCmd: rootname} {
  541.     testsetplatform mac
  542.     file rootname {}
  543. } {}
  544. test cmdAH-6.13 {Tcl_FileObjCmd: rootname} {
  545.     testsetplatform mac
  546.     file rootname foo.
  547. } foo
  548. test cmdAH-6.14 {Tcl_FileObjCmd: rootname} {
  549.     testsetplatform mac
  550.     file rootname .foo
  551. } {}
  552. test cmdAH-6.15 {Tcl_FileObjCmd: rootname} {
  553.     testsetplatform mac
  554.     file rootname abc.def
  555. } abc
  556. test cmdAH-6.16 {Tcl_FileObjCmd: rootname} {
  557.     testsetplatform mac
  558.     file rootname abc.def.ghi
  559. } abc.def
  560. test cmdAH-6.17 {Tcl_FileObjCmd: rootname} {
  561.     testsetplatform mac
  562.     file rootname a:b:c.d
  563. } a:b:c
  564. test cmdAH-6.18 {Tcl_FileObjCmd: rootname} {
  565.     testsetplatform mac
  566.     file rootname a:b.c:d
  567. } a:b.c:d
  568. test cmdAH-6.19 {Tcl_FileObjCmd: rootname} {
  569.     testsetplatform mac
  570.     file rootname a/b/c.d
  571. } a/b/c
  572. test cmdAH-6.20 {Tcl_FileObjCmd: rootname} {
  573.     testsetplatform mac
  574.     file rootname a/b.c/d
  575. } a/b.c/d
  576. test cmdAH-6.21 {Tcl_FileObjCmd: rootname} {
  577.     testsetplatform mac
  578.     file rootname /a.b
  579. } /a
  580. test cmdAH-6.22 {Tcl_FileObjCmd: rootname} {
  581.     testsetplatform mac
  582.     file rootname foo.c:
  583. } foo.c:
  584. test cmdAH-6.23 {Tcl_FileObjCmd: rootname} {
  585.     testsetplatform windows
  586.     file rootname {}
  587. } {}
  588. test cmdAH-6.24 {Tcl_FileObjCmd: rootname} {
  589.     testsetplatform windows
  590.     file ro foo
  591. } foo
  592. test cmdAH-6.25 {Tcl_FileObjCmd: rootname} {
  593.     testsetplatform windows
  594.     file rootname foo.
  595. } foo
  596. test cmdAH-6.26 {Tcl_FileObjCmd: rootname} {
  597.     testsetplatform windows
  598.     file rootname .foo
  599. } {}
  600. test cmdAH-6.27 {Tcl_FileObjCmd: rootname} {
  601.     testsetplatform windows
  602.     file rootname abc.def
  603. } abc
  604. test cmdAH-6.28 {Tcl_FileObjCmd: rootname} {
  605.     testsetplatform windows
  606.     file rootname abc.def.ghi
  607. } abc.def
  608. test cmdAH-6.29 {Tcl_FileObjCmd: rootname} {
  609.     testsetplatform windows
  610.     file rootname a/b/c.d
  611. } a/b/c
  612. test cmdAH-6.30 {Tcl_FileObjCmd: rootname} {
  613.     testsetplatform windows
  614.     file rootname a/b.c/d
  615. } a/b.c/d
  616. test cmdAH-6.31 {Tcl_FileObjCmd: rootname} {
  617.     testsetplatform windows
  618.     file rootname a\\b.c\\
  619. } a\\b.c\\
  620. test cmdAH-6.32 {Tcl_FileObjCmd: rootname} {
  621.     testsetplatform windows
  622.     file rootname a\\b\\c.d
  623. } a\\b\\c
  624. test cmdAH-6.33 {Tcl_FileObjCmd: rootname} {
  625.     testsetplatform windows
  626.     file rootname a\\b.c\\d
  627. } a\\b.c\\d
  628. test cmdAH-6.34 {Tcl_FileObjCmd: rootname} {
  629.     testsetplatform windows
  630.     file rootname a\\b.c\\
  631. } a\\b.c\\
  632. set num 35
  633. foreach outer { {} a .a a. a.a } {
  634.   foreach inner { {} a .a a. a.a } {
  635.     set thing [format %s/%s $outer $inner]
  636. ;   test cmdAH-6.$num {Tcl_FileObjCmd: rootname and extension options} {
  637.     testsetplatform unix
  638.     format %s%s [file rootname $thing] [file ext $thing]
  639.     } $thing
  640.     set num [expr $num+1]
  641.   }
  642. }
  643.  
  644. # extension
  645.  
  646. test cmdAH-7.1 {Tcl_FileObjCmd: extension} {
  647.     testsetplatform unix
  648.     list [catch {file extension a b} msg] $msg
  649. } {1 {wrong # args: should be "file extension name"}}
  650. test cmdAH-7.2 {Tcl_FileObjCmd: extension} {
  651.     testsetplatform unix
  652.     file extension {}
  653. } {}
  654. test cmdAH-7.3 {Tcl_FileObjCmd: extension} {
  655.     testsetplatform unix
  656.     file ext foo
  657. } {}
  658. test cmdAH-7.4 {Tcl_FileObjCmd: extension} {
  659.     testsetplatform unix
  660.     file extension foo.
  661. } .
  662. test cmdAH-7.5 {Tcl_FileObjCmd: extension} {
  663.     testsetplatform unix
  664.     file extension .foo
  665. } .foo
  666. test cmdAH-7.6 {Tcl_FileObjCmd: extension} {
  667.     testsetplatform unix
  668.     file extension abc.def
  669. } .def
  670. test cmdAH-7.7 {Tcl_FileObjCmd: extension} {
  671.     testsetplatform unix
  672.     file extension abc.def.ghi
  673. } .ghi
  674. test cmdAH-7.8 {Tcl_FileObjCmd: extension} {
  675.     testsetplatform unix
  676.     file extension a/b/c.d
  677. } .d
  678. test cmdAH-7.9 {Tcl_FileObjCmd: extension} {
  679.     testsetplatform unix
  680.     file extension a/b.c/d
  681. } {}
  682. test cmdAH-7.10 {Tcl_FileObjCmd: extension} {
  683.     testsetplatform unix
  684.     file extension a/b.c/
  685. } {}
  686. test cmdAH-7.11 {Tcl_FileObjCmd: extension} {
  687.     testsetplatform mac
  688.     file ext foo
  689. } {}
  690. test cmdAH-7.12 {Tcl_FileObjCmd: extension} {
  691.     testsetplatform mac
  692.     file extension {}
  693. } {}
  694. test cmdAH-7.13 {Tcl_FileObjCmd: extension} {
  695.     testsetplatform mac
  696.     file extension foo.
  697. } .
  698. test cmdAH-7.14 {Tcl_FileObjCmd: extension} {
  699.     testsetplatform mac
  700.     file extension .foo
  701. } .foo
  702. test cmdAH-7.15 {Tcl_FileObjCmd: extension} {
  703.     testsetplatform mac
  704.     file extension abc.def
  705. } .def
  706. test cmdAH-7.16 {Tcl_FileObjCmd: extension} {
  707.     testsetplatform mac
  708.     file extension abc.def.ghi
  709. } .ghi
  710. test cmdAH-7.17 {Tcl_FileObjCmd: extension} {
  711.     testsetplatform mac
  712.     file extension a:b:c.d
  713. } .d
  714. test cmdAH-7.18 {Tcl_FileObjCmd: extension} {
  715.     testsetplatform mac
  716.     file extension a:b.c:d
  717. } {}
  718. test cmdAH-7.19 {Tcl_FileObjCmd: extension} {
  719.     testsetplatform mac
  720.     file extension a/b/c.d
  721. } .d
  722. test cmdAH-7.20 {Tcl_FileObjCmd: extension} {
  723.     testsetplatform mac
  724.     file extension a/b.c/d
  725. } {}
  726. test cmdAH-7.21 {Tcl_FileObjCmd: extension} {
  727.     testsetplatform mac
  728.     file extension /a.b
  729. } .b
  730. test cmdAH-7.22 {Tcl_FileObjCmd: extension} {
  731.     testsetplatform mac
  732.     file extension foo.c:
  733. } {}
  734. test cmdAH-7.23 {Tcl_FileObjCmd: extension} {
  735.     testsetplatform windows
  736.     file extension {}
  737. } {}
  738. test cmdAH-7.24 {Tcl_FileObjCmd: extension} {
  739.     testsetplatform windows
  740.     file ext foo
  741. } {}
  742. test cmdAH-7.25 {Tcl_FileObjCmd: extension} {
  743.     testsetplatform windows
  744.     file extension foo.
  745. } .
  746. test cmdAH-7.26 {Tcl_FileObjCmd: extension} {
  747.     testsetplatform windows
  748.     file extension .foo
  749. } .foo
  750. test cmdAH-7.27 {Tcl_FileObjCmd: extension} {
  751.     testsetplatform windows
  752.     file extension abc.def
  753. } .def
  754. test cmdAH-7.28 {Tcl_FileObjCmd: extension} {
  755.     testsetplatform windows
  756.     file extension abc.def.ghi
  757. } .ghi
  758. test cmdAH-7.29 {Tcl_FileObjCmd: extension} {
  759.     testsetplatform windows
  760.     file extension a/b/c.d
  761. } .d
  762. test cmdAH-7.30 {Tcl_FileObjCmd: extension} {
  763.     testsetplatform windows
  764.     file extension a/b.c/d
  765. } {}
  766. test cmdAH-7.31 {Tcl_FileObjCmd: extension} {
  767.     testsetplatform windows
  768.     file extension a\\b.c\\
  769. } {}
  770. test cmdAH-7.32 {Tcl_FileObjCmd: extension} {
  771.     testsetplatform windows
  772.     file extension a\\b\\c.d
  773. } .d
  774. test cmdAH-7.33 {Tcl_FileObjCmd: extension} {
  775.     testsetplatform windows
  776.     file extension a\\b.c\\d
  777. } {}
  778. test cmdAH-7.34 {Tcl_FileObjCmd: extension} {
  779.     testsetplatform windows
  780.     file extension a\\b.c\\
  781. } {}
  782. set num 35
  783. foreach value {a..b a...b a.c..b ..b} result {..b ...b ..b ..b} {
  784.     foreach p {unix mac windows} {
  785. ;    test cmdAH-7.$num {Tcl_FileObjCmd: extension} "
  786.         testsetplatform $p
  787.         file extension $value
  788.     " $result
  789.     incr num
  790.     }
  791. }
  792.  
  793. # pathtype
  794.  
  795. test cmdAH-8.1 {Tcl_FileObjCmd: pathtype} {
  796.     testsetplatform unix
  797.     list [catch {file pathtype a b} msg] $msg
  798. } {1 {wrong # args: should be "file pathtype name"}}
  799. test cmdAH-8.2 {Tcl_FileObjCmd: pathtype} {
  800.     testsetplatform unix
  801.     file pathtype /a
  802. } absolute
  803. test cmdAH-8.3 {Tcl_FileObjCmd: pathtype} {
  804.     testsetplatform unix
  805.     file p a
  806. } relative
  807. test cmdAH-8.4 {Tcl_FileObjCmd: pathtype} {
  808.     testsetplatform windows
  809.     file pathtype c:a
  810. } volumerelative
  811.  
  812. # split
  813.  
  814. test cmdAH-9.1 {Tcl_FileObjCmd: split} {
  815.     testsetplatform unix
  816.     list [catch {file split a b} msg] $msg
  817. } {1 {wrong # args: should be "file split name"}}
  818. test cmdAH-9.2 {Tcl_FileObjCmd: split} {
  819.     testsetplatform unix
  820.     file split a
  821. } a
  822. test cmdAH-9.3 {Tcl_FileObjCmd: split} {
  823.     testsetplatform unix
  824.     file split a/b
  825. } {a b}
  826.  
  827. # join
  828.  
  829. test cmdAH-10.1 {Tcl_FileObjCmd: join} {
  830.     testsetplatform unix
  831.     file join a
  832. } a
  833. test cmdAH-10.2 {Tcl_FileObjCmd: join} {
  834.     testsetplatform unix
  835.     file join a b
  836. } a/b
  837. test cmdAH-10.3 {Tcl_FileObjCmd: join} {
  838.     testsetplatform unix
  839.     file join a b c d
  840. } a/b/c/d
  841.  
  842. # error handling of Tcl_TranslateFileName
  843.  
  844. test cmdAH-11.1 {Tcl_FileObjCmd} {
  845.     testsetplatform unix
  846.     list [catch {file atime ~_bad_user} msg] $msg
  847. } {1 {user "_bad_user" doesn't exist}}
  848.  
  849. testsetplatform $platform
  850. makeFile abcde gorp.file
  851. makeDirectory dir.file
  852.  
  853. # readable
  854.  
  855. test cmdAH-12.1 {Tcl_FileObjCmd: readable} {
  856.     list [catch {file readable a b} msg] $msg
  857. } {1 {wrong # args: should be "file readable name"}}
  858. testchmod 444 gorp.file
  859. test cmdAH-12.2 {Tcl_FileObjCmd: readable} {
  860.     file readable gorp.file
  861. } 1
  862. testchmod 333 gorp.file
  863. test cmdAH-12.3 {Tcl_FileObjCmd: readable} {unixOnly && !root} {
  864.     file reada gorp.file
  865. } 0
  866.  
  867. # writable
  868.  
  869. test cmdAH-13.1 {Tcl_FileObjCmd: writable} {
  870.     list [catch {file writable a b} msg] $msg
  871. } {1 {wrong # args: should be "file writable name"}}
  872. testchmod 555 gorp.file
  873. test cmdAH-13.2 {Tcl_FileObjCmd: writable} {!root} {
  874.     file writable gorp.file
  875. } 0
  876. testchmod 222 gorp.file
  877. test cmdAH-13.3 {Tcl_FileObjCmd: writable} {
  878.     file writable gorp.file
  879. } 1
  880.  
  881. # executable
  882.  
  883. file delete -force dir.file gorp.file
  884. file mkdir dir.file
  885. makeFile abcde gorp.file
  886.  
  887. test cmdAH-14.1 {Tcl_FileObjCmd: executable} {
  888.     list [catch {file executable a b} msg] $msg
  889. } {1 {wrong # args: should be "file executable name"}}
  890. test cmdAH-14.2 {Tcl_FileObjCmd: executable} {
  891.     file executable gorp.file
  892. } 0
  893. test cmdAH-14.3 {Tcl_FileObjCmd: executable} {unix} {
  894.     # Only on unix will setting the execute bit on a regular file
  895.     # cause that file to be executable.   
  896.     
  897.     testchmod 775 gorp.file
  898.     file exe gorp.file
  899. } 1
  900.  
  901. test cmdAH-14.4 {Tcl_FileObjCmd: executable} {mac} {
  902.     # On mac, the only executable files are of type APPL.
  903.  
  904.     set x [file exe gorp.file]    
  905.     file attrib gorp.file -type APPL
  906.     lappend x [file exe gorp.file]
  907. } {0 1}
  908. test cmdAH-14.5 {Tcl_FileObjCmd: executable} {pc} {
  909.     # On pc, must be a .exe, .com, etc.
  910.     
  911.     set x [file exe gorp.file]
  912.     makeFile foo gorp.exe
  913.     lappend x [file exe gorp.exe]
  914.     file delete gorp.exe
  915.     set x
  916. } {0 1}
  917. test cmdAH-14.6 {Tcl_FileObjCmd: executable} {
  918.     # Directories are always executable.
  919.     
  920.     file exe dir.file
  921. } 1
  922.  
  923. file delete -force dir.file  
  924. file delete gorp.file
  925. file delete link.file
  926. # exists
  927.  
  928. test cmdAH-15.1 {Tcl_FileObjCmd: exists} {
  929.     list [catch {file exists a b} msg] $msg
  930. } {1 {wrong # args: should be "file exists name"}}
  931. test cmdAH-15.2 {Tcl_FileObjCmd: exists} {file exists gorp.file} 0
  932. test cmdAH-15.3 {Tcl_FileObjCmd: exists} {
  933.     file exists [file join dir.file gorp.file]
  934. } 0
  935. catch {
  936.     makeFile abcde gorp.file
  937.     makeDirectory dir.file
  938.     makeFile 12345 [file join dir.file gorp.file]
  939. }
  940. test cmdAH-15.4 {Tcl_FileObjCmd: exists} {
  941.     file exists gorp.file
  942. } 1
  943. test cmdAH-15.5 {Tcl_FileObjCmd: exists} {
  944.     file exists [file join dir.file gorp.file]
  945. } 1
  946.  
  947. # nativename
  948. test cmdAH-15.6 {Tcl_FileObjCmd: nativename} {
  949.     testsetplatform unix
  950.     list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
  951. } {0 a/b {}}
  952. test cmdAH-15.7 {Tcl_FileObjCmd: nativename} {
  953.     testsetplatform windows
  954.     list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
  955. } {0 {a\b} {}}
  956. test cmdAH-15.8 {Tcl_FileObjCmd: nativename} {
  957.     testsetplatform mac
  958.     list [catch {file nativename a/b} msg] $msg [testsetplatform $platform]
  959. } {0 :a:b {}}
  960.  
  961. test cmdAH-15.9 {Tcl_FileObjCmd: ~ : exists} {
  962.     file exists ~nOsUcHuSeR
  963. } 0
  964. test cmdAH-15.10 {Tcl_FileObjCmd: ~ : nativename} {
  965.     # should probably be 0 in fact...
  966.     catch {file nativename ~nOsUcHuSeR}
  967. } 1
  968.  
  969. # The test below has to be done in /tmp rather than the current
  970. # directory in order to guarantee (?) a local file system:  some
  971. # NFS file systems won't do the stuff below correctly.
  972.  
  973. if {$tcl_platform(platform) == "unix"} {
  974.     file delete /tmp/tcl.foo.dir/file
  975.     removeDirectory /tmp/tcl.foo.dir
  976.     makeDirectory /tmp/tcl.foo.dir
  977.     makeFile 12345 /tmp/tcl.foo.dir/file
  978.     exec chmod 000 /tmp/tcl.foo.dir
  979.     if {$user != "root"} {
  980.     test cmdAH-15.9 {Tcl_FileObjCmd: exists} {
  981.         file exists /tmp/tcl.foo.dir/file
  982.     } 0
  983.     }
  984.     exec chmod 775 /tmp/tcl.foo.dir
  985.     file delete /tmp/tcl.foo.dir/file
  986.     removeDirectory /tmp/tcl.foo.dir
  987. }
  988.  
  989. # Stat related commands
  990.  
  991. testsetplatform $platform
  992. file delete gorp.file
  993. makeFile "Test string" gorp.file
  994. catch {exec chmod 765 gorp.file}
  995.  
  996. # atime
  997.  
  998. test cmdAH-16.1 {Tcl_FileObjCmd: atime} {
  999.     list [catch {file atime a b} msg] $msg
  1000. } {1 {wrong # args: should be "file atime name"}}
  1001. test cmdAH-16.2 {Tcl_FileObjCmd: atime} {
  1002.     catch {unset stat}
  1003.     file stat gorp.file stat
  1004.     list [expr {[file mtime gorp.file] == $stat(mtime)}] \
  1005.         [expr {[file atime gorp.file] == $stat(atime)}]
  1006. } {1 1}
  1007. test cmdAH-16.3 {Tcl_FileObjCmd: atime} {
  1008.     string tolower [list [catch {file atime _bogus_} msg] \
  1009.         $msg $errorCode]
  1010. } {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1011.  
  1012. # isdirectory
  1013.  
  1014. test cmdAH-17.1 {Tcl_FileObjCmd: isdirectory} {
  1015.     list [catch {file isdirectory a b} msg] $msg
  1016. } {1 {wrong # args: should be "file isdirectory name"}}
  1017. test cmdAH-17.2 {Tcl_FileObjCmd: isdirectory} {
  1018.     file isdirectory gorp.file
  1019. } 0
  1020. test cmdAH-17.3 {Tcl_FileObjCmd: isdirectory} {
  1021.     file isd dir.file
  1022. } 1
  1023.  
  1024. # isfile
  1025.  
  1026. test cmdAH-18.1 {Tcl_FileObjCmd: isfile} {
  1027.     list [catch {file isfile a b} msg] $msg
  1028. } {1 {wrong # args: should be "file isfile name"}}
  1029. test cmdAH-18.2 {Tcl_FileObjCmd: isfile} {file isfile gorp.file} 1
  1030. test cmdAH-18.3 {Tcl_FileObjCmd: isfile} {file isfile dir.file} 0
  1031.  
  1032. # lstat and readlink:  don't run these tests everywhere, since not all
  1033. # sites will have symbolic links
  1034.  
  1035. catch {exec ln -s gorp.file link.file}
  1036. test cmdAH-19.1 {Tcl_FileObjCmd: lstat} {
  1037.     list [catch {file lstat a} msg] $msg
  1038. } {1 {wrong # args: should be "file lstat name varName"}}
  1039. test cmdAH-19.2 {Tcl_FileObjCmd: lstat} {
  1040.     list [catch {file lstat a b c} msg] $msg
  1041. } {1 {wrong # args: should be "file lstat name varName"}}
  1042. test cmdAH-19.3 {Tcl_FileObjCmd: lstat} {unixOnly nonPortable} {
  1043.     catch {unset stat}
  1044.     file lstat link.file stat
  1045.     lsort [array names stat]
  1046. } {atime ctime dev gid ino mode mtime nlink size type uid}
  1047. test cmdAH-19.4 {Tcl_FileObjCmd: lstat} {unixOnly nonPortable} {
  1048.     catch {unset stat}
  1049.     file lstat link.file stat
  1050.     list $stat(nlink) [expr $stat(mode)&0777] $stat(type)
  1051. } {1 511 link}
  1052. test cmdAH-19.5 {Tcl_FileObjCmd: lstat errors} {nonPortable} {
  1053.     string tolower [list [catch {file lstat _bogus_ stat} msg] \
  1054.         $msg $errorCode]
  1055. } {1 {couldn't lstat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1056. test cmdAH-19.6 {Tcl_FileObjCmd: lstat errors} {
  1057.     catch {unset x}
  1058.     set x 44
  1059.     list [catch {file lstat gorp.file x} msg] $msg $errorCode
  1060. } {1 {can't set "x(dev)": variable isn't array} NONE}
  1061. catch {unset stat}
  1062.  
  1063. # mtime 
  1064.  
  1065. test cmdAH-20.1 {Tcl_FileObjCmd: mtime} {
  1066.     list [catch {file mtime a b} msg] $msg
  1067. } {1 {wrong # args: should be "file mtime name"}}
  1068. test cmdAH-20.2 {Tcl_FileObjCmd: mtime} {
  1069.     set old [file mtime gorp.file]
  1070.     after 2000
  1071.     set f [open gorp.file w]
  1072.     puts $f "More text"
  1073.     close $f
  1074.     set new [file mtime gorp.file]
  1075.     expr {($new > $old) && ($new <= ($old+5))}
  1076. } {1}
  1077. test cmdAH-20.3 {Tcl_FileObjCmd: mtime} {
  1078.     catch {unset stat}
  1079.     file stat gorp.file stat
  1080.     list [expr {[file mtime gorp.file] == $stat(mtime)}] \
  1081.         [expr {[file atime gorp.file] == $stat(atime)}]
  1082. } {1 1}
  1083. test cmdAH-20.4 {Tcl_FileObjCmd: mtime} {
  1084.     string tolower [list [catch {file mtime _bogus_} msg] $msg \
  1085.         $errorCode]
  1086. } {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1087. test cmdAH-20.5 {Tcl_FileObjCmd: mtime} {
  1088.     # Under Unix, use a file in /tmp to avoid clock skew due to NFS.
  1089.     # On other platforms, just use a file in the local directory.
  1090.  
  1091.     if {$tcl_platform(platform) == "unix"} {
  1092.      set name /tmp/tcl.test
  1093.     } else {
  1094.     set name tf
  1095.     }
  1096.  
  1097.     # Borland file times were off by timezone.  Make sure that a new file's
  1098.     # time is correct.  10 seconds variance is allowed used due to slow
  1099.     # networks or clock skew on a network drive.
  1100.  
  1101.     file delete -force $name
  1102.     close [open $name w]
  1103.     set a [expr abs([clock seconds]-[file mtime $name])<10]
  1104.     file delete $name
  1105.     set a
  1106. } {1}
  1107.  
  1108.  
  1109. # owned
  1110.  
  1111. test cmdAH-21.1 {Tcl_FileObjCmd: owned} {
  1112.     list [catch {file owned a b} msg] $msg
  1113. } {1 {wrong # args: should be "file owned name"}}
  1114. test cmdAH-21.2 {Tcl_FileObjCmd: owned} {
  1115.     file owned gorp.file
  1116. } 1
  1117. test cmdAH-21.3 {Tcl_FileObjCmd: owned} {unixOnly && !root} {
  1118.     file owned /
  1119. } 0
  1120.  
  1121. # readlink
  1122.  
  1123. test cmdAH-22.1 {Tcl_FileObjCmd: readlink} {
  1124.     list [catch {file readlink a b} msg] $msg
  1125. } {1 {wrong # args: should be "file readlink name"}}
  1126. test cmdAH-22.2 {Tcl_FileObjCmd: readlink} {unixOnly nonPortable} {
  1127.     file readlink link.file
  1128. } gorp.file
  1129. test cmdAH-22.3 {Tcl_FileObjCmd: readlink errors} {unixOnly nonPortable} {
  1130.     list [catch {file readlink _bogus_} msg] [string tolower $msg] \
  1131.         [string tolower $errorCode]
  1132. } {1 {couldn't readlink "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1133. test cmdAH-22.4 {Tcl_FileObjCmd: readlink errors} {macOnly nonPortable} {
  1134.     list [catch {file readlink _bogus_} msg] [string tolower $msg] \
  1135.         [string tolower $errorCode]
  1136. } {1 {couldn't readlink "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1137. test cmdAH-22.5 {Tcl_FileObjCmd: readlink errors} {pcOnly nonPortable} {
  1138.     list [catch {file readlink _bogus_} msg] [string tolower $msg] \
  1139.         [string tolower $errorCode]
  1140. } {1 {couldn't readlink "_bogus_": invalid argument} {posix einval {invalid argument}}}
  1141.  
  1142. # size
  1143.  
  1144. test cmdAH-23.1 {Tcl_FileObjCmd: size} {
  1145.     list [catch {file size a b} msg] $msg
  1146. } {1 {wrong # args: should be "file size name"}}
  1147. test cmdAH-23.2 {Tcl_FileObjCmd: size} {
  1148.     set oldsize [file size gorp.file]
  1149.     set f [open gorp.file a]
  1150.     fconfigure $f -translation lf -eofchar {}
  1151.     puts $f "More text"
  1152.     close $f
  1153.     expr {[file size gorp.file] - $oldsize}
  1154. } {10}
  1155. test cmdAH-23.3 {Tcl_FileObjCmd: size} {
  1156.     string tolower [list [catch {file size _bogus_} msg] $msg \
  1157.         $errorCode]
  1158. } {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1159.  
  1160. # stat
  1161.  
  1162. testsetplatform $platform
  1163. makeFile "Test string" gorp.file
  1164. catch {exec chmod 765 gorp.file}
  1165.  
  1166. test cmdAH-24.1 {Tcl_FileObjCmd: stat} {
  1167.     list [catch {file stat _bogus_} msg] $msg $errorCode
  1168. } {1 {wrong # args: should be "file stat name varName"} NONE}
  1169. test cmdAH-24.2 {Tcl_FileObjCmd: stat} {
  1170.     list [catch {file stat _bogus_ a b} msg] $msg $errorCode
  1171. } {1 {wrong # args: should be "file stat name varName"} NONE}
  1172. test cmdAH-24.3 {Tcl_FileObjCmd: stat} {
  1173.     catch {unset stat}
  1174.     file stat gorp.file stat
  1175.     lsort [array names stat]
  1176. } {atime ctime dev gid ino mode mtime nlink size type uid}
  1177. test cmdAH-24.4 {Tcl_FileObjCmd: stat} {
  1178.     catch {unset stat}
  1179.     file stat gorp.file stat
  1180.     list $stat(nlink) $stat(size) $stat(type)
  1181. } {1 12 file}
  1182. test cmdAH-24.5 {Tcl_FileObjCmd: stat} {unix} {
  1183.     catch {unset stat}
  1184.     file stat gorp.file stat
  1185.     expr $stat(mode)&0777
  1186. } {501}
  1187. test cmdAH-24.6 {Tcl_FileObjCmd: stat} {
  1188.     string tolower [list [catch {file stat _bogus_ stat} msg] \
  1189.         $msg $errorCode]
  1190. } {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1191. test cmdAH-24.7 {Tcl_FileObjCmd: stat} {
  1192.     catch {unset x}
  1193.     set x 44
  1194.     list [catch {file stat gorp.file x} msg] $msg $errorCode
  1195. } {1 {can't set "x(dev)": variable isn't array} NONE}
  1196. catch {unset stat}
  1197.  
  1198. # type
  1199.  
  1200. file delete link.file
  1201.  
  1202. test cmdAH-25.1 {Tcl_FileObjCmd: type} {
  1203.     list [catch {file size a b} msg] $msg
  1204. } {1 {wrong # args: should be "file size name"}}
  1205. test cmdAH-25.2 {Tcl_FileObjCmd: type} {
  1206.     file type dir.file
  1207. } directory
  1208. test cmdAH-25.3 {Tcl_FileObjCmd: type} {
  1209.     file type gorp.file
  1210. } file
  1211. test cmdAH-25.4 {Tcl_FileObjCmd: type} {unixOnly nonPortable} {
  1212.     exec ln -s a/b/c link.file
  1213.     set result [file type link.file]
  1214.     file delete link.file
  1215.     set result
  1216. } link
  1217. test cmdAH-25.5 {Tcl_FileObjCmd: type} {
  1218.     string tolower [list [catch {file type _bogus_} msg] $msg $errorCode]
  1219. } {1 {couldn't stat "_bogus_": no such file or directory} {posix enoent {no such file or directory}}}
  1220.  
  1221. # Error conditions
  1222.  
  1223. test cmdAH-26.1 {error conditions} {
  1224.     list [catch {file gorp x} msg] $msg
  1225. } {1 {bad option "gorp": must be atime, attributes, 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}}
  1226. test cmdAH-26.2 {error conditions} {
  1227.     list [catch {file ex x} msg] $msg
  1228. } {1 {ambiguous option "ex": must be atime, attributes, 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}}
  1229. test cmdAH-26.3 {error conditions} {
  1230.     list [catch {file is x} msg] $msg
  1231. } {1 {ambiguous option "is": must be atime, attributes, 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}}
  1232. test cmdAH-26.4 {error conditions} {
  1233.     list [catch {file z x} msg] $msg
  1234. } {1 {bad option "z": must be atime, attributes, 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}}
  1235. test cmdAH-26.5 {error conditions} {
  1236.     list [catch {file read x} msg] $msg
  1237. } {1 {ambiguous option "read": must be atime, attributes, 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}}
  1238. test cmdAH-26.6 {error conditions} {
  1239.     list [catch {file s x} msg] $msg
  1240. } {1 {ambiguous option "s": must be atime, attributes, 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}}
  1241. test cmdAH-26.7 {error conditions} {
  1242.     list [catch {file t x} msg] $msg
  1243. } {1 {ambiguous option "t": must be atime, attributes, 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}}
  1244. test cmdAH-26.8 {error conditions} {
  1245.     list [catch {file dirname ~woohgy} msg] $msg
  1246. } {1 {user "woohgy" doesn't exist}}
  1247.  
  1248. testsetplatform $platform
  1249. catch {unset platform}
  1250.  
  1251. catch {exec chmod 777 dir.file}
  1252. file delete -force dir.file
  1253. file delete gorp.file
  1254. file delete link.file
  1255.  
  1256. concat ""
  1257.