summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormpeterv <mpeterval@gmail.com>2016-04-17 12:45:31 +0300
committermpeterv <mpeterval@gmail.com>2016-04-17 12:58:50 +0300
commitc3b8293c1ce682f34abfb8d88687922288f016ed (patch)
tree47b3f7fbe118bb607f261689232a753dc9752406
parentbd3f31ea3e1b57f53430486a43da95c339c8fed0 (diff)
downloadluacov-c3b8293c1ce682f34abfb8d88687922288f016ed.tar.gz
Fix line filtering for simple single line expressions
-rw-r--r--src/luacov/reporter.lua4
-rw-r--r--tests/linescanner.lua37
2 files changed, 39 insertions, 2 deletions
diff --git a/src/luacov/reporter.lua b/src/luacov/reporter.lua
index 30bd20e..fcf65c3 100644
--- a/src/luacov/reporter.lua
+++ b/src/luacov/reporter.lua
@@ -58,6 +58,10 @@ local zero_hits_exclusions = {
fixup "<FIELDNAME>=<PARENS>'", -- "[123] = [[", possibly with opening parens
"return function", -- "return function(arg1, ..., argN)"
"function", -- "function(arg1, ..., argN)"
+ "[ntfx0]", -- Single token expressions leave no trace in tables, function calls and sometimes assignments
+ "''", -- Same for strings
+ "{ ?}", -- Same for empty tables
+ fixup "<FULLID>", -- Same for local variables indexed once
fixup "local x=function", -- "local a = function(arg1, ..., argN)"
fixup "local x=<PARENS>'", -- "local a = [[", possibly with opening parens
fixup "local x=n", -- "local a = nil; local b = nil" produces no trace for the second statement
diff --git a/tests/linescanner.lua b/tests/linescanner.lua
index 3c62f8c..6287850 100644
--- a/tests/linescanner.lua
+++ b/tests/linescanner.lua
@@ -244,11 +244,11 @@ local function f() end +
local x -
local x, y -
local x = -
-1 +
+1 ?
local x, y = -
2, 3 +
local x, y = 2, +
-3 +
+3 ?
]]
test [[
@@ -274,6 +274,39 @@ local t = { +
} ?
]=]
+-- Single expressions in tables and calls.
+test [=[
+local x = { +
+ 1, ?
+ 2 ?
+} ?
+local y = { +
+ 3, ?
+ id ?
+} ?
+local z = { +
+ "" ?
+} ?
+local a = f( +
+ true ?
+) ?
+local b = { +
+ id[1] ?
+} ?
+local c = { +
+ id.abcd ?
+} ?
+local d = { +
+ id.k1.k2 +
+} ?
+local e = { +
+ {} ?
+} ?
+local f = { +
+ {foo} +
+} ?
+]=]
+
-- Hanging table endings.
test [[
local v = f({ +