From 1806cdc571215fa82d6ffde3aa75204861aa6cb5 Mon Sep 17 00:00:00 2001 From: Philipp Janda Date: Sun, 18 Jan 2015 18:36:21 +0100 Subject: add table.sort, add code from lua-compat-5.2 --- tests/test.lua | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests') diff --git a/tests/test.lua b/tests/test.lua index 7e1c9da..b59fd94 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -133,6 +133,46 @@ do print("table.remove", next(t)) end +___'' +do + local p, t = tproxy{ 3, 1, 5, 2, 8, 5, 2, 9, 7, 4 } + table.sort(p) + print("table.sort", next(p)) + for i,v in ipairs(t) do + print("table.sort", i, v) + end + table.sort(p) + print("table.sort", next(p)) + for i,v in ipairs(t) do + print("table.sort", i, v) + end + p, t = tproxy{ 9, 8, 7, 6, 5, 4, 3, 2, 1 } + table.sort(p) + print("table.sort", next(p)) + for i,v in ipairs(t) do + print("table.sort", i, v) + end + table.sort(p, function(a, b) return a > b end) + print("table.sort", next(p)) + for i,v in ipairs(t) do + print("table.sort", i, v) + end + p, t = tproxy{ 1, 1, 1, 1, 1 } + print("table.sort", next(p)) + for i,v in ipairs(t) do + print("table.sort", i, v) + end + t = { 3, 1, 5, 2, 8, 5, 2, 9, 7, 4 } + table.sort(t) + for i,v in ipairs(t) do + print("table.sort", i, v) + end + table.sort(t, function(a, b) return a > b end) + for i,v in ipairs(t) do + print("table.sort", i, v) + end +end + ___'' do -- cgit v1.2.3-55-g6feb