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
|
# testsuite_dir_include section for BASIC256
# Modification History
# date programmer description
# 20140529 j.m.reneau original coding
# 20200709 j.m.reneau added mkdir and rmdir testing
currentsuite = "dir"
# test file system functions
# change directories and see if all is well
c$ = currentdir
if right(c$,10) = "/TestSuite" then
changedir("..")
n$ = currentdir
changedir(c$)
call s("ChangeDir/CurrentDir", n$+"/TestSuite",c$)
else
call s("ChangeDir/CurrentDir", "not being execited from the TestSuite folder","")
endif
# see if a dummy file exists
try
kill("dirtemp.txt")
catch
end try
call n("DIR dummyfile not exists", exists("dirtemp.txt"), false)
# create it and see if it exists
open "dirtemp.txt"
close
call n("DIR dummyfile exists", exists("dirtemp.txt"), true)
# use the dir stmt to see if it exists
f$ = dir(".")
a = false
do
if f$ = "dirtemp.txt" then a = true
f$ = dir()
until f$ = ""
call n("DIR dummyfile exists (dir)", a, true)
# kill it and make sure it is gone
kill("dirtemp.txt")
call n("DIR dummyfile second not exists", exists("dirtemp.txt"), false)
# RMDIR and MKDIR test
# create a new folder
mkdir "dir_test_folder"
call n("DIR Folder dir_test_folder exists", exists("dir_test_folder"), true)
# create file in new folder
changedir("dir_test_folder")
open "dirtemp.txt"
close
call n("DIR File dir_test_folder/dirtemp.txt exists", exists("dirtemp.txt"), true)
# go up and try to delete
changedir ".."
try
rmdir "dir_test_folder"
print "dir_test_folder removed"
catch
print 'unable to remove'
end try
call n("DIR Folder dir_test_folder exists after failed remove", exists("dir_test_folder"), true)
# kill file in folder and remove
kill "dir_test_folder/dirtemp.txt"
rmdir "dir_test_folder"
call n("DIR Folder dir_test_folder remove", exists("dir_test_folder"), false)
|