Skip to content

Commit

Permalink
Add tests for varargs table packing
Browse files Browse the repository at this point in the history
  • Loading branch information
franko committed Dec 13, 2014
1 parent 374a40c commit b2d2af5
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/vararg-pack-1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local function foo(...)
local arg = {...}
for k = 1, #arg do
print(arg[k])
end
end

foo("hello", "boy")

10 changes: 10 additions & 0 deletions tests/vararg-pack-2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local function foo(msg, ...)
local arg = {...}
print(msg)
for k = 1, #arg do
print(arg[k])
end
end

foo("Hey!", "hello", "boy")

10 changes: 10 additions & 0 deletions tests/vararg-pack-3.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
local function foo(msg, ...)
local arg = {"wait", "a", "moment", ...}
print(msg)
for k = 1, #arg do
print(arg[k])
end
end

foo("Hey", "hello", "boy")

13 changes: 13 additions & 0 deletions tests/vararg-pack-4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
local function foo(x)
return x, 2*x, x^2-1
end

local function boo(x)
local arg = { foo(x) }
for k = 1, #arg do
print(arg[k])
end
end

boo(7)

9 changes: 9 additions & 0 deletions tests/vararg-pack-5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local function foo(...)
local arg = {..., "friend"}
for k = 1, #arg do
print(arg[k])
end
end

foo("hello", "boy")

0 comments on commit b2d2af5

Please sign in to comment.