-
Notifications
You must be signed in to change notification settings - Fork 31
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
instrumentation breaks JavaScript labels #10
Comments
I didn't even know you could do this. :P |
Some thoughts about fixing this: In compiler terms, the embedded javascript label becomes a "value". e.g. this:
Becomes an AST that looks like:
So we could say "Whenever there's a Another alternative would be to use something along the lines of Microsoft C++ style pragmas, so we could do:
So the pragmas would disable and enable coverage selectively. This is perhaps a more flexible solution, which applications outside of this particular problem. It might be desirable to allow the "off" pragma to be inside the loop, although it might be tricky to allow the pragmas to span multiple scopes in such a fashion. |
Your #pragma idea sounds intriguing. I'm not sure how much effort this would be and how much effort one should spend on the above issue. You can always rewrite code using labels into code using no labels. Thats what we have done for now to continue working with coffee-coverage. Another way would be to parse the embedded JavaScript and try to get a deeper understanding of it. |
While pragma sounds intriguing, it will lead to code for which no coverage data was collected for. As such I would call this a bad practice. And bad programmers tend to fall back to a pragma(tic) solution whenever they feel necessary. http://stackoverflow.com/questions/46586/goto-still-considered-harmful |
We have this new pragma feature in 0.5.0, which might do what you want using jscoverage, but it still instruments the line for Istanbul and just marks the statement as |
When placing a JavaScript label in CoffeeScript in front of a loop like this:
the instrumentation will insert a line similar to
between the label and the loop head, thus generating invalid JavaScript:
The text was updated successfully, but these errors were encountered: