diff options
author | tomas <tomas> | 2004-11-01 15:27:13 +0000 |
---|---|---|
committer | tomas <tomas> | 2004-11-01 15:27:13 +0000 |
commit | 4d5d1e75fa5950b39873b46b3ab21fd39028e4f1 (patch) | |
tree | e2597be505a2ddaa87479c4549f8a51bf93a6ff1 /tests | |
parent | 3219f4618df9fa4f4a54d2d3bcc116380bafa217 (diff) | |
download | luafilesystem-4d5d1e75fa5950b39873b46b3ab21fd39028e4f1.tar.gz luafilesystem-4d5d1e75fa5950b39873b46b3ab21fd39028e4f1.tar.bz2 luafilesystem-4d5d1e75fa5950b39873b46b3ab21fd39028e4f1.zip |
Pequenas correcoes nos valores de retorno de algumas funcoes.
Acrescimo do arquivo de testes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.lua | 40 |
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 @@ | |||
1 | #!/usr/local/bin/lua | ||
2 | |||
3 | local tmp = "/tmp" | ||
4 | local sep = "/" | ||
5 | local upper = ".." | ||
6 | |||
7 | require"lfs" | ||
8 | |||
9 | function attrdir (path) | ||
10 | for file in lfs.dir(path) do | ||
11 | if file ~= "." and file ~= ".." then | ||
12 | local f = path..'/'..file | ||
13 | print ("\t=> "..f.." <=") | ||
14 | local attr = lfs.attributes (f) | ||
15 | assert (type(attr) == "table") | ||
16 | if attr.mode == "directory" then | ||
17 | attrdir (f) | ||
18 | else | ||
19 | for name, value in pairs(attr) do | ||
20 | print (name, value) | ||
21 | end | ||
22 | end | ||
23 | end | ||
24 | end | ||
25 | end | ||
26 | |||
27 | -- Checking changing directories | ||
28 | local current = assert (lfs.currentdir()) | ||
29 | local reldir = string.gsub (current, "^.*%"..sep.."([^"..sep.."])$", "%1") | ||
30 | assert (lfs.chdir (upper), "could not change to upper directory") | ||
31 | assert (lfs.chdir (reldir), "could not change back to current directory") | ||
32 | assert (lfs.currentdir() == current, "error trying to change directories") | ||
33 | assert (lfs.chdir ("this couldn't be an actual directory") == false, "could change to a non-existent directory") | ||
34 | -- Changing creating and removing directories | ||
35 | assert (lfs.mkdir (tmp.."/lfs_tmp_dir"), "could not make a new directory") | ||
36 | assert (os.remove (tmp.."/lfs_tmp_dir"), "could not remove new directory") | ||
37 | assert (lfs.mkdir (tmp.."/lfs_tmp_dir/lfs_tmp_dir") == false, "could create a directory inside a non-existent one") | ||
38 | -- | ||
39 | assert (lfs.attributes ("this couldn't be an actual file") == false, "could get attributes of a non-existent file") | ||
40 | assert (type(lfs.attributes (upper)) == "table", "couldn't get attributes of upper directory") | ||