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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 assertTrue(delete re.someDeletableProperty); | 429 assertTrue(delete re.someDeletableProperty); |
430 re.compile("ri+", "gm"); | 430 re.compile("ri+", "gm"); |
431 | 431 |
432 assertEquals("ri+", re.source); | 432 assertEquals("ri+", re.source); |
433 assertTrue(re.global); | 433 assertTrue(re.global); |
434 assertFalse(re.ignoreCase); | 434 assertFalse(re.ignoreCase); |
435 assertTrue(re.multiline); | 435 assertTrue(re.multiline); |
436 assertEquals(0, re.lastIndex); | 436 assertEquals(0, re.lastIndex); |
437 assertEquals(37, re.someOtherProperty); | 437 assertEquals(37, re.someOtherProperty); |
438 assertEquals(37, re[42]); | 438 assertEquals(37, re[42]); |
| 439 |
| 440 // Test boundary-checks. |
| 441 function assertRegExpTest(re, input, test) { |
| 442 assertEquals(test, re.test(input), "test:" + re + ":" + input); |
| 443 } |
| 444 |
| 445 assertRegExpTest(/b\b/, "b", true); |
| 446 assertRegExpTest(/b\b$/, "b", true); |
| 447 assertRegExpTest(/\bb/, "b", true); |
| 448 assertRegExpTest(/^\bb/, "b", true); |
| 449 assertRegExpTest(/,\b/, ",", false); |
| 450 assertRegExpTest(/,\b$/, ",", false); |
| 451 assertRegExpTest(/\b,/, ",", false); |
| 452 assertRegExpTest(/^\b,/, ",", false); |
| 453 |
| 454 assertRegExpTest(/b\B/, "b", false); |
| 455 assertRegExpTest(/b\B$/, "b", false); |
| 456 assertRegExpTest(/\Bb/, "b", false); |
| 457 assertRegExpTest(/^\Bb/, "b", false); |
| 458 assertRegExpTest(/,\B/, ",", true); |
| 459 assertRegExpTest(/,\B$/, ",", true); |
| 460 assertRegExpTest(/\B,/, ",", true); |
| 461 assertRegExpTest(/^\B,/, ",", true); |
| 462 |
| 463 assertRegExpTest(/b\b/, "b,", true); |
| 464 assertRegExpTest(/b\b/, "ba", false); |
| 465 assertRegExpTest(/b\B/, "b,", false); |
| 466 assertRegExpTest(/b\B/, "ba", true); |
| 467 |
| 468 assertRegExpTest(/b\Bb/, "bb", true); |
| 469 assertRegExpTest(/b\bb/, "bb", false); |
| 470 |
| 471 assertRegExpTest(/b\b[,b]/, "bb", false); |
| 472 assertRegExpTest(/b\B[,b]/, "bb", true); |
| 473 assertRegExpTest(/b\b[,b]/, "b,", true); |
| 474 assertRegExpTest(/b\B[,b]/, "b,", false); |
| 475 |
| 476 assertRegExpTest(/[,b]\bb/, "bb", false); |
| 477 assertRegExpTest(/[,b]\Bb/, "bb", true); |
| 478 assertRegExpTest(/[,b]\bb/, ",b", true); |
| 479 assertRegExpTest(/[,b]\Bb/, ",b", false); |
| 480 |
| 481 assertRegExpTest(/[,b]\b[,b]/, "bb", false); |
| 482 assertRegExpTest(/[,b]\B[,b]/, "bb", true); |
| 483 assertRegExpTest(/[,b]\b[,b]/, ",b", true); |
| 484 assertRegExpTest(/[,b]\B[,b]/, ",b", false); |
| 485 assertRegExpTest(/[,b]\b[,b]/, "b,", true); |
| 486 assertRegExpTest(/[,b]\B[,b]/, "b,", false); |
OLD | NEW |