Index: test/mjsunit/regexp.js |
diff --git a/test/mjsunit/regexp.js b/test/mjsunit/regexp.js |
index 59c3ba8d2874f08dff99445f2de61257a80b4add..b57b86d2d88bbf2a882e0116e3c8be38b13f3cd7 100644 |
--- a/test/mjsunit/regexp.js |
+++ b/test/mjsunit/regexp.js |
@@ -110,6 +110,44 @@ assertFalse(re.test("\\]")); |
assertFalse(re.test("\x03]")); // I.e., read as \cc |
+// Test that we handle \s and \S correctly inside some bizarre |
+// character classes. |
+re = /[\s-:]/; |
+assertTrue(re.test('-')); |
+assertTrue(re.test(':')); |
+assertTrue(re.test(' ')); |
+assertTrue(re.test('\t')); |
+assertTrue(re.test('\n')); |
+assertFalse(re.test('a')); |
+assertFalse(re.test('Z')); |
+ |
+re = /[\S-:]/; |
+assertTrue(re.test('-')); |
+assertTrue(re.test(':')); |
+assertFalse(re.test(' ')); |
+assertFalse(re.test('\t')); |
+assertFalse(re.test('\n')); |
+assertTrue(re.test('a')); |
+assertTrue(re.test('Z')); |
+ |
+re = /[^\s-:]/; |
+assertFalse(re.test('-')); |
+assertFalse(re.test(':')); |
+assertFalse(re.test(' ')); |
+assertFalse(re.test('\t')); |
+assertFalse(re.test('\n')); |
+assertTrue(re.test('a')); |
+assertTrue(re.test('Z')); |
+ |
+re = /[^\S-:]/; |
+assertFalse(re.test('-')); |
+assertFalse(re.test(':')); |
+assertTrue(re.test(' ')); |
+assertTrue(re.test('\t')); |
+assertTrue(re.test('\n')); |
+assertFalse(re.test('a')); |
+assertFalse(re.test('Z')); |
+ |
re = /[\s]/; |
assertFalse(re.test('-')); |
assertFalse(re.test(':')); |
@@ -609,47 +647,3 @@ assertEquals(4, re.exec("zimzamzumba").index); |
assertEquals(["bc"], re.exec("zimzomzumbc")); |
assertFalse(re.test("c")); |
assertFalse(re.test("")); |
- |
- |
-function testInvalidRange(str) { |
- try { |
- RegExp(str).test("x"); |
- } catch (e) { |
- return; |
- } |
- assetUnreachable("Allowed invalid range in " + str); |
-} |
- |
-function testValidRange(str) { |
- try { |
- RegExp(str).test("x"); |
- } catch (e) { |
- assertUnreachable("Shouldn't fail parsing: " + str + ", was: " + e); |
- } |
-} |
- |
-testInvalidRange("[\\d-z]"); |
-testInvalidRange("[z-\\d]"); |
-testInvalidRange("[\\d-\\d]"); |
-testInvalidRange("[z-x]"); // Larger value first. |
-testInvalidRange("[x-\\d-\\d]"); |
- |
-testValidRange("[x-z]"); |
-testValidRange("[!--\d]"); // Second "-" is end of range. |
-testValidRange("[\d-]"); |
-testValidRange("[-\d]"); |
-testValidRange("[-\d-]"); |
-testValidRange("[^-\d-]"); |
-testValidRange("[^-\d-]"); |
-testValidRange("[0-9-\w]"); |
- |
-// Escaped dashes do not count as range operators. |
-testValidRange("[\\d\\-z]"); |
-testValidRange("[z\\-\\d]"); |
-testValidRange("[\\d\\-\\d]"); |
-testValidRange("[z\\-x]"); |
-testValidRange("[x\\-\\d\\-\\d]"); |
- |
- |
- |
- |