diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-17 11:11:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-17 11:11:44 -0300 |
| commit | d9f40e3f6fb61650240c47d548bee69b24b07859 (patch) | |
| tree | ab01022b3e3bc6bdb800423c97095a9423e0a798 /testes/files.lua | |
| parent | 347d6961ac14213264c7176e3d125c9ba8475b01 (diff) | |
| download | lua-d9f40e3f6fb61650240c47d548bee69b24b07859.tar.gz lua-d9f40e3f6fb61650240c47d548bee69b24b07859.tar.bz2 lua-d9f40e3f6fb61650240c47d548bee69b24b07859.zip | |
First implementation for 'const' variables
A variable can be declared const, which means it cannot be assigned to,
with the syntax 'local <const> name = exp'.
Diffstat (limited to 'testes/files.lua')
| -rw-r--r-- | testes/files.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/testes/files.lua b/testes/files.lua index eb100fe1..54931c14 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
| @@ -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 | f = assert(io.open(file, "r")) | 147 | local <toclose> f = 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) |
| @@ -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 | f = assert(io.open(file, "r")) | 173 | local <toclose> f = 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 | f = assert(io.open(file, "r")) | 178 | local <toclose> f = 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 | f = assert(io.open(file, "r")) | 184 | local <toclose> f = 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) |
