1 19 20 package org.netbeans.lib.lexer.test.simple; 21 22 import junit.framework.TestCase; 23 import org.netbeans.lib.lexer.test.FixedTextDescriptor; 24 import org.netbeans.lib.lexer.test.LexerTestUtilities; 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 SimpleLexerRandomTest extends TestCase { 36 37 public SimpleLexerRandomTest(String testName) { 38 super(testName); 39 } 40 41 protected void setUp() throws java.lang.Exception { 42 LexerTestUtilities.setTesting(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 public void testWithSeed_1140557399761L() throws Exception { 54 test(1140557399761L); 55 } 56 57 private void test(long seed) throws Exception { 58 TestRandomModify randomModify = new TestRandomModify(seed); 59 randomModify.setLanguage(SimpleTokenId.language()); 60 61 65 randomModify.insertText(0, "+--+"); 68 randomModify.removeText(2, 1); 69 70 randomModify.clearDocument(); 71 72 randomModify.insertText(0, "---+"); 77 randomModify.insertText(1, "+"); 78 randomModify.removeText(3, 1); 79 80 randomModify.clearDocument(); 81 82 randomModify.insertText(0, "+--+--"); 86 randomModify.removeText(2, 1); 87 88 randomModify.clearDocument(); 89 90 randomModify.insertText(0, "-+--"); 94 randomModify.removeText(1, 1); 95 96 randomModify.clearDocument(); 97 98 randomModify.insertText(0, "-+-++--"); 100 randomModify.removeText(1, 4); 101 102 randomModify.clearDocument(); 103 104 randomModify.insertText(0, "-+-+ --"); 108 randomModify.removeText(3, 2); 109 110 randomModify.clearDocument(); 111 112 113 FixedTextDescriptor[] fixedTexts = new FixedTextDescriptor[] { 115 FixedTextDescriptor.create("-+--+-+", 0.2), 116 FixedTextDescriptor.create("+-", 0.2), 117 FixedTextDescriptor.create("-+", 0.2), 118 }; 119 120 RandomCharDescriptor[] regularChars = new RandomCharDescriptor[] { 121 RandomCharDescriptor.letter(0.3), 122 RandomCharDescriptor.space(0.3), 123 RandomCharDescriptor.lf(0.3), 124 RandomCharDescriptor.chars(new char[] { '+', '-', '*', '/'}, 0.3), 125 }; 126 127 RandomCharDescriptor[] plusMinusChars = new RandomCharDescriptor[] { 128 RandomCharDescriptor.chars(new char[] { '+', '-' }, 0.3), 129 RandomCharDescriptor.space(0.1), 131 }; 132 133 RandomTextProvider regularTextProvider = new RandomTextProvider(regularChars, fixedTexts); 134 RandomTextProvider plusMinusTextProvider = new RandomTextProvider(plusMinusChars, fixedTexts); 135 136 RandomTextProvider textProvider = plusMinusTextProvider; 137 138 randomModify.test( 139 new RandomModifyDescriptor[] { 140 new RandomModifyDescriptor(200, plusMinusTextProvider, 141 0.2, 0.2, 0.1, 142 0.2, 0.2, 143 0.0, 0.0), } 145 ); 146 147 randomModify.test( 148 new RandomModifyDescriptor[] { 149 new RandomModifyDescriptor(200, regularTextProvider, 150 0.4, 0.2, 0.2, 151 0.1, 0.1, 152 0.0, 0.0), new RandomModifyDescriptor(200, regularTextProvider, 154 0.2, 0.2, 0.1, 155 0.4, 0.3, 156 0.0, 0.0), } 158 ); 159 } 160 161 } 162 | Popular Tags |