1 19 20 package org.netbeans.lib.java.lexer; 21 22 import junit.framework.TestCase; 23 import org.netbeans.api.java.lexer.JavaTokenId; 24 import org.netbeans.lib.lexer.test.FixedTextDescriptor; 25 import org.netbeans.lib.lexer.test.RandomCharDescriptor; 26 import org.netbeans.lib.lexer.test.RandomModifyDescriptor; 27 import org.netbeans.lib.lexer.test.RandomTextProvider; 28 import org.netbeans.lib.lexer.test.TestRandomModify; 29 30 35 public class JavaLexerRandomTest extends TestCase { 36 37 public JavaLexerRandomTest(String testName) { 38 super(testName); 39 } 40 41 protected void setUp() throws java.lang.Exception { 42 System.setProperty("netbeans.debug.lexer.test", "true"); 44 } 45 46 protected void tearDown() throws java.lang.Exception { 47 } 48 49 public void testRandom() throws Exception { 50 test(0); 51 } 52 53 private void test(long seed) throws Exception { 54 TestRandomModify randomModify = new TestRandomModify(seed); 55 randomModify.setLanguage(JavaTokenId.language()); 56 57 61 FixedTextDescriptor[] fixedTexts = new FixedTextDescriptor[] { 62 FixedTextDescriptor.create("/**/", 0.2), 63 FixedTextDescriptor.create("*/", 0.2), 64 }; 65 66 RandomCharDescriptor[] regularChars = new RandomCharDescriptor[] { 67 RandomCharDescriptor.letter(0.3), 68 RandomCharDescriptor.space(0.3), 69 RandomCharDescriptor.lf(0.3), 70 RandomCharDescriptor.chars(new char[] { '+', '-', '*', '/'}, 0.3), 71 }; 72 73 RandomCharDescriptor[] anyChar = new RandomCharDescriptor[] { 74 RandomCharDescriptor.anyChar(1.0), 75 }; 76 77 RandomTextProvider regularTextProvider = new RandomTextProvider(regularChars, fixedTexts); 78 RandomTextProvider anyCharTextProvider = new RandomTextProvider(anyChar, fixedTexts); 79 80 randomModify.test( 81 new RandomModifyDescriptor[] { 82 new RandomModifyDescriptor(1000, regularTextProvider, 83 0.2, 0.2, 0.1, 84 0.2, 0.2, 85 0.0, 0.0), 86 } 87 ); 88 89 randomModify.test( 90 new RandomModifyDescriptor[] { 91 new RandomModifyDescriptor(1000, anyCharTextProvider, 92 0.4, 0.2, 0.2, 93 0.1, 0.1, 94 0.0, 0.0), 95 new RandomModifyDescriptor(1000, anyCharTextProvider, 96 0.2, 0.2, 0.1, 97 0.4, 0.3, 98 0.0, 0.0), 99 } 100 ); 101 } 102 103 } 104 | Popular Tags |