Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last entry in multi-line table definition missed if there's no trailing comma #52

Open
argos83 opened this issue Dec 5, 2016 · 5 comments

Comments

@argos83
Copy link

argos83 commented Dec 5, 2016

Hi!

When defining a table in multiple lines, LuaCov misses coverage on the last entry unless it has a trailing comma.

E.g.
Without trailing comma:

   11 local dummy_table = {
      	['a'] = 'A',
      	['b'] = 'B',
****0 	['c'] = 'C'
      }

With trailing comma:

   11 local dummy_table = {
      	['a'] = 'A',
      	['b'] = 'B',
      	['c'] = 'C',
      }

Thanks for this great library!

@mpeterv
Copy link
Contributor

mpeterv commented Dec 12, 2016

Hi @argos83! This problem in general is relatively difficult to detect: it's specific to LuaJIT IIRC, and simply filtering out misses on such lines is sometimes wrong because fieldname = "value" is valid outside tables and shouldn't be filtered out.

Does the problem go away when running luacov with cluacov installed?

@argos83
Copy link
Author

argos83 commented Dec 13, 2016

Hey @mpeterv, I've just tried with cluacov and the same issue occurs.

@mpeterv
Copy link
Contributor

mpeterv commented Dec 13, 2016

That's strange. cluacov fixed it for me. What version of Lua/LuaJIT are you using? I see that the first line of your example is executed 11 times so it must be a part of a larger snippet, does the issue occur when running just the example?

@argos83
Copy link
Author

argos83 commented Dec 15, 2016

Hey @mpeterv. It also happens when running just the example:

   1 local sometable = {
         ['a'] = 'A',
         ['b'] = 'B',
***0     ['c'] = 'C'
     }

I'm running lua in the context of OpenResty (v 1.11.2.2) compiled with --with-luajit which I think installs LuaJIT 2.1

@hsandt
Copy link

hsandt commented Oct 7, 2020

Erm... I had the exact opposite issue, where the last line would be considered uncovered only if adding a trailing comma

t = {
  1   a.b,
  1   a.c,
  1   a.d,
**0   a.e,
  1 }

I guess I shouldn't open a new issue and add my case here instead?

Did somebody send a PR trying to fix this issue, resulting in the opposite issue?

DifferentialOrange added a commit to tarantool/graphql that referenced this issue Nov 15, 2021
Last line in multiline table considered as non-covered by luacov
if it has no trailing comma. See more about the issue in luacov repo:
lunarmodules/luacov#52

Based on PR #18 by @no1seman
DifferentialOrange added a commit to tarantool/graphql that referenced this issue Nov 15, 2021
Last line in multiline table considered as non-covered by luacov
if it has no trailing comma. See more about the issue in luacov repo:
lunarmodules/luacov#52

Based on PR #18 by @no1seman
DifferentialOrange added a commit to tarantool/graphql that referenced this issue Nov 15, 2021
Last entries line in multiline table considered as non-covered by luacov
if it has no trailing comma. See more about the issue in luacov repo:
lunarmodules/luacov#52

Based on PR #18 by @no1seman
DifferentialOrange added a commit to tarantool/graphql that referenced this issue Nov 18, 2021
Last entries line in multiline table considered as non-covered by luacov
if it has no trailing comma. See more about the issue in luacov repo:
lunarmodules/luacov#52

Based on PR #18 by @no1seman
Totktonada pushed a commit to tarantool/graphql that referenced this issue Nov 18, 2021
Last entries line in multiline table considered as non-covered by luacov
if it has no trailing comma. See more about the issue in luacov repo:
lunarmodules/luacov#52

Based on PR #18 by @no1seman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants