Skip to content

Commit 39b49ee

Browse files
Fixed tests
1 parent 8b0a859 commit 39b49ee

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

pythonlua/luainit.lua

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ local function range(from, to, step)
4646
end
4747
end
4848

49+
local g_real_unpack = unpack
50+
51+
local unpack = function(t)
52+
if type(t) == "table" and t.is_list then
53+
return g_real_unpack(t._data)
54+
end
55+
return g_real_unpack(t)
56+
end
57+
4958
local function list(t)
5059
local result = {}
5160

@@ -66,8 +75,11 @@ local function list(t)
6675

6776
setmetatable(result, {
6877
__index = function(self, index)
69-
if type(index) == "number" and index < 0 then
70-
return rawget(result._data, #result._data + index + 1)
78+
if type(index) == "number" then
79+
if index < 0 then
80+
index = #result._data + index + 1
81+
end
82+
return rawget(result._data, index)
7183
end
7284

7385
return methods[index]
@@ -110,6 +122,9 @@ function dict(t)
110122

111123
setmetatable(result, {
112124
__index = function(self, index)
125+
if result._data[index] ~= nil then
126+
return result._data[index]
127+
end
113128
return methods[index]
114129
end,
115130
__newindex = function(self, index, value)

tests/comprehensions.py.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
8
88
12
99
10
10-
1 1.0
11-
2 4.0
12-
3 9.0
13-
4 16.0
14-
5 25.0
10+
1 1
11+
2 4
12+
3 9
13+
4 16
14+
5 25

tests/global.py.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
foo = 42
2+
foo = 34

0 commit comments

Comments
 (0)