[chore] Add the length method to state.array
@@ -1772,22 +1772,10 @@ func TestArray(t *testing.T) {
end
function len()
- return #counts
+ return counts:length()
end
function iter()
- local rv = {}
- for i, v in state.array_pairs(counts) do
- if v == nil then
- rv[i] = "nil"
- else
- rv[i] = v
- end
- end
- return rv
- end
-
- function iter2()
local rv = {}
for i, v in counts:ipairs() do
if v == nil then
@@ -1799,7 +1787,7 @@ func TestArray(t *testing.T) {
return rv
end
- abi.register(inc,get,set,len,iter,iter2)`
+ abi.register(inc,get,set,len,iter)`
bc, err := LoadDummyChain()
if err != nil {
@@ -1842,10 +1830,6 @@ func TestArray(t *testing.T) {
if err != nil {
t.Error(err)
}
- err = bc.Query("array", `{"Name":"iter2"}`, "", `[2,"ktlee","nil","nil","nil","nil","nil","nil","nil","nil"]`)
- if err != nil {
- t.Error(err)
- }
}
func TestPcall(t *testing.T) {
@@ -2460,7 +2444,7 @@ state.var {
}
function Length()
- return #fixedArray
+ return fixedArray:length()
end
abi.register(Length)
@@ -2485,7 +2469,7 @@ state.var {
}
function Append(val)
- dArr.append(val)
+ dArr:append(val)
end
function Get(idx)
@@ -2497,7 +2481,7 @@ function Set(idx, val)
end
function Length()
- return #dArr
+ return dArr:length()
end
abi.register(Append, Get, Set, Length)
