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

Side by Side Diff: test/cctest/test-regexp.cc

Issue 178223011: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-platform.cc ('k') | test/cctest/test-symbols.cc » ('j') | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #ifdef V8_INTERPRETED_REGEXP 42 #ifdef V8_INTERPRETED_REGEXP
43 #include "interpreter-irregexp.h" 43 #include "interpreter-irregexp.h"
44 #else // V8_INTERPRETED_REGEXP 44 #else // V8_INTERPRETED_REGEXP
45 #include "macro-assembler.h" 45 #include "macro-assembler.h"
46 #include "code.h" 46 #include "code.h"
47 #if V8_TARGET_ARCH_ARM 47 #if V8_TARGET_ARCH_ARM
48 #include "arm/assembler-arm.h" 48 #include "arm/assembler-arm.h"
49 #include "arm/macro-assembler-arm.h" 49 #include "arm/macro-assembler-arm.h"
50 #include "arm/regexp-macro-assembler-arm.h" 50 #include "arm/regexp-macro-assembler-arm.h"
51 #endif 51 #endif
52 #if V8_TARGET_ARCH_A64
53 #include "a64/assembler-a64.h"
54 #include "a64/macro-assembler-a64.h"
55 #include "a64/regexp-macro-assembler-a64.h"
56 #endif
57 #if V8_TARGET_ARCH_MIPS 52 #if V8_TARGET_ARCH_MIPS
58 #include "mips/assembler-mips.h" 53 #include "mips/assembler-mips.h"
59 #include "mips/macro-assembler-mips.h" 54 #include "mips/macro-assembler-mips.h"
60 #include "mips/regexp-macro-assembler-mips.h" 55 #include "mips/regexp-macro-assembler-mips.h"
61 #endif 56 #endif
62 #if V8_TARGET_ARCH_X64 57 #if V8_TARGET_ARCH_X64
63 #include "x64/assembler-x64.h" 58 #include "x64/assembler-x64.h"
64 #include "x64/macro-assembler-x64.h" 59 #include "x64/macro-assembler-x64.h"
65 #include "x64/regexp-macro-assembler-x64.h" 60 #include "x64/regexp-macro-assembler-x64.h"
66 #endif 61 #endif
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 static bool IsDigit(uc16 c) { 437 static bool IsDigit(uc16 c) {
443 return ('0' <= c && c <= '9'); 438 return ('0' <= c && c <= '9');
444 } 439 }
445 440
446 441
447 static bool NotDigit(uc16 c) { 442 static bool NotDigit(uc16 c) {
448 return !IsDigit(c); 443 return !IsDigit(c);
449 } 444 }
450 445
451 446
452 static bool IsWhiteSpaceOrLineTerminator(uc16 c) { 447 static bool IsWhiteSpace(uc16 c) {
453 // According to ECMA 5.1, 15.10.2.12 the CharacterClassEscape \s includes 448 switch (c) {
454 // WhiteSpace (7.2) and LineTerminator (7.3) values. 449 case 0x09:
455 return v8::internal::WhiteSpaceOrLineTerminator::Is(c); 450 case 0x0A:
451 case 0x0B:
452 case 0x0C:
453 case 0x0d:
454 case 0x20:
455 case 0xA0:
456 case 0x2028:
457 case 0x2029:
458 case 0xFEFF:
459 return true;
460 default:
461 return unibrow::Space::Is(c);
462 }
456 } 463 }
457 464
458 465
459 static bool NotWhiteSpaceNorLineTermiantor(uc16 c) { 466 static bool NotWhiteSpace(uc16 c) {
460 return !IsWhiteSpaceOrLineTerminator(c); 467 return !IsWhiteSpace(c);
461 } 468 }
462 469
463 470
464 static bool NotWord(uc16 c) { 471 static bool NotWord(uc16 c) {
465 return !IsRegExpWord(c); 472 return !IsRegExpWord(c);
466 } 473 }
467 474
468 475
469 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { 476 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
470 Zone zone(CcTest::i_isolate()); 477 Zone zone(CcTest::i_isolate());
471 ZoneList<CharacterRange>* ranges = 478 ZoneList<CharacterRange>* ranges =
472 new(&zone) ZoneList<CharacterRange>(2, &zone); 479 new(&zone) ZoneList<CharacterRange>(2, &zone);
473 CharacterRange::AddClassEscape(c, ranges, &zone); 480 CharacterRange::AddClassEscape(c, ranges, &zone);
474 for (unsigned i = 0; i < (1 << 16); i++) { 481 for (unsigned i = 0; i < (1 << 16); i++) {
475 bool in_class = false; 482 bool in_class = false;
476 for (int j = 0; !in_class && j < ranges->length(); j++) { 483 for (int j = 0; !in_class && j < ranges->length(); j++) {
477 CharacterRange& range = ranges->at(j); 484 CharacterRange& range = ranges->at(j);
478 in_class = (range.from() <= i && i <= range.to()); 485 in_class = (range.from() <= i && i <= range.to());
479 } 486 }
480 CHECK_EQ(pred(i), in_class); 487 CHECK_EQ(pred(i), in_class);
481 } 488 }
482 } 489 }
483 490
484 491
485 TEST(CharacterClassEscapes) { 492 TEST(CharacterClassEscapes) {
486 v8::internal::V8::Initialize(NULL); 493 v8::internal::V8::Initialize(NULL);
487 TestCharacterClassEscapes('.', IsRegExpNewline); 494 TestCharacterClassEscapes('.', IsRegExpNewline);
488 TestCharacterClassEscapes('d', IsDigit); 495 TestCharacterClassEscapes('d', IsDigit);
489 TestCharacterClassEscapes('D', NotDigit); 496 TestCharacterClassEscapes('D', NotDigit);
490 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator); 497 TestCharacterClassEscapes('s', IsWhiteSpace);
491 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor); 498 TestCharacterClassEscapes('S', NotWhiteSpace);
492 TestCharacterClassEscapes('w', IsRegExpWord); 499 TestCharacterClassEscapes('w', IsRegExpWord);
493 TestCharacterClassEscapes('W', NotWord); 500 TestCharacterClassEscapes('W', NotWord);
494 } 501 }
495 502
496 503
497 static RegExpNode* Compile(const char* input, 504 static RegExpNode* Compile(const char* input,
498 bool multiline, 505 bool multiline,
499 bool is_ascii, 506 bool is_ascii,
500 Zone* zone) { 507 Zone* zone) {
501 V8::Initialize(NULL); 508 V8::Initialize(NULL);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 694
688 695
689 #ifndef V8_INTERPRETED_REGEXP 696 #ifndef V8_INTERPRETED_REGEXP
690 697
691 #if V8_TARGET_ARCH_IA32 698 #if V8_TARGET_ARCH_IA32
692 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler; 699 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler;
693 #elif V8_TARGET_ARCH_X64 700 #elif V8_TARGET_ARCH_X64
694 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; 701 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler;
695 #elif V8_TARGET_ARCH_ARM 702 #elif V8_TARGET_ARCH_ARM
696 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; 703 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler;
697 #elif V8_TARGET_ARCH_A64
698 typedef RegExpMacroAssemblerA64 ArchRegExpMacroAssembler;
699 #elif V8_TARGET_ARCH_MIPS 704 #elif V8_TARGET_ARCH_MIPS
700 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; 705 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
701 #endif 706 #endif
702 707
703 class ContextInitializer { 708 class ContextInitializer {
704 public: 709 public:
705 ContextInitializer() 710 ContextInitializer()
706 : scope_(CcTest::isolate()), 711 : scope_(CcTest::isolate()),
707 env_(v8::Context::New(CcTest::isolate())) { 712 env_(v8::Context::New(CcTest::isolate())) {
708 env_->Enter(); 713 env_->Enter();
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 ZoneList<CharacterRange> first_only(4, &zone); 1808 ZoneList<CharacterRange> first_only(4, &zone);
1804 ZoneList<CharacterRange> second_only(4, &zone); 1809 ZoneList<CharacterRange> second_only(4, &zone);
1805 ZoneList<CharacterRange> both(4, &zone); 1810 ZoneList<CharacterRange> both(4, &zone);
1806 } 1811 }
1807 1812
1808 1813
1809 TEST(Graph) { 1814 TEST(Graph) {
1810 V8::Initialize(NULL); 1815 V8::Initialize(NULL);
1811 Execute("\\b\\w+\\b", false, true, true); 1816 Execute("\\b\\w+\\b", false, true, true);
1812 } 1817 }
OLDNEW
« no previous file with comments | « test/cctest/test-platform.cc ('k') | test/cctest/test-symbols.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698