[NOTHING CHANGED] Move to maven and massive clean and fixup #93
@@ -61,3 +61,177 @@ pcall(unpack) false
|
||||
pcall(unpack,nil) false
|
||||
pcall(unpack,"abc") false
|
||||
pcall(unpack,1) false
|
||||
unpack({"aa"}) aa
|
||||
unpack({"aa","bb"}) aa bb
|
||||
unpack({"aa","bb","cc"}) aa bb cc
|
||||
unpack -
|
||||
unpack a a
|
||||
unpack . nil
|
||||
unpack ab a b
|
||||
unpack .b nil b
|
||||
unpack a. a nil
|
||||
unpack abc a b c
|
||||
unpack .ab nil a b
|
||||
unpack a.b a nil b
|
||||
unpack ab. a b nil
|
||||
unpack ..b nil nil b
|
||||
unpack a.. a nil nil
|
||||
unpack .b. nil b nil
|
||||
unpack ... nil nil nil
|
||||
unpack (-)
|
||||
unpack (a) a
|
||||
unpack (.) nil
|
||||
unpack (ab) a b
|
||||
unpack (.b) nil b
|
||||
unpack (a.) a nil
|
||||
unpack (abc) a b c
|
||||
unpack (.ab) nil a b
|
||||
unpack (a.b) a nil b
|
||||
unpack (ab.) a b nil
|
||||
unpack (..b) nil nil b
|
||||
unpack (a..) a nil nil
|
||||
unpack (.b.) nil b nil
|
||||
unpack (...) nil nil nil
|
||||
pcall(unpack,t) true aa bb cc dd ee ff
|
||||
pcall(unpack,t,2) true bb cc dd ee ff
|
||||
pcall(unpack,t,2,5) true bb cc dd ee
|
||||
pcall(unpack,t,2,6) true bb cc dd ee ff
|
||||
pcall(unpack,t,2,7) true bb cc dd ee ff nil
|
||||
pcall(unpack,t,1) true aa bb cc dd ee ff
|
||||
pcall(unpack,t,1,5) true aa bb cc dd ee
|
||||
pcall(unpack,t,1,6) true aa bb cc dd ee ff
|
||||
pcall(unpack,t,1,7) true aa bb cc dd ee ff nil
|
||||
pcall(unpack,t,0) true nil aa bb cc dd ee ff
|
||||
pcall(unpack,t,0,5) true nil aa bb cc dd ee
|
||||
pcall(unpack,t,0,6) true nil aa bb cc dd ee ff
|
||||
pcall(unpack,t,0,7) true nil aa bb cc dd ee ff nil
|
||||
pcall(unpack,t,-1) true nil nil aa bb cc dd ee ff
|
||||
pcall(unpack,t,-1,5) true nil nil aa bb cc dd ee
|
||||
pcall(unpack,t,-1,6) true nil nil aa bb cc dd ee ff
|
||||
pcall(unpack,t,-1,7) true nil nil aa bb cc dd ee ff nil
|
||||
pcall(unpack,t,2,4) true bb cc dd
|
||||
pcall(unpack,t,2,5) true bb cc dd ee
|
||||
pcall(unpack,t,2,6) true bb cc dd ee ff
|
||||
pcall(unpack,t,2,7) true bb cc dd ee ff nil
|
||||
pcall(unpack,t,2,8) true bb cc dd ee ff nil nil
|
||||
pcall(unpack,t,2,2) true
|
||||
pcall(unpack,t,2,1) true
|
||||
pcall(unpack,t,2,0) true
|
||||
pcall(unpack,t,2,-1) true
|
||||
pcall(unpack,t,0) true zz aa bb cc dd ee ff
|
||||
pcall(unpack,t,2,0) true
|
||||
pcall(unpack,t,2,-1) true
|
||||
pcall(unpack,t,"3") true cc dd ee ff
|
||||
pcall(unpack,t,"a") false
|
||||
pcall(unpack,t,function() end) false
|
||||
----- misc table initializer tests -------
|
||||
3
|
||||
4
|
||||
4
|
||||
----- basic table operations -------
|
||||
------ basic table tests on basic table table
|
||||
t[1]=2 true
|
||||
t[1] true 2
|
||||
t[1]=nil true
|
||||
t[1] true nil
|
||||
t["a"]="b" true
|
||||
t["a"],t.a true b b
|
||||
t.a="c" true
|
||||
t["a"],t.a true c c
|
||||
t.a=nil true
|
||||
t["a"],t.a true nil nil
|
||||
t[nil]="d" false string
|
||||
t[nil] true nil
|
||||
t[nil]=nil false string
|
||||
t[nil] true nil
|
||||
------ basic table tests on function metatable on __index table
|
||||
t[1]=2 true
|
||||
t[1] true 2
|
||||
t[1]=nil true
|
||||
metatable call args table 1
|
||||
t[1] true dummy
|
||||
t["a"]="b" true
|
||||
t["a"],t.a true b b
|
||||
t.a="c" true
|
||||
t["a"],t.a true c c
|
||||
t.a=nil true
|
||||
metatable call args table a
|
||||
metatable call args table a
|
||||
t["a"],t.a true dummy dummy
|
||||
t[nil]="d" false string
|
||||
metatable call args table nil
|
||||
t[nil] true dummy
|
||||
t[nil]=nil false string
|
||||
metatable call args table nil
|
||||
t[nil] true dummy
|
||||
------ basic table tests on function metatable on __newindex table
|
||||
metatable call args table 1 2
|
||||
t[1]=2 true
|
||||
t[1] true nil
|
||||
metatable call args table 1 nil
|
||||
t[1]=nil true
|
||||
t[1] true nil
|
||||
metatable call args table a b
|
||||
t["a"]="b" true
|
||||
t["a"],t.a true nil nil
|
||||
metatable call args table a c
|
||||
t.a="c" true
|
||||
t["a"],t.a true nil nil
|
||||
metatable call args table a nil
|
||||
t.a=nil true
|
||||
t["a"],t.a true nil nil
|
||||
metatable call args table nil d
|
||||
t[nil]="d" true nil
|
||||
t[nil] true nil
|
||||
metatable call args table nil nil
|
||||
t[nil]=nil true nil
|
||||
t[nil] true nil
|
||||
------ basic table tests on plain metatable on __index table
|
||||
t[1]=2 true
|
||||
t[1] true 2
|
||||
t[1]=nil true
|
||||
t[1] true nil
|
||||
t["a"]="b" true
|
||||
t["a"],t.a true b b
|
||||
t.a="c" true
|
||||
t["a"],t.a true c c
|
||||
t.a=nil true
|
||||
t["a"],t.a true nil nil
|
||||
t[nil]="d" false string
|
||||
t[nil] true nil
|
||||
t[nil]=nil false string
|
||||
t[nil] true nil
|
||||
------ basic table tests on plain metatable on __newindex table
|
||||
t[1]=2 true
|
||||
t[1] true 2
|
||||
t[1]=nil true
|
||||
t[1] true nil
|
||||
t["a"]="b" true
|
||||
t["a"],t.a true b b
|
||||
t.a="c" true
|
||||
t["a"],t.a true c c
|
||||
t.a=nil true
|
||||
t["a"],t.a true nil nil
|
||||
t[nil]="d" false string
|
||||
t[nil] true nil
|
||||
t[nil]=nil false string
|
||||
t[nil] true nil
|
||||
-- sort tests
|
||||
default (lexical) comparator
|
||||
2-4-6-8-1-3-5-7
|
||||
1-2-3-4-5-6-7-8
|
||||
333-222-111
|
||||
111-222-333
|
||||
www-xxx-yyy-aaa-bbb-ccc
|
||||
aaa-bbb-ccc-www-xxx-yyy
|
||||
21-23-25-27-22-24-26-28
|
||||
sort failed
|
||||
custom (numerical) comparator
|
||||
2-4-6-8-1-3-5-7
|
||||
1-2-3-4-5-6-7-8
|
||||
333-222-111
|
||||
111-222-333
|
||||
www-xxx-yyy-aaa-bbb-ccc
|
||||
sort failed
|
||||
21-23-25-27-22-24-26-28
|
||||
21-22-23-24-25-26-27-28
|
||||
|
||||
@@ -2,3 +2,210 @@ true true
|
||||
b
|
||||
true true
|
||||
true true c
|
||||
--f, n, table.unpack(t) func.1 0
|
||||
true 0 0 0
|
||||
--f, n, table.unpack(t) func.1 0 1
|
||||
true 1 1 1
|
||||
--f, n, table.unpack(t) func.1 0 1 2
|
||||
true 1 3 3
|
||||
--f, n, table.unpack(t) func.1 0 1 2 3
|
||||
true 1 3 6
|
||||
--f, n, table.unpack(t) func.1 0 1 2 3 4
|
||||
true 1 3 6
|
||||
--f, n, table.unpack(t) func.1 1
|
||||
true 0 0 0
|
||||
--f, n, table.unpack(t) func.1 1 1
|
||||
true 1 2 3
|
||||
--f, n, table.unpack(t) func.1 1 1 2
|
||||
true 1 4 7
|
||||
--f, n, table.unpack(t) func.1 1 1 2 3
|
||||
true 1 4 10
|
||||
--f, n, table.unpack(t) func.1 1 1 2 3 4
|
||||
true 1 4 10
|
||||
--f, n, table.unpack(t) func.1 2
|
||||
true 0 0 0
|
||||
--f, n, table.unpack(t) func.1 2 1
|
||||
true 1 3 6
|
||||
--f, n, table.unpack(t) func.1 2 1 2
|
||||
true 1 5 12
|
||||
--f, n, table.unpack(t) func.1 2 1 2 3
|
||||
true 1 5 15
|
||||
--f, n, table.unpack(t) func.1 2 1 2 3 4
|
||||
true 1 5 15
|
||||
--f, n, table.unpack(t) func.1 3
|
||||
true 0 0 0
|
||||
--f, n, table.unpack(t) func.1 3 1
|
||||
true 1 4 10
|
||||
--f, n, table.unpack(t) func.1 3 1 2
|
||||
true 1 6 18
|
||||
--f, n, table.unpack(t) func.1 3 1 2 3
|
||||
true 1 6 21
|
||||
--f, n, table.unpack(t) func.1 3 1 2 3 4
|
||||
true 1 6 21
|
||||
--f, n, table.unpack(t) func.2 0
|
||||
--f2, n<=0, returning sum(...)
|
||||
true 0
|
||||
--f, n, table.unpack(t) func.2 0 1
|
||||
--f2, n<=0, returning sum(...) 1
|
||||
true 1
|
||||
--f, n, table.unpack(t) func.2 0 1 2
|
||||
--f2, n<=0, returning sum(...) 1 2
|
||||
true 3
|
||||
--f, n, table.unpack(t) func.2 0 1 2 3
|
||||
--f2, n<=0, returning sum(...) 1 2 3
|
||||
true 6
|
||||
--f, n, table.unpack(t) func.2 0 1 2 3 4
|
||||
--f2, n<=0, returning sum(...) 1 2 3 4
|
||||
true 10
|
||||
--f, n, table.unpack(t) func.2 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1
|
||||
--f2, n<=0, returning sum(...) 1
|
||||
true 1
|
||||
--f, n, table.unpack(t) func.2 1 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 1
|
||||
--f2, n<=0, returning sum(...) 1 1
|
||||
true 2
|
||||
--f, n, table.unpack(t) func.2 1 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 1 2
|
||||
--f2, n<=0, returning sum(...) 1 1 2
|
||||
true 4
|
||||
--f, n, table.unpack(t) func.2 1 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 1 2 3
|
||||
--f2, n<=0, returning sum(...) 1 1 2 3
|
||||
true 7
|
||||
--f, n, table.unpack(t) func.2 1 1 2 3 4
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 1 2 3 4
|
||||
--f2, n<=0, returning sum(...) 1 1 2 3 4
|
||||
true 11
|
||||
--f, n, table.unpack(t) func.2 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2
|
||||
--f2, n<=0, returning sum(...) 1 2
|
||||
true 3
|
||||
--f, n, table.unpack(t) func.2 2 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 1
|
||||
--f2, n<=0, returning sum(...) 1 2 1
|
||||
true 4
|
||||
--f, n, table.unpack(t) func.2 2 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 1 2
|
||||
--f2, n<=0, returning sum(...) 1 2 1 2
|
||||
true 6
|
||||
--f, n, table.unpack(t) func.2 2 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 1 2 3
|
||||
--f2, n<=0, returning sum(...) 1 2 1 2 3
|
||||
true 9
|
||||
--f, n, table.unpack(t) func.2 2 1 2 3 4
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 1 2 3 4
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 1 2 3 4
|
||||
--f2, n<=0, returning sum(...) 1 2 1 2 3 4
|
||||
true 13
|
||||
--f, n, table.unpack(t) func.2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 3
|
||||
--f2, n<=0, returning sum(...) 1 2 3
|
||||
true 6
|
||||
--f, n, table.unpack(t) func.2 3 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 2 3 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 3 1
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1
|
||||
--f2, n<=0, returning sum(...) 1 2 3 1
|
||||
true 7
|
||||
--f, n, table.unpack(t) func.2 3 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 2 3 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 3 1 2
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 2
|
||||
--f2, n<=0, returning sum(...) 1 2 3 1 2
|
||||
true 9
|
||||
--f, n, table.unpack(t) func.2 3 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 2 3 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 3 1 2 3
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 2 3
|
||||
--f2, n<=0, returning sum(...) 1 2 3 1 2 3
|
||||
true 12
|
||||
--f, n, table.unpack(t) func.2 3 1 2 3 4
|
||||
--f2, n>0, returning f2(n-1,n,...) 2 3 1 2 3 4
|
||||
--f2, n>0, returning f2(n-1,n,...) 1 2 3 1 2 3 4
|
||||
--f2, n>0, returning f2(n-1,n,...) 0 1 2 3 1 2 3 4
|
||||
--f2, n<=0, returning sum(...) 1 2 3 1 2 3 4
|
||||
true 16
|
||||
--f, n, table.unpack(t) func.3 0
|
||||
true 0
|
||||
--f, n, table.unpack(t) func.3 0 1
|
||||
true 1
|
||||
--f, n, table.unpack(t) func.3 0 1 2
|
||||
true 3
|
||||
--f, n, table.unpack(t) func.3 0 1 2 3
|
||||
true 6
|
||||
--f, n, table.unpack(t) func.3 0 1 2 3 4
|
||||
true 10
|
||||
--f, n, table.unpack(t) func.3 1
|
||||
f3,n-1,n,... func.3 0 1
|
||||
true true 1
|
||||
--f, n, table.unpack(t) func.3 1 1
|
||||
f3,n-1,n,... func.3 0 1 1
|
||||
true true 2
|
||||
--f, n, table.unpack(t) func.3 1 1 2
|
||||
f3,n-1,n,... func.3 0 1 1 2
|
||||
true true 4
|
||||
--f, n, table.unpack(t) func.3 1 1 2 3
|
||||
f3,n-1,n,... func.3 0 1 1 2 3
|
||||
true true 7
|
||||
--f, n, table.unpack(t) func.3 1 1 2 3 4
|
||||
f3,n-1,n,... func.3 0 1 1 2 3 4
|
||||
true true 11
|
||||
--f, n, table.unpack(t) func.3 2
|
||||
f3,n-1,n,... func.3 1 2
|
||||
f3,n-1,n,... func.3 0 1 2
|
||||
true true true 3
|
||||
--f, n, table.unpack(t) func.3 2 1
|
||||
f3,n-1,n,... func.3 1 2 1
|
||||
f3,n-1,n,... func.3 0 1 2 1
|
||||
true true true 4
|
||||
--f, n, table.unpack(t) func.3 2 1 2
|
||||
f3,n-1,n,... func.3 1 2 1 2
|
||||
f3,n-1,n,... func.3 0 1 2 1 2
|
||||
true true true 6
|
||||
--f, n, table.unpack(t) func.3 2 1 2 3
|
||||
f3,n-1,n,... func.3 1 2 1 2 3
|
||||
f3,n-1,n,... func.3 0 1 2 1 2 3
|
||||
true true true 9
|
||||
--f, n, table.unpack(t) func.3 2 1 2 3 4
|
||||
f3,n-1,n,... func.3 1 2 1 2 3 4
|
||||
f3,n-1,n,... func.3 0 1 2 1 2 3 4
|
||||
true true true 13
|
||||
--f, n, table.unpack(t) func.3 3
|
||||
f3,n-1,n,... func.3 2 3
|
||||
f3,n-1,n,... func.3 1 2 3
|
||||
f3,n-1,n,... func.3 0 1 2 3
|
||||
true true true true 6
|
||||
--f, n, table.unpack(t) func.3 3 1
|
||||
f3,n-1,n,... func.3 2 3 1
|
||||
f3,n-1,n,... func.3 1 2 3 1
|
||||
f3,n-1,n,... func.3 0 1 2 3 1
|
||||
true true true true 7
|
||||
--f, n, table.unpack(t) func.3 3 1 2
|
||||
f3,n-1,n,... func.3 2 3 1 2
|
||||
f3,n-1,n,... func.3 1 2 3 1 2
|
||||
f3,n-1,n,... func.3 0 1 2 3 1 2
|
||||
true true true true 9
|
||||
--f, n, table.unpack(t) func.3 3 1 2 3
|
||||
f3,n-1,n,... func.3 2 3 1 2 3
|
||||
f3,n-1,n,... func.3 1 2 3 1 2 3
|
||||
f3,n-1,n,... func.3 0 1 2 3 1 2 3
|
||||
true true true true 12
|
||||
--f, n, table.unpack(t) func.3 3 1 2 3 4
|
||||
f3,n-1,n,... func.3 2 3 1 2 3 4
|
||||
f3,n-1,n,... func.3 1 2 3 1 2 3 4
|
||||
f3,n-1,n,... func.3 0 1 2 3 1 2 3 4
|
||||
true true true true 16
|
||||
120
|
||||
120
|
||||
1234
|
||||
true 832040
|
||||
true 832040
|
||||
true inf
|
||||
1 1 2 3 5 8 13 21 34
|
||||
|
||||
@@ -132,7 +132,7 @@ testbothpairs(t)
|
||||
-- tests of setlist table constructors
|
||||
-- length is tested elsewhere
|
||||
print('----- unpack tests -------')
|
||||
local unpack = table.unpack
|
||||
local unpack = table.unpack or unpack
|
||||
print( 'pcall(unpack)', (pcall(unpack)) );
|
||||
print( 'pcall(unpack,nil)', (pcall(unpack,nil)) );
|
||||
print( 'pcall(unpack,"abc")', (pcall(unpack,"abc")) );
|
||||
|
||||
@@ -60,11 +60,12 @@ local function f3(n,...)
|
||||
end
|
||||
|
||||
local function all(f)
|
||||
local unpack = table.unpack or unpack
|
||||
for n=0,3 do
|
||||
t = {}
|
||||
for m=1,5 do
|
||||
print( "--f, n, table.unpack(t)", f, n, table.unpack(t) )
|
||||
print( pcall( f, n, table.unpack(t)) )
|
||||
print( "--f, n, table.unpack(t)", f, n, unpack(t) )
|
||||
print( pcall( f, n, unpack(t)) )
|
||||
t[m] = m
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user