summaryrefslogtreecommitdiff
path: root/tests/modules/table/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-14 23:25:19 +0800
committerruki <[email protected]>2021-11-14 23:25:19 +0800
commit474998e342c779f71ff5591ddc936304411fa46a (patch)
tree9efa50d7cf7fa857e0b163e6aa0335cb62a76745 /tests/modules/table/test.lua
parent8ea70c741c233e8ddc1523cc8f2e91eb7baa2de7 (diff)
add table.find_xxx
Diffstat (limited to 'tests/modules/table/test.lua')
-rw-r--r--tests/modules/table/test.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/modules/table/test.lua b/tests/modules/table/test.lua
index fc17fcb62..5ed17620c 100644
--- a/tests/modules/table/test.lua
+++ b/tests/modules/table/test.lua
@@ -1,4 +1,11 @@
function test_remove_if(t)
- t:are_equal(table.remove_if({1, 2, 3, 4, 5, 6}, function (t, i, v) return (v % 2) == 0 end), {1, 3, 5})
- t:are_equal(table.remove_if({a = 1, b = 2, c = 3}, function (t, i, v) return (v % 2) == 0 end), {a = 1, c = 3})
+ t:are_equal(table.remove_if({1, 2, 3, 4, 5, 6}, function (i, v) return (v % 2) == 0 end), {1, 3, 5})
+ t:are_equal(table.remove_if({a = 1, b = 2, c = 3}, function (i, v) return (v % 2) == 0 end), {a = 1, c = 3})
+end
+
+function test_find_if(t)
+ t:are_equal(table.find_if({1, 2, 3, 4, 5, 6}, function (i, v) return (v % 2) == 0 end), {2, 4, 6})
+ t:are_equal(table.find_first_if({1, 2, 3, 4, 5, 6}, function (i, v) return (v % 2) == 0 end), 2)
+ t:are_equal(table.find({1, 2, 4, 4, 5, 6}, 4), {3, 4})
+ t:are_equal(table.find_first({1, 2, 3, 4, 5, 6}, 4), 4)
end