| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 assertFalse(/foo$(?!bar)/.test("football"), "football9"); | 256 assertFalse(/foo$(?!bar)/.test("football"), "football9"); |
| 257 assertTrue(/(x?)foo$\1/.test("foo"), "football10"); | 257 assertTrue(/(x?)foo$\1/.test("foo"), "football10"); |
| 258 assertTrue(/foo$(?=(ball)?)/.test("foo"), "football11"); | 258 assertTrue(/foo$(?=(ball)?)/.test("foo"), "football11"); |
| 259 assertTrue(/foo$(?!bar)/.test("foo"), "football12"); | 259 assertTrue(/foo$(?!bar)/.test("foo"), "football12"); |
| 260 | 260 |
| 261 // Check that the back reference has two successors. See | 261 // Check that the back reference has two successors. See |
| 262 // BackReferenceNode::PropagateForward. | 262 // BackReferenceNode::PropagateForward. |
| 263 assertFalse(/f(o)\b\1/.test('foo')); | 263 assertFalse(/f(o)\b\1/.test('foo')); |
| 264 assertTrue(/f(o)\B\1/.test('foo')); | 264 assertTrue(/f(o)\B\1/.test('foo')); |
| 265 | 265 |
| 266 // Back-reference, ignore case: |
| 267 // ASCII |
| 268 assertEquals("xaAx,a", String(/x(a)\1x/i.exec("xaAx")), "\\1 ASCII"); |
| 269 assertFalse(/x(...)\1/i.test("xaaaaa"), "\\1 ASCII, string short"); |
| 270 assertTrue(/x((?:))\1\1x/i.test("xx"), "\\1 empty, ASCII"); |
| 271 assertTrue(/x(?:...|(...))\1x/i.test("xabcx"), "\\1 uncaptured, ASCII"); |
| 272 assertTrue(/x(?:...|(...))\1x/i.test("xabcABCx"), "\\1 backtrack, ASCII"); |
| 273 assertEquals("xaBcAbCABCx,aBc", |
| 274 String(/x(...)\1\1x/i.exec("xaBcAbCABCx")), |
| 275 "\\1\\1 ASCII"); |
| 276 |
| 277 for (var i = 0; i < 128; i++) { |
| 278 var testName = "(.)\\1 ~ " + i + "," + (i^0x20); |
| 279 var test = /^(.)\1$/i.test(String.fromCharCode(i, i ^ 0x20)) |
| 280 var c = String.fromCharCode(i); |
| 281 if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) { |
| 282 assertTrue(test, testName); |
| 283 } else { |
| 284 assertFalse(test, testName); |
| 285 } |
| 286 } |
| 287 |
| 288 // UC16 |
| 289 // Characters used: |
| 290 // "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, lamda |
| 291 assertEquals("x\u03a3\u03c3x,\u03a3", |
| 292 String(/x(.)\1x/i.exec("x\u03a3\u03c3x")), "\\1 UC16"); |
| 293 assertFalse(/x(...)\1/i.test("x\u03a3\u03c2\u03c3\u03c2\u03c3"), |
| 294 "\\1 ASCII, string short"); |
| 295 assertTrue(/\u03a3((?:))\1\1x/i.test("\u03c2x"), "\\1 empty, UC16"); |
| 296 assertTrue(/x(?:...|(...))\1x/i.test("x\u03a3\u03c2\u03c3x"), |
| 297 "\\1 uncaptured, UC16"); |
| 298 assertTrue(/x(?:...|(...))\1x/i.test("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"), |
| 299 "\\1 backtrack, UC16"); |
| 300 var longUC16String = "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb"; |
| 301 assertEquals(longUC16String + "," + longUC16String.substring(1,4), |
| 302 String(/x(...)\1\1/i.exec(longUC16String)), |
| 303 "\\1\\1 UC16"); |
| 304 |
| 266 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end"); | 305 assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end"); |
| OLD | NEW |