OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // And one more time, just to be certain. | 598 // And one more time, just to be certain. |
599 log = []; | 599 log = []; |
600 re.lastIndex = fakeLastIndex; | 600 re.lastIndex = fakeLastIndex; |
601 result = re.exec(fakeString); | 601 result = re.exec(fakeString); |
602 assertEquals(["str"], result); | 602 assertEquals(["str"], result); |
603 assertEquals(["ts", "li"], log); | 603 assertEquals(["ts", "li"], log); |
604 | 604 |
605 | 605 |
606 // Check that properties of RegExp have the correct permissions. | 606 // Check that properties of RegExp have the correct permissions. |
607 var re = /x/g; | 607 var re = /x/g; |
608 var desc = Object.getOwnPropertyDescriptor(re, "global"); | 608 var desc = Object.getOwnPropertyDescriptor(re.__proto__, "global"); |
609 assertEquals(true, desc.value); | 609 assertInstanceof(desc.get, Function); |
610 assertEquals(false, desc.configurable); | 610 assertEquals(true, desc.configurable); |
611 assertEquals(false, desc.enumerable); | 611 assertEquals(false, desc.enumerable); |
612 assertEquals(false, desc.writable); | 612 |
| 613 desc = Object.getOwnPropertyDescriptor(re.__proto__, "multiline"); |
| 614 assertInstanceof(desc.get, Function); |
| 615 assertEquals(true, desc.configurable); |
| 616 assertEquals(false, desc.enumerable); |
| 617 |
| 618 desc = Object.getOwnPropertyDescriptor(re.__proto__, "ignoreCase"); |
| 619 assertInstanceof(desc.get, Function); |
| 620 assertEquals(true, desc.configurable); |
| 621 assertEquals(false, desc.enumerable); |
| 622 |
| 623 desc = Object.getOwnPropertyDescriptor(re, "global"); |
| 624 assertEquals(undefined, desc); |
613 | 625 |
614 desc = Object.getOwnPropertyDescriptor(re, "multiline"); | 626 desc = Object.getOwnPropertyDescriptor(re, "multiline"); |
615 assertEquals(false, desc.value); | 627 assertEquals(undefined, desc); |
616 assertEquals(false, desc.configurable); | |
617 assertEquals(false, desc.enumerable); | |
618 assertEquals(false, desc.writable); | |
619 | 628 |
620 desc = Object.getOwnPropertyDescriptor(re, "ignoreCase"); | 629 desc = Object.getOwnPropertyDescriptor(re, "ignoreCase"); |
621 assertEquals(false, desc.value); | 630 assertEquals(undefined, desc); |
622 assertEquals(false, desc.configurable); | |
623 assertEquals(false, desc.enumerable); | |
624 assertEquals(false, desc.writable); | |
625 | 631 |
626 desc = Object.getOwnPropertyDescriptor(re, "lastIndex"); | 632 desc = Object.getOwnPropertyDescriptor(re, "lastIndex"); |
627 assertEquals(0, desc.value); | 633 assertEquals(0, desc.value); |
628 assertEquals(false, desc.configurable); | 634 assertEquals(false, desc.configurable); |
629 assertEquals(false, desc.enumerable); | 635 assertEquals(false, desc.enumerable); |
630 assertEquals(true, desc.writable); | 636 assertEquals(true, desc.writable); |
631 | 637 |
632 | 638 |
633 // Check that end-anchored regexps are optimized correctly. | 639 // Check that end-anchored regexps are optimized correctly. |
634 var re = /(?:a|bc)g$/; | 640 var re = /(?:a|bc)g$/; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 // Test that RegExp.prototype.toString() throws TypeError for | 715 // Test that RegExp.prototype.toString() throws TypeError for |
710 // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). | 716 // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). |
711 assertThrows("RegExp.prototype.toString.call(null)", TypeError); | 717 assertThrows("RegExp.prototype.toString.call(null)", TypeError); |
712 assertThrows("RegExp.prototype.toString.call(0)", TypeError); | 718 assertThrows("RegExp.prototype.toString.call(0)", TypeError); |
713 assertThrows("RegExp.prototype.toString.call('')", TypeError); | 719 assertThrows("RegExp.prototype.toString.call('')", TypeError); |
714 assertThrows("RegExp.prototype.toString.call(false)", TypeError); | 720 assertThrows("RegExp.prototype.toString.call(false)", TypeError); |
715 assertThrows("RegExp.prototype.toString.call(true)", TypeError); | 721 assertThrows("RegExp.prototype.toString.call(true)", TypeError); |
716 assertThrows("RegExp.prototype.toString.call([])", TypeError); | 722 assertThrows("RegExp.prototype.toString.call([])", TypeError); |
717 assertThrows("RegExp.prototype.toString.call({})", TypeError); | 723 assertThrows("RegExp.prototype.toString.call({})", TypeError); |
718 assertThrows("RegExp.prototype.toString.call(function(){})", TypeError); | 724 assertThrows("RegExp.prototype.toString.call(function(){})", TypeError); |
OLD | NEW |