Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keplerproject/luafilesystem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authortomas <tomas>2004-11-01 18:27:13 +0300
committertomas <tomas>2004-11-01 18:27:13 +0300
commit4d5d1e75fa5950b39873b46b3ab21fd39028e4f1 (patch)
treee2597be505a2ddaa87479c4549f8a51bf93a6ff1 /tests
parent3219f4618df9fa4f4a54d2d3bcc116380bafa217 (diff)
Pequenas correcoes nos valores de retorno de algumas funcoes.
Acrescimo do arquivo de testes.
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test.lua b/tests/test.lua
new file mode 100644
index 0000000..5703bfb
--- /dev/null
+++ b/tests/test.lua
@@ -0,0 +1,40 @@
+#!/usr/local/bin/lua
+
+local tmp = "/tmp"
+local sep = "/"
+local upper = ".."
+
+require"lfs"
+
+function attrdir (path)
+ for file in lfs.dir(path) do
+ if file ~= "." and file ~= ".." then
+ local f = path..'/'..file
+ print ("\t=> "..f.." <=")
+ local attr = lfs.attributes (f)
+ assert (type(attr) == "table")
+ if attr.mode == "directory" then
+ attrdir (f)
+ else
+ for name, value in pairs(attr) do
+ print (name, value)
+ end
+ end
+ end
+ end
+end
+
+-- Checking changing directories
+local current = assert (lfs.currentdir())
+local reldir = string.gsub (current, "^.*%"..sep.."([^"..sep.."])$", "%1")
+assert (lfs.chdir (upper), "could not change to upper directory")
+assert (lfs.chdir (reldir), "could not change back to current directory")
+assert (lfs.currentdir() == current, "error trying to change directories")
+assert (lfs.chdir ("this couldn't be an actual directory") == false, "could change to a non-existent directory")
+-- Changing creating and removing directories
+assert (lfs.mkdir (tmp.."/lfs_tmp_dir"), "could not make a new directory")
+assert (os.remove (tmp.."/lfs_tmp_dir"), "could not remove new directory")
+assert (lfs.mkdir (tmp.."/lfs_tmp_dir/lfs_tmp_dir") == false, "could create a directory inside a non-existent one")
+--
+assert (lfs.attributes ("this couldn't be an actual file") == false, "could get attributes of a non-existent file")
+assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory")