diff options
author | mpeterv <mpeterval@gmail.com> | 2015-12-04 18:50:15 +0300 |
---|---|---|
committer | mpeterv <mpeterval@gmail.com> | 2015-12-04 18:50:15 +0300 |
commit | ec6294c99a1bbe7a5a82228a8cb26ae9f30132fe (patch) | |
tree | e0130b3467a66c798c901c68e57a276aa2893d82 | |
parent | fb2ddba82a373b5b2972bf6a6a083271419712a5 (diff) | |
download | luacov-ec6294c99a1bbe7a5a82228a8cb26ae9f30132fe.tar.gz |
Filter out hanging table endings
Line "}," does not trigger debug hooks if the table being closed
is empty or ends with a key-value pair. Same goes for "}, function(...)".
-rw-r--r-- | src/luacov/reporter.lua | 2 | ||||
-rw-r--r-- | tests/linescanner.lua | 24 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/luacov/reporter.lua b/src/luacov/reporter.lua index d8e315c..9da032c 100644 --- a/src/luacov/reporter.lua +++ b/src/luacov/reporter.lua @@ -66,6 +66,8 @@ local zero_hits_exclusions = { fixup "local <ID>=<PARENS>'", -- "local a = [[", possibly with opening parens fixup "<FULLID>=<PARENS>'", -- "a.b = [[", possibly with opening parens fixup "<FULLID>=function", -- "a = function(arg1, ..., argN)" + "} ?,", -- "}," generates no trace if the table ends with a key-value pair + "} ?, ?function", -- same with "}, function(...)" "break", -- "break" generates no trace in Lua 5.2+ "{", -- "{" opening table "}?[ %)]*", -- optional "{" closing table, possibly with several closing parens diff --git a/tests/linescanner.lua b/tests/linescanner.lua index f726fbd..a96a9a6 100644 --- a/tests/linescanner.lua +++ b/tests/linescanner.lua @@ -48,7 +48,7 @@ test [[ local stuff = function (x) return x end + local thing = stuff({ + b = { name = 'bob', ? - }, + + }, ? -- comment - }) ? print("test2") + @@ -58,7 +58,7 @@ test [[ local stuff = function (x) return x end + local thing = stuff({ + b = { name = 'bob', ? - }, + + }, ? -- comment - } ? ) ? @@ -267,4 +267,24 @@ local t = { + } ? ]=] +-- Hanging table endings. +test [[ +local v = f({ + + a = "foo", ? + x = y + +}, ? +function(g) ? + g() + +end) - +]] + +test [[ +local v = f({ + + a = "foo", ? + x = y + +}, function(g) ? + g() + +end) - +]] + print(("%d LineScanner tests passed."):format(ntests)) |