-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
309 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
number.lua | ||
table.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
|
||
do | ||
local a = nil | ||
local b = {} | ||
local t = {[true] = a, [false] = b or 1} | ||
assert(t[true] == nil) | ||
assert(t[false] == b) | ||
end | ||
|
||
do | ||
local b = {} | ||
local t = {[true] = nil, [false] = b or 1} | ||
assert(t[true] == nil) | ||
assert(t[false] == b) | ||
end | ||
|
||
|
||
do --- tnew | ||
local a = nil | ||
local b = {} | ||
local t = {[true] = a, [false] = b or 1} | ||
assert(t[true] == nil) | ||
assert(t[false] == b) | ||
end | ||
|
||
do --- tdup | ||
local b = {} | ||
local t = {[true] = nil, [false] = b or 1} | ||
assert(t[true] == nil) | ||
assert(t[false] == b) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ assignment.lua | |
compare.lua | ||
constant | ||
for.lua | ||
length.lua | ||
modulo.lua | ||
concat.lua | ||
self.lua | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
|
||
do | ||
local t = {} | ||
for i=1,100 do t[#t+1] = i end | ||
assert(#t == 100) | ||
for i=1,100 do t[#t] = nil end | ||
end | ||
|
||
do | ||
local t = {} | ||
t[90] = 999 | ||
for i=1,100 do t[#t+1] = i end | ||
assert(#t > 100 and t[#t] == 100) | ||
end | ||
|
||
do | ||
local t = {} | ||
for i=1,100 do t[i] = i end | ||
t[10] = nil | ||
for i=1,99 do t[#t] = nil end | ||
assert(#t == 0) | ||
end | ||
|
||
|
||
do --- length increasing and decreasing in loop | ||
local t = {} | ||
for i=1,100 do t[#t+1] = i end | ||
assert(#t == 100) | ||
for i=1,100 do t[#t] = nil end | ||
assert(#t == 0) | ||
end | ||
|
||
do --- length increasing in loop with existing element | ||
local t = {} | ||
t[90] = 999 | ||
for i=1,100 do t[#t+1] = i end | ||
assert(#t > 100 and t[#t] == 100) | ||
end | ||
|
||
do --- length decreasing in loop with erased element | ||
local t = {} | ||
for i=1,100 do t[i] = i end | ||
t[10] = nil | ||
for i=1,99 do t[#t] = nil end | ||
assert(#t == 0) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
do --- small integer values | ||
local t = { 4,5,6,7,8,9,10 } | ||
local n = 0 | ||
for i,v in ipairs(t) do | ||
assert(v == i+3) | ||
n = n + 1 | ||
end | ||
assert(n == 7) | ||
end | ||
|
||
do --- jit key=value | ||
local t = {} | ||
for i=1,100 do t[i]=i end | ||
local n = 0 | ||
for i,v in ipairs(t) do | ||
assert(i == v) | ||
n = n + 1 | ||
end | ||
assert(n == 100) | ||
end | ||
|
||
do --- untitled | ||
local t = {} | ||
local o = {{}, {}} | ||
for i=1,100 do | ||
local c = i.."" | ||
t[i] = c | ||
o[1][c] = i | ||
o[2][c] = i | ||
end | ||
o[1]["90"] = nil | ||
|
||
local n = 0 | ||
for _, c in ipairs(t) do | ||
for i = 1, 2 do | ||
o[i][c] = o[i][c] or 1 | ||
n = n + 1 | ||
end | ||
end | ||
assert(n == 200) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
do --- _G 1 | ||
local ok, err = pcall(next, _G, 1) | ||
assert(not ok) | ||
local ok, err = pcall(function() next(_G, 1) end) | ||
assert(not ok) | ||
end | ||
|
||
do --- as iterator | ||
local t = { foo = 9, bar = 10, 4, 5, 6 } | ||
local r = {} | ||
local function dummy() end | ||
local function f(next) | ||
for k,v in next,t,nil do r[#r+1] = k; if v == 5 then f(dummy) end end | ||
end | ||
f(next) | ||
assert(#r == 5) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.