1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#
# pushd.test
#
# Tests for tcl.tlib directory directory stack routines.
#
#---------------------------------------------------------------------------
# Copyright 1992-1999 Karl Lehenbauer and Mark Diekhans.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appear in all copies. Karl Lehenbauer and
# Mark Diekhans make no representations about the suitability of this
# software for any purpose. It is provided "as is" without express or
# implied warranty.
#------------------------------------------------------------------------------
# $Id: pushd.test,v 1.2 2002/04/02 02:29:43 hobbs Exp $
#------------------------------------------------------------------------------
#
if {[cequal [info procs Test] {}]} {
source [file join [file dirname [info script]] testlib.tcl]
}
#
# Get the directories we are going to be using. Also the device for
# windows. Always get absolute paths via cd-ing and pwd, in case the directory
# is symbolicly linked.
#
switch $tcl_platform(platform) {
unix {
set tmp /tmp
}
windows {
if [cequal $tcl_platform(os) {Windows NT}] {
set tmp {C:/Program Files}
} else {
set tmp C:/dos
}
}
}
if ![file isdirectory $tmp] {
puts "*************************************************************"
puts "Directory $tmp does not exist, pushd & popd tests"
puts "will be skipped"
puts "*************************************************************"
return
}
set CWD [pwd]
set CWDROOT [lindex [file split $CWD] 0]
cd $tmp
set TMP [pwd]
set TMPROOT [lindex [file split $TMP] 0]
Test pushd-1.1 {pushd command} {
pushd
} 1 {directory stack empty}
Test pushd-1.2 {pushd command} {
pushd $TMP
set TCLXENV(dirPushList)
} 0 [list $TMP]
Test pushd-1.3 {pushd command} {
pushd $CWDROOT
} 0 $CWDROOT
Test pushd-1.4 {pushd command} {
pushd $TMP
set TCLXENV(dirPushList)
} 0 [list $CWDROOT $TMP $TMP]
Test pushd-1.5 {pushd command} {
dirs
} 0 [list $TMP $CWDROOT $TMP $TMP]
cd $CWD
Test popd-1.1 {popd command} {
popd
} 0 $CWDROOT
Test popd-1.2 {popd command} {
dirs
} 0 [list $CWDROOT $TMP $TMP]
Test popd-1.3 {popd command} {
list [popd] [popd] [dirs]
} 0 [list $TMP $TMP [list $TMP]]
Test popd-1.4 {popd command} {
popd
} 1 {directory stack empty}
Test popd-1.4 {popd command} {
set TCLXENV(dirPushList)
} 0 {}
cd $CWD
# cleanup
::tcltest::cleanupTests
return
|