source [file dirname [info script]]/testing.tcl needs cmd file test join-1.1 "One name" { file join abc } {abc} test join-1.2 "One name with trailing slash" { file join abc/ } {abc} test join-1.3 "One name with leading slash" { file join /abc } {/abc} test join-1.4 "One name with leading and trailing slash" { file join /abc/ } {/abc} test join-1.5 "Two names" { file join abc def } {abc/def} test join-1.6 "Two names with dir trailing slash" { file join abc/ def } {abc/def} test join-1.7 "Two names with dir leading slash" { file join /abc def } {/abc/def} test join-1.8 "Two names with dir leading and trailing slash" { file join /abc/ def } {/abc/def} test join-1.9 "Two names with file trailing slash" { file join abc def/ } {abc/def} test join-1.10 "Two names with file leading slash" { file join abc /def } {/def} test join-1.11 "Two names with file leading and trailing slash" { file join abc /def/ } {/def} test join-1.12 "Two names with double slashes" { file join abc/ /def } {/def} test join-1.13 "Join to root" { file join / abc } {/abc} test join-1.14 "Join to root" { set dir [file join / .] # Either / or /. is OK here expr {$dir in {/ /.}} } 1 test join-1.15 "Join to root" { file join / / } {/} test join-1.16 "Join to root" { file join /abc / } {/} test join-1.17 "With trailing slash" { file join /abc/def/ ghi/jkl } {/abc/def/ghi/jkl} test join-2.1 "Dir is empty string" { file join "" def } {def} test join-2.2 "File is empty string" { file join abc "" } {abc} test join-2.3 "Path too long" jim { set components [string repeat {abcdefghi } 500] list [catch [concat file join $components] msg] $msg } {1 {Path too long}} test tail-1.1 "One component" { file tail abc } {abc} test tail-1.2 "Two components" { file tail abc/def } {def} test tail-1.3 "Absolute one component" { file tail /abc } {abc} test tail-1.4 "Trailing slash" { file tail abc/ } {abc} test dirname-1.1 "One component" { file dirname abc } {.} test dirname-1.2 "Two components" { file dirname abc/def } {abc} test dirname-1.3 "Absolute one component" { file dirname /abc } {/} test dirname-1.4 "Trailing slash" { file dirname abc/ } {.} # These tests are courtesy of picol test file.12.1 "picol test" {file dirname /foo/bar/grill.txt} /foo/bar test file.12.2 "picol test" {file dirname /foo/bar/baz/} /foo/bar test file.12.3 "picol test" {file dirname /foo/bar/baz///} /foo/bar test file.12.4 "picol test" {file dirname /foo/bar/baz///qux} /foo/bar/baz test file.12.5 "picol test" {file dirname foo/bar/grill.txt} foo/bar test file.12.6 "picol test" {file dirname foo/bar/baz/} foo/bar test file.12.7 "picol test" {file dirname {}} . test file.12.8 "picol test" {file dirname /} / test file.12.9 "picol test" {file dirname ///} / test file.13.1 "picol test" {file tail /foo/bar/grill.txt} grill.txt test file.13.2 "picol test" {file tail /foo/bar/baz/} baz test file.13.3 "picol test" {file tail /foo/bar/baz///} baz test file.13.4 "picol test" {file dirname /foo/bar/baz///qux} /foo/bar/baz test file.13.5 "picol test" {file tail foo/bar/grill.txt} grill.txt test file.13.6 "picol test" {file tail foo/bar/baz/} baz test file.13.7 "picol test" {file tail {}} {} test file.13.8 "picol test" {file tail /} {} test file.13.9 "picol test" {file tail ///} {} test file.14 "picol test" {file join foo} foo test file.15 "picol test" {file join foo bar} foo/bar test file.16 "picol test" {file join foo /bar} /bar if {$tcl_platform(platform) eq {windows}} { test file.17 "picol test" {file join foo C:/bar grill} C:/bar/grill } test file.18 "picol test" {file split {/foo/space station/bar}} {/ foo {space station} bar} test file.19 "picol test" {file split {/foo/space station/bar/}} {/ foo {space station} bar} test file.20 "picol test" {file split {foo/space station/bar}} {foo {space station} bar} test file.21 "picol test" {file split foo///bar} {foo bar} test file.22 "picol test" {file split foo} foo testreport