forked from antlr/antlr4
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from antlr/Test-word-size
Complement and validate bitset bug fix
- Loading branch information
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tool/test/org/antlr/v4/test/rt/js/node/TestBitSetWordSize.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.antlr.v4.test.rt.js.node; | ||
|
||
import org.junit.Test; | ||
import static org.junit.Assert.*; | ||
|
||
public class TestBitSetWordSize extends BaseTest { | ||
|
||
@Test | ||
public void testBitSetWordSize() throws Exception { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("grammar T;\n"); | ||
// create 40 tokens so we exceed 32 bits size | ||
for(int i=1;i<=40;i++) { | ||
sb.append("T"); | ||
sb.append(i); | ||
sb.append(" : 'x"); | ||
sb.append(i); | ||
sb.append("';\n"); | ||
} | ||
// create a rule which will generate bit set test | ||
sb.append("o : T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8;\n"); | ||
// create a rule where expected token - 32 uses same bit than optional token | ||
sb.append("a : o? T36 {console.log('ok');};\n"); | ||
sb.append("WS : (' '|'\\n') -> skip ;"); | ||
String grammar = sb.toString(); | ||
// use input which triggers bug when word size is 64 | ||
String input = "x36"; | ||
String found = execParser("T.g4", grammar, "TParser", "TLexer", "TListener", "TVisitor", "a", input, false); | ||
assertEquals("ok\n", found); | ||
assertNull(this.stderrDuringParse); | ||
} | ||
|
||
|
||
|
||
} |