diff options
Diffstat (limited to 'testes/files.lua')
| -rw-r--r-- | testes/files.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/testes/files.lua b/testes/files.lua index 6e7bd9e2..585e5948 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
| @@ -125,7 +125,7 @@ do | |||
| 125 | -- closing file by scope | 125 | -- closing file by scope |
| 126 | local F = nil | 126 | local F = nil |
| 127 | do | 127 | do |
| 128 | local <toclose> f = assert(io.open(file, "w")) | 128 | local f <close> = assert(io.open(file, "w")) |
| 129 | F = f | 129 | F = f |
| 130 | end | 130 | end |
| 131 | assert(tostring(F) == "file (closed)") | 131 | assert(tostring(F) == "file (closed)") |
| @@ -135,7 +135,7 @@ assert(os.remove(file)) | |||
| 135 | 135 | ||
| 136 | do | 136 | do |
| 137 | -- test writing/reading numbers | 137 | -- test writing/reading numbers |
| 138 | local <toclose> f = assert(io.open(file, "w")) | 138 | local f <close> = assert(io.open(file, "w")) |
| 139 | f:write(maxint, '\n') | 139 | f:write(maxint, '\n') |
| 140 | f:write(string.format("0X%x\n", maxint)) | 140 | f:write(string.format("0X%x\n", maxint)) |
| 141 | f:write("0xABCp-3", '\n') | 141 | f:write("0xABCp-3", '\n') |
| @@ -144,7 +144,7 @@ do | |||
| 144 | f:write(string.format("0x%X\n", -maxint)) | 144 | f:write(string.format("0x%X\n", -maxint)) |
| 145 | f:write("-0xABCp-3", '\n') | 145 | f:write("-0xABCp-3", '\n') |
| 146 | assert(f:close()) | 146 | assert(f:close()) |
| 147 | local <toclose> f = assert(io.open(file, "r")) | 147 | local f <close> = assert(io.open(file, "r")) |
| 148 | assert(f:read("n") == maxint) | 148 | assert(f:read("n") == maxint) |
| 149 | assert(f:read("n") == maxint) | 149 | assert(f:read("n") == maxint) |
| 150 | assert(f:read("n") == 0xABCp-3) | 150 | assert(f:read("n") == 0xABCp-3) |
| @@ -158,7 +158,7 @@ assert(os.remove(file)) | |||
| 158 | 158 | ||
| 159 | -- testing multiple arguments to io.read | 159 | -- testing multiple arguments to io.read |
| 160 | do | 160 | do |
| 161 | local <toclose> f = assert(io.open(file, "w")) | 161 | local f <close> = assert(io.open(file, "w")) |
| 162 | f:write[[ | 162 | f:write[[ |
| 163 | a line | 163 | a line |
| 164 | another line | 164 | another line |
| @@ -170,18 +170,18 @@ three | |||
| 170 | ]] | 170 | ]] |
| 171 | local l1, l2, l3, l4, n1, n2, c, dummy | 171 | local l1, l2, l3, l4, n1, n2, c, dummy |
| 172 | assert(f:close()) | 172 | assert(f:close()) |
| 173 | local <toclose> f = assert(io.open(file, "r")) | 173 | local f <close> = assert(io.open(file, "r")) |
| 174 | l1, l2, n1, n2, dummy = f:read("l", "L", "n", "n") | 174 | l1, l2, n1, n2, dummy = f:read("l", "L", "n", "n") |
| 175 | assert(l1 == "a line" and l2 == "another line\n" and | 175 | assert(l1 == "a line" and l2 == "another line\n" and |
| 176 | n1 == 1234 and n2 == 3.45 and dummy == nil) | 176 | n1 == 1234 and n2 == 3.45 and dummy == nil) |
| 177 | assert(f:close()) | 177 | assert(f:close()) |
| 178 | local <toclose> f = assert(io.open(file, "r")) | 178 | local f <close> = assert(io.open(file, "r")) |
| 179 | l1, l2, n1, n2, c, l3, l4, dummy = f:read(7, "l", "n", "n", 1, "l", "l") | 179 | l1, l2, n1, n2, c, l3, l4, dummy = f:read(7, "l", "n", "n", 1, "l", "l") |
| 180 | assert(l1 == "a line\n" and l2 == "another line" and c == '\n' and | 180 | assert(l1 == "a line\n" and l2 == "another line" and c == '\n' and |
| 181 | n1 == 1234 and n2 == 3.45 and l3 == "one" and l4 == "two" | 181 | n1 == 1234 and n2 == 3.45 and l3 == "one" and l4 == "two" |
| 182 | and dummy == nil) | 182 | and dummy == nil) |
| 183 | assert(f:close()) | 183 | assert(f:close()) |
| 184 | local <toclose> f = assert(io.open(file, "r")) | 184 | local f <close> = assert(io.open(file, "r")) |
| 185 | -- second item failing | 185 | -- second item failing |
| 186 | l1, n1, n2, dummy = f:read("l", "n", "n", "l") | 186 | l1, n1, n2, dummy = f:read("l", "n", "n", "l") |
| 187 | assert(l1 == "a line" and n1 == nil) | 187 | assert(l1 == "a line" and n1 == nil) |
