aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilipp Janda <siffiejoe@gmx.net>2015-01-18 18:36:21 +0100
committerPhilipp Janda <siffiejoe@gmx.net>2015-01-18 18:36:21 +0100
commit1806cdc571215fa82d6ffde3aa75204861aa6cb5 (patch)
tree0299bce22e04ad8a44142a6e2e455e85166b924d /tests
parent4c062846ae003dd747dfcd3eca91493c7eee4f50 (diff)
downloadlua-compat-5.3-1806cdc571215fa82d6ffde3aa75204861aa6cb5.tar.gz
lua-compat-5.3-1806cdc571215fa82d6ffde3aa75204861aa6cb5.tar.bz2
lua-compat-5.3-1806cdc571215fa82d6ffde3aa75204861aa6cb5.zip
add table.sort, add code from lua-compat-5.2
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test.lua40
1 files changed, 40 insertions, 0 deletions
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
133 print("table.remove", next(t)) 133 print("table.remove", next(t))
134end 134end
135 135
136___''
137do
138 local p, t = tproxy{ 3, 1, 5, 2, 8, 5, 2, 9, 7, 4 }
139 table.sort(p)
140 print("table.sort", next(p))
141 for i,v in ipairs(t) do
142 print("table.sort", i, v)
143 end
144 table.sort(p)
145 print("table.sort", next(p))
146 for i,v in ipairs(t) do
147 print("table.sort", i, v)
148 end
149 p, t = tproxy{ 9, 8, 7, 6, 5, 4, 3, 2, 1 }
150 table.sort(p)
151 print("table.sort", next(p))
152 for i,v in ipairs(t) do
153 print("table.sort", i, v)
154 end
155 table.sort(p, function(a, b) return a > b end)
156 print("table.sort", next(p))
157 for i,v in ipairs(t) do
158 print("table.sort", i, v)
159 end
160 p, t = tproxy{ 1, 1, 1, 1, 1 }
161 print("table.sort", next(p))
162 for i,v in ipairs(t) do
163 print("table.sort", i, v)
164 end
165 t = { 3, 1, 5, 2, 8, 5, 2, 9, 7, 4 }
166 table.sort(t)
167 for i,v in ipairs(t) do
168 print("table.sort", i, v)
169 end
170 table.sort(t, function(a, b) return a > b end)
171 for i,v in ipairs(t) do
172 print("table.sort", i, v)
173 end
174end
175
136 176
137___'' 177___''
138do 178do