19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @summary tests RegExp framework (use -Dseed=X to set PRNG seed)
27 * @author Mike McCloskey
28 * @bug 4481568 4482696 4495089 4504687 4527731 4599621 4631553 4619345
29 * 4630911 4672616 4711773 4727935 4750573 4792284 4803197 4757029 4808962
30 * 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476
31 * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
32 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
33 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
34 * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590
35 * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
36 * 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895
37 * 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706
38 * 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812
39 * 8216332 8214245
40 *
41 * @library /test/lib
42 * @library /lib/testlibrary/java/lang
43 * @build jdk.test.lib.RandomFactory
44 * @run main RegExTest
45 * @key randomness
46 */
47
48 import java.io.BufferedReader;
49 import java.io.ByteArrayInputStream;
50 import java.io.ByteArrayOutputStream;
51 import java.io.File;
52 import java.io.FileInputStream;
53 import java.io.InputStreamReader;
54 import java.io.ObjectInputStream;
55 import java.io.ObjectOutputStream;
56 import java.math.BigInteger;
57 import java.nio.CharBuffer;
58 import java.nio.file.Files;
59 import java.nio.file.Path;
178 unicodePropertiesTest();
179 unicodeHexNotationTest();
180 unicodeClassesTest();
181 unicodeCharacterNameTest();
182 horizontalAndVerticalWSTest();
183 linebreakTest();
184 branchTest();
185 groupCurlyNotFoundSuppTest();
186 groupCurlyBackoffTest();
187 patternAsPredicate();
188 patternAsMatchPredicate();
189 invalidFlags();
190 embeddedFlags();
191 grapheme();
192 expoBacktracking();
193 invalidGroupName();
194 illegalRepetitionRange();
195 surrogatePairWithCanonEq();
196 lineBreakWithQuantifier();
197 caseInsensitivePMatch();
198
199 if (failure) {
200 throw new
201 RuntimeException("RegExTest failed, 1st failure: " +
202 firstFailure);
203 } else {
204 System.err.println("OKAY: All tests passed.");
205 }
206 }
207
208 // Utility functions
209
210 private static String getRandomAlphaString(int length) {
211 StringBuffer buf = new StringBuffer(length);
212 for (int i=0; i<length; i++) {
213 char randChar = (char)(97 + generator.nextInt(26));
214 buf.append(randChar);
215 }
216 return buf.toString();
217 }
5137 "[\\p{general_category=Ll}]", "[\\p{IsLowercase}]",
5138 "[\\p{javaLowerCase}]", "[\\p{Upper}]", "[\\p{Lu}]",
5139 "[\\p{IsLu}]", "[\\p{gc=Lu}]",
5140 "[\\p{general_category=Lu}]", "[\\p{IsUppercase}]",
5141 "[\\p{javaUpperCase}]", "[\\p{Lt}]", "[\\p{IsLt}]",
5142 "[\\p{gc=Lt}]", "[\\p{general_category=Lt}]",
5143 "[\\p{IsTitlecase}]", "[\\p{javaTitleCase}]"))
5144 {
5145 if (!Pattern.compile(pattern, Pattern.CASE_INSENSITIVE
5146 | Pattern.UNICODE_CHARACTER_CLASS)
5147 .matcher(input)
5148 .matches())
5149 {
5150 failCount++;
5151 System.err.println("Expected to match: " +
5152 "'" + input + "' =~ /" + pattern + "/");
5153 }
5154 }
5155 }
5156 report("caseInsensitivePMatch");
5157 }
5158 }
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @summary tests RegExp framework (use -Dseed=X to set PRNG seed)
27 * @author Mike McCloskey
28 * @bug 4481568 4482696 4495089 4504687 4527731 4599621 4631553 4619345
29 * 4630911 4672616 4711773 4727935 4750573 4792284 4803197 4757029 4808962
30 * 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476
31 * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
32 * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
33 * 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
34 * 7067045 7014640 7189363 8007395 8013252 8013254 8012646 8023647 6559590
35 * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819
36 * 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895
37 * 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706
38 * 8194667 8197462 8184692 8221431 8224789 8228352 8230829 8236034 8235812
39 * 8216332 8214245 8237599
40 *
41 * @library /test/lib
42 * @library /lib/testlibrary/java/lang
43 * @build jdk.test.lib.RandomFactory
44 * @run main RegExTest
45 * @key randomness
46 */
47
48 import java.io.BufferedReader;
49 import java.io.ByteArrayInputStream;
50 import java.io.ByteArrayOutputStream;
51 import java.io.File;
52 import java.io.FileInputStream;
53 import java.io.InputStreamReader;
54 import java.io.ObjectInputStream;
55 import java.io.ObjectOutputStream;
56 import java.math.BigInteger;
57 import java.nio.CharBuffer;
58 import java.nio.file.Files;
59 import java.nio.file.Path;
178 unicodePropertiesTest();
179 unicodeHexNotationTest();
180 unicodeClassesTest();
181 unicodeCharacterNameTest();
182 horizontalAndVerticalWSTest();
183 linebreakTest();
184 branchTest();
185 groupCurlyNotFoundSuppTest();
186 groupCurlyBackoffTest();
187 patternAsPredicate();
188 patternAsMatchPredicate();
189 invalidFlags();
190 embeddedFlags();
191 grapheme();
192 expoBacktracking();
193 invalidGroupName();
194 illegalRepetitionRange();
195 surrogatePairWithCanonEq();
196 lineBreakWithQuantifier();
197 caseInsensitivePMatch();
198 surrogatePairOverlapRegion();
199
200 if (failure) {
201 throw new
202 RuntimeException("RegExTest failed, 1st failure: " +
203 firstFailure);
204 } else {
205 System.err.println("OKAY: All tests passed.");
206 }
207 }
208
209 // Utility functions
210
211 private static String getRandomAlphaString(int length) {
212 StringBuffer buf = new StringBuffer(length);
213 for (int i=0; i<length; i++) {
214 char randChar = (char)(97 + generator.nextInt(26));
215 buf.append(randChar);
216 }
217 return buf.toString();
218 }
5138 "[\\p{general_category=Ll}]", "[\\p{IsLowercase}]",
5139 "[\\p{javaLowerCase}]", "[\\p{Upper}]", "[\\p{Lu}]",
5140 "[\\p{IsLu}]", "[\\p{gc=Lu}]",
5141 "[\\p{general_category=Lu}]", "[\\p{IsUppercase}]",
5142 "[\\p{javaUpperCase}]", "[\\p{Lt}]", "[\\p{IsLt}]",
5143 "[\\p{gc=Lt}]", "[\\p{general_category=Lt}]",
5144 "[\\p{IsTitlecase}]", "[\\p{javaTitleCase}]"))
5145 {
5146 if (!Pattern.compile(pattern, Pattern.CASE_INSENSITIVE
5147 | Pattern.UNICODE_CHARACTER_CLASS)
5148 .matcher(input)
5149 .matches())
5150 {
5151 failCount++;
5152 System.err.println("Expected to match: " +
5153 "'" + input + "' =~ /" + pattern + "/");
5154 }
5155 }
5156 }
5157 report("caseInsensitivePMatch");
5158 }
5159
5160 // This test is for 8237599
5161 private static void surrogatePairOverlapRegion() {
5162 String input = "\ud801\udc37";
5163
5164 Pattern p = Pattern.compile(".+");
5165 Matcher m = p.matcher(input);
5166 m.region(0, 1);
5167
5168 boolean ok = m.find();
5169 if (!ok || !m.group(0).equals(input.substring(0, 1)))
5170 {
5171 failCount++;
5172 System.out.println("Input \"" + input + "\".substr(0, 1)" +
5173 " expected to match pattern \"" + p + "\"");
5174 if (ok) {
5175 System.out.println("group(0): \"" + m.group(0) + "\"");
5176 }
5177 } else if (!m.hitEnd()) {
5178 failCount++;
5179 System.out.println("Expected m.hitEnd() == true");
5180 }
5181
5182 p = Pattern.compile(".*(.)");
5183 m = p.matcher(input);
5184 m.region(1, 2);
5185
5186 ok = m.find();
5187 if (!ok || !m.group(0).equals(input.substring(1, 2))
5188 || !m.group(1).equals(input.substring(1, 2)))
5189 {
5190 failCount++;
5191 System.out.println("Input \"" + input + "\".substr(1, 2)" +
5192 " expected to match pattern \"" + p + "\"");
5193 if (ok) {
5194 System.out.println("group(0): \"" + m.group(0) + "\"");
5195 System.out.println("group(1): \"" + m.group(1) + "\"");
5196 }
5197 }
5198 report("surrogatePairOverlapRegion");
5199 }
5200 }
|