1 13 14 package org.netbeans.lib.html.lexer; 15 16 import junit.framework.TestCase; 17 import org.netbeans.lib.lexer.test.FixedTextDescriptor; 18 import org.netbeans.lib.lexer.test.LexerTestUtilities; 19 import org.netbeans.lib.lexer.test.RandomCharDescriptor; 20 import org.netbeans.lib.lexer.test.RandomModifyDescriptor; 21 import org.netbeans.lib.lexer.test.RandomTextProvider; 22 import org.netbeans.lib.lexer.test.TestRandomModify; 23 import org.netbeans.modules.el.lexer.api.ELTokenId; 24 25 30 public class ELLexerRandomTest extends TestCase { 31 32 public ELLexerRandomTest(String testName) { 33 super(testName); 34 } 35 36 protected void setUp() throws java.lang.Exception { 37 LexerTestUtilities.setTesting(true); 39 } 40 41 protected void tearDown() throws java.lang.Exception { 42 } 43 44 public void testRandom() throws Exception { 45 test(0); 46 } 47 48 private void test(long seed) throws Exception { 49 TestRandomModify randomModify = new TestRandomModify(seed); 50 randomModify.setLanguage(ELTokenId.language()); 51 52 56 randomModify.insertText(0, "("); 58 randomModify.insertText(1, "1"); 59 randomModify.insertText(2, "2"); 60 randomModify.insertText(3, ")"); 61 randomModify.insertText(2, "+"); 62 randomModify.removeText(2, 1); 63 randomModify.insertText(2, "-"); 64 65 randomModify.clearDocument(); 66 67 FixedTextDescriptor[] fixedTexts = new FixedTextDescriptor[] { 69 FixedTextDescriptor.create(" ", 0.2), 70 }; 71 72 RandomCharDescriptor[] regularChars = new RandomCharDescriptor[] { 73 RandomCharDescriptor.digit(0.2), 74 RandomCharDescriptor.space(0.2), 75 RandomCharDescriptor.chars(new char[] { '+', '-', '(', ')' }, 0.3), 76 }; 77 78 RandomTextProvider regularTextProvider = new RandomTextProvider(regularChars, fixedTexts); 79 80 randomModify.test( 81 new RandomModifyDescriptor[] { 82 new RandomModifyDescriptor(20, regularTextProvider, 83 0.4, 0.2, 0.2, 84 0.1, 0.1, 85 0.0, 0.0), new RandomModifyDescriptor(20, regularTextProvider, 87 0.2, 0.2, 0.1, 88 0.4, 0.3, 89 0.0, 0.0), } 91 ); 92 } 93 94 } 95 | Popular Tags |