mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Add table.keyof()
(#14910)
This commit is contained in:
parent
a677d33bdf
commit
dc7a7a0ed9
4 changed files with 25 additions and 1 deletions
|
@ -166,6 +166,16 @@ describe("table", function()
|
|||
it("indexof()", function()
|
||||
assert.equal(1, table.indexof({"foo", "bar"}, "foo"))
|
||||
assert.equal(-1, table.indexof({"foo", "bar"}, "baz"))
|
||||
assert.equal(-1, table.indexof({[2] = "foo", [3] = "bar"}, "foo"))
|
||||
assert.equal(-1, table.indexof({[1] = "foo", [3] = "bar"}, "bar"))
|
||||
end)
|
||||
|
||||
it("keyof()", function()
|
||||
assert.equal("a", table.keyof({a = "foo", b = "bar"}, "foo"))
|
||||
assert.equal(nil, table.keyof({a = "foo", b = "bar"}, "baz"))
|
||||
assert.equal(1, table.keyof({"foo", "bar"}, "foo"))
|
||||
assert.equal(2, table.keyof({[2] = "foo", [3] = "bar"}, "foo"))
|
||||
assert.equal(3, table.keyof({[1] = "foo", [3] = "bar"}, "bar"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue