Skip to content

Commit d4e8b14

Browse files
committed
Lua 5.5 no longer put nil in array part of table.
1 parent bc1a80b commit d4e8b14

2 files changed

Lines changed: 10 additions & 42 deletions

File tree

spec/inputs/test/in_expression_spec.yue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,6 @@ describe "in expression", ->
7272
assert.is_true 2 in get_items!
7373
assert.is_false 5 in get_items!
7474

75-
it "should handle nil in table", ->
76-
items = {1, nil, 3}
77-
assert.is_true nil in items
78-
assert.is_true 1 in items
79-
8075
it "should work with string keys", ->
8176
obj = ["name", "value"]
8277
assert.is_true "name" in obj

spec/outputs/test/in_expression_spec.lua

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -201,25 +201,7 @@ local _anon_func_21 = function(get_items)
201201
end
202202
return false
203203
end
204-
local _anon_func_22 = function(items)
205-
local _val_0 = nil
206-
for _index_0 = 1, #items do
207-
if items[_index_0] == _val_0 then
208-
return true
209-
end
210-
end
211-
return false
212-
end
213-
local _anon_func_23 = function(items)
214-
local _val_0 = 1
215-
for _index_0 = 1, #items do
216-
if items[_index_0] == _val_0 then
217-
return true
218-
end
219-
end
220-
return false
221-
end
222-
local _anon_func_24 = function(obj)
204+
local _anon_func_22 = function(obj)
223205
local _val_0 = "name"
224206
for _index_0 = 1, #obj do
225207
if obj[_index_0] == _val_0 then
@@ -228,7 +210,7 @@ local _anon_func_24 = function(obj)
228210
end
229211
return false
230212
end
231-
local _anon_func_25 = function(obj)
213+
local _anon_func_23 = function(obj)
232214
local _val_0 = "value"
233215
for _index_0 = 1, #obj do
234216
if obj[_index_0] == _val_0 then
@@ -237,7 +219,7 @@ local _anon_func_25 = function(obj)
237219
end
238220
return false
239221
end
240-
local _anon_func_26 = function(obj)
222+
local _anon_func_24 = function(obj)
241223
local _val_0 = "missing"
242224
for _index_0 = 1, #obj do
243225
if obj[_index_0] == _val_0 then
@@ -246,7 +228,7 @@ local _anon_func_26 = function(obj)
246228
end
247229
return false
248230
end
249-
local _anon_func_27 = function(items)
231+
local _anon_func_25 = function(items)
250232
local _val_0 = 2
251233
for _index_0 = 1, #items do
252234
if items[_index_0] == _val_0 then
@@ -255,7 +237,7 @@ local _anon_func_27 = function(items)
255237
end
256238
return false
257239
end
258-
local _anon_func_28 = function(allowed, item)
240+
local _anon_func_26 = function(allowed, item)
259241
for _index_0 = 1, #allowed do
260242
if allowed[_index_0] == item then
261243
return true
@@ -411,31 +393,22 @@ return describe("in expression", function()
411393
assert.is_true(_anon_func_20(get_items))
412394
return assert.is_false(_anon_func_21(get_items))
413395
end)
414-
it("should handle nil in table", function()
415-
local items = {
416-
1,
417-
nil,
418-
3
419-
}
420-
assert.is_true(_anon_func_22(items))
421-
return assert.is_true(_anon_func_23(items))
422-
end)
423396
it("should work with string keys", function()
424397
local obj = {
425398
"name",
426399
"value"
427400
}
428-
assert.is_true(_anon_func_24(obj))
429-
assert.is_true(_anon_func_25(obj))
430-
return assert.is_false(_anon_func_26(obj))
401+
assert.is_true(_anon_func_22(obj))
402+
assert.is_true(_anon_func_23(obj))
403+
return assert.is_false(_anon_func_24(obj))
431404
end)
432405
it("should support complex expressions", function()
433406
local items = {
434407
1,
435408
2,
436409
3
437410
}
438-
local result = (_anon_func_27(items)) and "yes" or "no"
411+
local result = (_anon_func_25(items)) and "yes" or "no"
439412
return assert.same(result, "yes")
440413
end)
441414
return it("should work in comprehension", function()
@@ -456,7 +429,7 @@ return describe("in expression", function()
456429
local _len_0 = 1
457430
for _index_0 = 1, #source do
458431
local item = source[_index_0]
459-
if (#allowed > 0 and _anon_func_28(allowed, item)) then
432+
if (#allowed > 0 and _anon_func_26(allowed, item)) then
460433
_accum_0[_len_0] = item
461434
_len_0 = _len_0 + 1
462435
end

0 commit comments

Comments
 (0)