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

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

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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-profile-generator.cc ('k') | test/cctest/test-spaces.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
52 #if V8_TARGET_ARCH_MIPS 57 #if V8_TARGET_ARCH_MIPS
53 #include "mips/assembler-mips.h" 58 #include "mips/assembler-mips.h"
54 #include "mips/macro-assembler-mips.h" 59 #include "mips/macro-assembler-mips.h"
55 #include "mips/regexp-macro-assembler-mips.h" 60 #include "mips/regexp-macro-assembler-mips.h"
56 #endif 61 #endif
57 #if V8_TARGET_ARCH_X64 62 #if V8_TARGET_ARCH_X64
58 #include "x64/assembler-x64.h" 63 #include "x64/assembler-x64.h"
59 #include "x64/macro-assembler-x64.h" 64 #include "x64/macro-assembler-x64.h"
60 #include "x64/regexp-macro-assembler-x64.h" 65 #include "x64/regexp-macro-assembler-x64.h"
61 #endif 66 #endif
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 static bool IsDigit(uc16 c) { 442 static bool IsDigit(uc16 c) {
438 return ('0' <= c && c <= '9'); 443 return ('0' <= c && c <= '9');
439 } 444 }
440 445
441 446
442 static bool NotDigit(uc16 c) { 447 static bool NotDigit(uc16 c) {
443 return !IsDigit(c); 448 return !IsDigit(c);
444 } 449 }
445 450
446 451
447 static bool IsWhiteSpace(uc16 c) { 452 static bool IsWhiteSpaceOrLineTerminator(uc16 c) {
448 switch (c) { 453 // According to ECMA 5.1, 15.10.2.12 the CharacterClassEscape \s includes
449 case 0x09: 454 // WhiteSpace (7.2) and LineTerminator (7.3) values.
450 case 0x0A: 455 return v8::internal::WhiteSpaceOrLineTerminator::Is(c);
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 }
463 } 456 }
464 457
465 458
466 static bool NotWhiteSpace(uc16 c) { 459 static bool NotWhiteSpaceNorLineTermiantor(uc16 c) {
467 return !IsWhiteSpace(c); 460 return !IsWhiteSpaceOrLineTerminator(c);
468 } 461 }
469 462
470 463
471 static bool NotWord(uc16 c) { 464 static bool NotWord(uc16 c) {
472 return !IsRegExpWord(c); 465 return !IsRegExpWord(c);
473 } 466 }
474 467
475 468
476 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) { 469 static void TestCharacterClassEscapes(uc16 c, bool (pred)(uc16 c)) {
477 Zone zone(CcTest::i_isolate()); 470 Zone zone(CcTest::i_isolate());
478 ZoneList<CharacterRange>* ranges = 471 ZoneList<CharacterRange>* ranges =
479 new(&zone) ZoneList<CharacterRange>(2, &zone); 472 new(&zone) ZoneList<CharacterRange>(2, &zone);
480 CharacterRange::AddClassEscape(c, ranges, &zone); 473 CharacterRange::AddClassEscape(c, ranges, &zone);
481 for (unsigned i = 0; i < (1 << 16); i++) { 474 for (unsigned i = 0; i < (1 << 16); i++) {
482 bool in_class = false; 475 bool in_class = false;
483 for (int j = 0; !in_class && j < ranges->length(); j++) { 476 for (int j = 0; !in_class && j < ranges->length(); j++) {
484 CharacterRange& range = ranges->at(j); 477 CharacterRange& range = ranges->at(j);
485 in_class = (range.from() <= i && i <= range.to()); 478 in_class = (range.from() <= i && i <= range.to());
486 } 479 }
487 CHECK_EQ(pred(i), in_class); 480 CHECK_EQ(pred(i), in_class);
488 } 481 }
489 } 482 }
490 483
491 484
492 TEST(CharacterClassEscapes) { 485 TEST(CharacterClassEscapes) {
493 v8::internal::V8::Initialize(NULL); 486 v8::internal::V8::Initialize(NULL);
494 TestCharacterClassEscapes('.', IsRegExpNewline); 487 TestCharacterClassEscapes('.', IsRegExpNewline);
495 TestCharacterClassEscapes('d', IsDigit); 488 TestCharacterClassEscapes('d', IsDigit);
496 TestCharacterClassEscapes('D', NotDigit); 489 TestCharacterClassEscapes('D', NotDigit);
497 TestCharacterClassEscapes('s', IsWhiteSpace); 490 TestCharacterClassEscapes('s', IsWhiteSpaceOrLineTerminator);
498 TestCharacterClassEscapes('S', NotWhiteSpace); 491 TestCharacterClassEscapes('S', NotWhiteSpaceNorLineTermiantor);
499 TestCharacterClassEscapes('w', IsRegExpWord); 492 TestCharacterClassEscapes('w', IsRegExpWord);
500 TestCharacterClassEscapes('W', NotWord); 493 TestCharacterClassEscapes('W', NotWord);
501 } 494 }
502 495
503 496
504 static RegExpNode* Compile(const char* input, 497 static RegExpNode* Compile(const char* input,
505 bool multiline, 498 bool multiline,
506 bool is_ascii, 499 bool is_ascii,
507 Zone* zone) { 500 Zone* zone) {
508 V8::Initialize(NULL); 501 V8::Initialize(NULL);
(...skipping 23 matching lines...) Expand all
532 bool multiline, 525 bool multiline,
533 bool is_ascii, 526 bool is_ascii,
534 bool dot_output = false) { 527 bool dot_output = false) {
535 v8::HandleScope scope(CcTest::isolate()); 528 v8::HandleScope scope(CcTest::isolate());
536 Zone zone(CcTest::i_isolate()); 529 Zone zone(CcTest::i_isolate());
537 RegExpNode* node = Compile(input, multiline, is_ascii, &zone); 530 RegExpNode* node = Compile(input, multiline, is_ascii, &zone);
538 USE(node); 531 USE(node);
539 #ifdef DEBUG 532 #ifdef DEBUG
540 if (dot_output) { 533 if (dot_output) {
541 RegExpEngine::DotPrint(input, node, false); 534 RegExpEngine::DotPrint(input, node, false);
542 exit(0);
543 } 535 }
544 #endif // DEBUG 536 #endif // DEBUG
545 } 537 }
546 538
547 539
548 class TestConfig { 540 class TestConfig {
549 public: 541 public:
550 typedef int Key; 542 typedef int Key;
551 typedef int Value; 543 typedef int Value;
552 static const int kNoKey; 544 static const int kNoKey;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 687
696 688
697 #ifndef V8_INTERPRETED_REGEXP 689 #ifndef V8_INTERPRETED_REGEXP
698 690
699 #if V8_TARGET_ARCH_IA32 691 #if V8_TARGET_ARCH_IA32
700 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler; 692 typedef RegExpMacroAssemblerIA32 ArchRegExpMacroAssembler;
701 #elif V8_TARGET_ARCH_X64 693 #elif V8_TARGET_ARCH_X64
702 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler; 694 typedef RegExpMacroAssemblerX64 ArchRegExpMacroAssembler;
703 #elif V8_TARGET_ARCH_ARM 695 #elif V8_TARGET_ARCH_ARM
704 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler; 696 typedef RegExpMacroAssemblerARM ArchRegExpMacroAssembler;
697 #elif V8_TARGET_ARCH_A64
698 typedef RegExpMacroAssemblerA64 ArchRegExpMacroAssembler;
705 #elif V8_TARGET_ARCH_MIPS 699 #elif V8_TARGET_ARCH_MIPS
706 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; 700 typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
707 #endif 701 #endif
708 702
709 class ContextInitializer { 703 class ContextInitializer {
710 public: 704 public:
711 ContextInitializer() 705 ContextInitializer()
712 : scope_(CcTest::isolate()), 706 : scope_(CcTest::isolate()),
713 env_(v8::Context::New(CcTest::isolate())) { 707 env_(v8::Context::New(CcTest::isolate())) {
714 env_->Enter(); 708 env_->Enter();
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 ZoneList<CharacterRange> first_only(4, &zone); 1803 ZoneList<CharacterRange> first_only(4, &zone);
1810 ZoneList<CharacterRange> second_only(4, &zone); 1804 ZoneList<CharacterRange> second_only(4, &zone);
1811 ZoneList<CharacterRange> both(4, &zone); 1805 ZoneList<CharacterRange> both(4, &zone);
1812 } 1806 }
1813 1807
1814 1808
1815 TEST(Graph) { 1809 TEST(Graph) {
1816 V8::Initialize(NULL); 1810 V8::Initialize(NULL);
1817 Execute("\\b\\w+\\b", false, true, true); 1811 Execute("\\b\\w+\\b", false, true, true);
1818 } 1812 }
OLDNEW
« no previous file with comments | « test/cctest/test-profile-generator.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698