Skip to content

Commit 8d1196f

Browse files
committed
remove dead code
1 parent fbd061e commit 8d1196f

8 files changed

Lines changed: 15 additions & 66 deletions

File tree

nattlua.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/local/bin/luajit
22

33
if ... == "test" then
4+
require("test.helpers.preprocess")
45
STARTUP_PROFILE = true
56
require("test.helpers.profiler").Start()
67
end

nattlua/other/formating.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ local tostring = _G.tostring
77
local error = _G.error
88
local ipairs = _G.ipairs
99
local stringx = require("nattlua.other.string")
10-
local mathx = require("nattlua.other.math")
1110
local formating = {}
1211

1312
function formating.QuoteToken(str--[[#: string]])--[[#: string]]
@@ -284,6 +283,10 @@ local function calculate_text_positions(
284283
}
285284
end
286285

286+
local function clamp(num--[[#: number]], min--[[#: number]], max--[[#: number]])
287+
return math.min(math.max(num, min), max)
288+
end
289+
287290
function formating.BuildSourceCodePointMessage2(
288291
code--[[#: string]],
289292
start--[[#: number]],
@@ -303,8 +306,8 @@ function formating.BuildSourceCodePointMessage2(
303306

304307
if config.show_box == nil then config.show_box = true end
305308

306-
start = mathx.clamp(start or 1, 1, #code)
307-
stop = mathx.clamp(stop or 1, 1, #code)
309+
start = clamp(start or 1, 1, #code)
310+
stop = clamp(stop or 1, 1, #code)
308311

309312
if stop < start then start, stop = stop, start end
310313

nattlua/other/math.lua

Lines changed: 0 additions & 17 deletions
This file was deleted.

nattlua/other/path.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ function path.GetFileName(path, no_extension)
166166

167167
if last_dot then return path:sub(1, last_dot - 1) else return path end
168168
end
169-
return path
170169

170+
return path
171171
end
172172

173173
return path

nattlua/other/string.lua

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,6 @@ function stringx.replace(self--[[#: string]], old--[[#: string]], new--[[#: stri
3333
return table.concat(parts, new)
3434
end
3535

36-
function stringx.trim(self--[[#: string]])
37-
local char = "%s*"
38-
local _, start = self:find(char, 0)
39-
local end_start, end_stop = self:reverse():find(char, 0)
40-
41-
if start and end_start and end_stop then
42-
return self:sub(start + 1, (end_start - end_stop) - 2)
43-
elseif start then
44-
return self:sub(start + 1)
45-
elseif end_start and end_stop then
46-
return self:sub(0, (end_start - end_stop) - 2)
47-
end
48-
49-
return self
50-
end
51-
5236
function stringx.pad_left(str--[[#: string]], len--[[#: number]], char--[[#: string]])
5337
if #str < len + 1 then return char:rep(len - #str + 1) .. str end
5438

test/helpers/coverage.lua

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function coverage.Preprocess(code, key)
1515
-- don't mark the funciton body as being called
1616
start, stop = node.tokens["function"].start, node.tokens["function"].stop
1717
end
18+
1819
if node.kind == "table" then
1920
-- don't mark the funciton body as being called
2021
start, stop = node.tokens["{"].start, node.tokens["{"].stop
@@ -136,33 +137,6 @@ function coverage.Clear(key)
136137
_G.__COVERAGE[key] = nil
137138
end
138139

139-
local function normalizeRanges(ranges)
140-
local start, stop = ranges[1][1], ranges[#ranges][2]
141-
local new_list = {}
142-
local last = 0
143-
local last_index = start
144-
local i = start
145-
146-
while i <= stop do
147-
local count = 0
148-
149-
for _, range in ipairs(ranges) do
150-
if i >= range[1] and i <= range[2] then count = count + range[3] end
151-
end
152-
153-
if count ~= last then
154-
table.insert(new_list, {last_index, i, count})
155-
i = i + 1
156-
last = count
157-
last_index = i
158-
end
159-
160-
i = i + 1
161-
end
162-
163-
return new_list
164-
end
165-
166140
local function normalizeRanges(ranges)
167141
local map = {}
168142
local minVal = math.huge

test/run.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if is_coverage then
2424

2525
function preprocess.Preprocess(code, name, path, from)
2626
if from == "package" then
27-
if path and path:find("^nattlua/") and not path:find("^nattlua/other") then
27+
if path and path:find("^nattlua/") then
2828
covered[name] = path
2929
return coverage.Preprocess(code, name)
3030
end

test/tests/coverage.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ local function annotate_equal(code)
5151
equal(annotate(code), code)
5252
end
5353

54-
5554
collect([[
5655
5756
local foo = {
@@ -293,6 +292,11 @@ local code = META.New([[
293292
]=])
294293

295294

295+
coverage.Preprocess([==[
296+
--[[#local type x = tbl[name] ]]
297+
]==], "test")
298+
299+
296300
equal(annotate("local x = 1"), "1")
297301
equal(annotate("do return end"), "return")
298302
equal(

0 commit comments

Comments
 (0)