• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moonlibs / algo / 13245529690

10 Feb 2025 04:24PM UTC coverage: 88.735% (+0.3%) from 88.411%
13245529690

push

github

web-flow
Merge 53997529c into 98a85d735

74 of 85 new or added lines in 4 files covered. (87.06%)

33 existing lines in 1 file now uncovered.

512 of 577 relevant lines covered (88.73%)

4565.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/algo/utils.lua
1
local type = type
1✔
2
local math_floor = math.floor
1✔
3
local table_new = require('table.new')
1✔
4

5
---Appends all k-vs from t2 to t1, if not exists in t1
6
---@param t1 table?
7
---@param t2 table?
8
local function merge(t1, t2)
9
        if type(t1) ~= 'table' or type(t2) ~= 'table' then return end
7✔
10

NEW
11
        for k in pairs(t2) do
×
NEW
12
                if t1[k] == nil then
×
NEW
13
                        t1[k] = t2[k]
×
14
                end
15
        end
16
end
17

18
local map_mt  = { __serialize = 'map' }
1✔
19
local list_mt = { __serialize = 'seq' }
1✔
20
local weak_mt = { __mode = 'v' }
1✔
21

22

23
---Creates new list with null values
24
---@param size number
25
---@param init number? initial value
26
---@private
27
---@return number[]
28
local function new_list(size, init)
29
        size = math_floor(size)
20✔
30
        local t = setmetatable(table_new(size, 0), list_mt)
20✔
31
        if not init then return t end
20✔
32
        for i = 0, size do
70✔
33
                t[i] = init
60✔
34
        end
35
        return t
10✔
36
end
37

38
---Creates new list with zero values
39
---@param size number
40
---@private
41
---@return number[]
42
local function new_zero_list(size)
43
        return new_list(size, 0)
10✔
44
end
45

46
local function _list_serialize(list)
NEW
47
        local r = {}
×
NEW
48
        for i = 1, #list do
×
NEW
49
                r[i] = tostring(list[i])
×
50
        end
NEW
51
        return r
×
52
end
53

54
local pretty_list_mt = {__serialize = _list_serialize}
1✔
55

56
local function make_list_pretty(rv)
NEW
57
        return setmetatable(rv, pretty_list_mt)
×
58
end
59

60

61
return {
1✔
62
        merge = merge,
1✔
63
        map_mt = map_mt,
1✔
64
        list_mt = list_mt,
1✔
65
        weak_mt = weak_mt,
1✔
66

67
        new_list = new_list,
1✔
68
        new_zero_list = new_zero_list,
1✔
69
        make_list_pretty = make_list_pretty,
1✔
70
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc