-
Notifications
You must be signed in to change notification settings - Fork 66
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
Fix invalid Java unit test assertion #116
Conversation
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Unit tests for CodeCompletionCore | ||
*/ | ||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This annotation was hiding the broken test. Test correctness shouldn't depend on the order in which the test methods are run.
@@ -153,8 +150,8 @@ public void test2_typicalExpressionTest() throws Exception { | |||
assertTrue(candidates.tokens.containsKey(ExprLexer.VAR)); | |||
assertTrue(candidates.tokens.containsKey(ExprLexer.LET)); | |||
|
|||
assertEquals(Arrays.asList(new Integer[]{ExprLexer.ID, ExprLexer.EQUAL}), candidates.tokens.get(ExprLexer.VAR)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExprLexer.ID
and ExprLexer.EQUAL
are members of the ignored token set, so they should not be candidate completions.
Thanks @mallman, please sign your patch so I can merge it (see the DCO link) |
tokens as completions Signed-off-by: Michael Allman <msa@allman.ms>
Done. Any thoughts on how to fix the associated bug? Do you want to take that on yourself? |
No idea yet. If you would like to take that over that would be great. |
Fix invalid Java unit test assertion. C3 should not suggest ignored tokens as completions.
See issue #77 for related discussion.
This invalid assertion was hiding a bug in C3. How to fix that bug is up for discussion, but basically it appears that the implementation of the
followSetsByATN
global cache is problematic. This cache is based on the class name of the parser object, but it does not account for ignored tokens. Two instances ofCodeCompletionCore
will use the samefollowSetsByATN
entry for the same parser, even if they have different ignored tokens. How to fix this?The other language implementations of C3 may have the same problem. For example, it looks to me like the C# tests have the same invalid assertion. I'm not sure I want to touch that, though, because I'm not familiar with C#. So this PR just addresses the Java port.
I'm also wondering if this is related to #66 as well. @mike-lischke is the expert here.