| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // Some tests from the Mozilla tests, where our behavior differs from | 87 // Some tests from the Mozilla tests, where our behavior differs from |
| 88 // SpiderMonkey. | 88 // SpiderMonkey. |
| 89 // From ecma_3/RegExp/regress-334158.js | 89 // From ecma_3/RegExp/regress-334158.js |
| 90 assertTrue(/\ca/.test( "\x01" )); | 90 assertTrue(/\ca/.test( "\x01" )); |
| 91 assertFalse(/\ca/.test( "\\ca" )); | 91 assertFalse(/\ca/.test( "\\ca" )); |
| 92 // Passes in KJS, fails in IrregularExpressions. | 92 // Passes in KJS, fails in IrregularExpressions. |
| 93 // See http://code.google.com/p/v8/issues/detail?id=152 | 93 // See http://code.google.com/p/v8/issues/detail?id=152 |
| 94 //assertTrue(/\c[a/]/.test( "\x1ba/]" )); | 94 //assertTrue(/\c[a/]/.test( "\x1ba/]" )); |
| 95 | 95 |
| 96 | 96 |
| 97 // Test \c in character class |
| 98 re = /^[\cM]$/; |
| 99 assertTrue(re.test("\r")); |
| 100 assertFalse(re.test("M")); |
| 101 assertFalse(re.test("c")); |
| 102 assertFalse(re.test("\\")); |
| 103 assertFalse(re.test("\x03")); // I.e., read as \cc |
| 104 |
| 105 re = /^[\c]]$/; |
| 106 assertTrue(re.test("c]")); |
| 107 assertFalse(re.test("\\]")); |
| 108 assertFalse(re.test("\x1d")); // ']' & 0x1f |
| 109 assertFalse(re.test("\\]")); |
| 110 assertFalse(re.test("\x03]")); // I.e., read as \cc |
| 111 |
| 112 |
| 97 // Test that we handle \s and \S correctly inside some bizarre | 113 // Test that we handle \s and \S correctly inside some bizarre |
| 98 // character classes. | 114 // character classes. |
| 99 re = /[\s-:]/; | 115 re = /[\s-:]/; |
| 100 assertTrue(re.test('-')); | 116 assertTrue(re.test('-')); |
| 101 assertTrue(re.test(':')); | 117 assertTrue(re.test(':')); |
| 102 assertTrue(re.test(' ')); | 118 assertTrue(re.test(' ')); |
| 103 assertTrue(re.test('\t')); | 119 assertTrue(re.test('\t')); |
| 104 assertTrue(re.test('\n')); | 120 assertTrue(re.test('\n')); |
| 105 assertFalse(re.test('a')); | 121 assertFalse(re.test('a')); |
| 106 assertFalse(re.test('Z')); | 122 assertFalse(re.test('Z')); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 325 |
| 310 // Test that merging of quick test masks gets it right. | 326 // Test that merging of quick test masks gets it right. |
| 311 assertFalse(/x([0-7]%%x|[0-6]%%y)/.test('x7%%y'), 'qt'); | 327 assertFalse(/x([0-7]%%x|[0-6]%%y)/.test('x7%%y'), 'qt'); |
| 312 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy7%%%y'), 'qt2'); | 328 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy7%%%y'), 'qt2'); |
| 313 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt3'); | 329 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt3'); |
| 314 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt4'); | 330 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt4'); |
| 315 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt5'); | 331 assertFalse(/()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)/.test('xy%%%y'), 'qt5'); |
| 316 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt6'); | 332 assertFalse(/()x\1y([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt6'); |
| 317 assertFalse(/xy([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt7'); | 333 assertFalse(/xy([0-7]%%%x|[0-6]%%%y)/.test('xy7%%%y'), 'qt7'); |
| 318 assertFalse(/x([0-7]%%%x|[0-6]%%%y)/.test('x7%%%y'), 'qt8'); | 334 assertFalse(/x([0-7]%%%x|[0-6]%%%y)/.test('x7%%%y'), 'qt8'); |
| 335 |
| 336 |
| 337 // Don't hang on this one. |
| 338 /[^\xfe-\xff]*/.test(""); |
| OLD | NEW |