Luajit doesnt implement table.unpack in the current stable version

This commit is contained in:
Enrico Horn
2021-07-21 20:38:06 +02:00
parent ddba10c180
commit 3e9ae5c524
4 changed files with 385 additions and 3 deletions

View File

@@ -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