Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: test/mjsunit/regexp.js

Issue 2793313002: [regexp] Add tests for recent changes in Annex B (Closed)
Patch Set: Rebase and address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 assertEquals(-0, re.lastIndex); 757 assertEquals(-0, re.lastIndex);
758 "abc".search(re); 758 "abc".search(re);
759 assertEquals(-0, re.lastIndex); 759 assertEquals(-0, re.lastIndex);
760 760
761 var re = /./; 761 var re = /./;
762 re.exec = function(str) { assertEquals(0, re.lastIndex); return []; } 762 re.exec = function(str) { assertEquals(0, re.lastIndex); return []; }
763 re.lastIndex = NaN; 763 re.lastIndex = NaN;
764 assertEquals(NaN, re.lastIndex); 764 assertEquals(NaN, re.lastIndex);
765 "abc".search(re); 765 "abc".search(re);
766 assertEquals(NaN, re.lastIndex); 766 assertEquals(NaN, re.lastIndex);
767
768 // Annex B changes: https://github.com/tc39/ecma262/pull/303
769
770 assertThrows("/{1}/", SyntaxError);
771 assertTrue(/^{*$/.test("{{{"));
772 assertTrue(/^}*$/.test("}}}"));
773 assertTrue(/]/.test("]"));
774 assertTrue(/^\c%$/.test("\\c%")); // We go into ExtendedPatternCharacter.
775 assertTrue(/^\d%$/.test("2%")); // ... CharacterClassEscape.
776 assertTrue(/^\e%$/.test("e%")); // ... IdentityEscape.
777 assertTrue(/^\ca$/.test("\u{1}")); // ... ControlLetter.
778 assertTrue(/^\cA$/.test("\u{1}")); // ... ControlLetter.
779 assertTrue(/^\c9$/.test("\\c9")); // ... ExtendedPatternCharacter.
780 assertTrue(/^\c$/.test("\\c")); // ... ExtendedPatternCharacter.
781 assertTrue(/^[\c%]*$/.test("\\c%")); // TODO(v8:6201): Not covered by the spec.
782 assertTrue(/^[\c:]*$/.test("\\c:")); // TODO(v8:6201): Not covered by the spec.
783 assertTrue(/^[\c0]*$/.test("\u{10}")); // ... ClassControlLetter.
784 assertTrue(/^[\c1]*$/.test("\u{11}")); // ('0' % 32 == 0x10)
785 assertTrue(/^[\c2]*$/.test("\u{12}"));
786 assertTrue(/^[\c3]*$/.test("\u{13}"));
787 assertTrue(/^[\c4]*$/.test("\u{14}"));
788 assertTrue(/^[\c5]*$/.test("\u{15}"));
789 assertTrue(/^[\c6]*$/.test("\u{16}"));
790 assertTrue(/^[\c7]*$/.test("\u{17}"));
791 assertTrue(/^[\c8]*$/.test("\u{18}"));
792 assertTrue(/^[\c9]*$/.test("\u{19}"));
793 assertTrue(/^[\c_]*$/.test("\u{1F}"));
794 assertTrue(/^[\c11]*$/.test("\u{11}1"));
795 assertTrue(/^[\8]*$/.test("8")); // ... ClassEscape ~~> IdentityEscape.
796 assertTrue(/^[\7]*$/.test("\u{7}")); // ... ClassEscape
797 // ~~> LegacyOctalEscapeSequence.
798 assertTrue(/^[\11]*$/.test("\u{9}"));
799 assertTrue(/^[\111]*$/.test("\u{49}"));
800 assertTrue(/^[\222]*$/.test("\u{92}"));
801 assertTrue(/^[\333]*$/.test("\u{DB}"));
802 assertTrue(/^[\444]*$/.test("\u{24}4"));
803 assertTrue(/^[\d-X]*$/.test("234-X-432")); // CharacterRangeOrUnion.
804 assertTrue(/^[\d-X-Z]*$/.test("234-XZ-432"));
805 assertFalse(/^[\d-X-Z]*$/.test("234-XYZ-432"));
OLDNEW
« no previous file with comments | « src/regexp/regexp-parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698