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

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

Issue 11600: * Rename to Irregexp throughout.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years 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
« src/runtime.cc ('K') | « src/runtime.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 18 matching lines...) Expand all
29 #include <stdlib.h> 29 #include <stdlib.h>
30 #include <set> 30 #include <set>
31 31
32 #include "v8.h" 32 #include "v8.h"
33 33
34 #include "cctest.h" 34 #include "cctest.h"
35 #include "zone-inl.h" 35 #include "zone-inl.h"
36 #include "parser.h" 36 #include "parser.h"
37 #include "ast.h" 37 #include "ast.h"
38 #include "jsregexp-inl.h" 38 #include "jsregexp-inl.h"
39 #include "assembler-re2k.h" 39 #include "assembler-irregexp.h"
40 #include "regexp-macro-assembler.h" 40 #include "regexp-macro-assembler.h"
41 #include "regexp-macro-assembler-re2k.h" 41 #include "regexp-macro-assembler-irregexp.h"
42 #include "regexp-macro-assembler-ia32.h" 42 #include "regexp-macro-assembler-ia32.h"
43 #include "interpreter-re2k.h" 43 #include "interpreter-irregexp.h"
44 44
45 45
46 using namespace v8::internal; 46 using namespace v8::internal;
47 47
48 48
49 static SmartPointer<const char> Parse(const char* input) { 49 static SmartPointer<const char> Parse(const char* input) {
50 v8::HandleScope scope; 50 v8::HandleScope scope;
51 ZoneScope zone_scope(DELETE_ON_EXIT); 51 ZoneScope zone_scope(DELETE_ON_EXIT);
52 FlatStringReader reader(CStrVector(input)); 52 FlatStringReader reader(CStrVector(input));
53 RegExpParseResult result; 53 RegExpParseResult result;
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 is_on = (range[k] <= p && p <= range[k + 1]); 518 is_on = (range[k] <= p && p <= range[k + 1]);
519 CHECK_EQ(is_on, outs->Get(j)); 519 CHECK_EQ(is_on, outs->Get(j));
520 } 520 }
521 } 521 }
522 } 522 }
523 523
524 524
525 TEST(Assembler) { 525 TEST(Assembler) {
526 V8::Initialize(NULL); 526 V8::Initialize(NULL);
527 byte codes[1024]; 527 byte codes[1024];
528 Re2kAssembler assembler(Vector<byte>(codes, 1024)); 528 IrregexpAssembler assembler(Vector<byte>(codes, 1024));
529 #define __ assembler. 529 #define __ assembler.
530 Label advance; 530 Label advance;
531 Label look_for_foo; 531 Label look_for_foo;
532 Label fail; 532 Label fail;
533 __ GoTo(&look_for_foo); 533 __ GoTo(&look_for_foo);
534 __ Bind(&advance); 534 __ Bind(&advance);
535 __ AdvanceCP(1); 535 __ AdvanceCP(1);
536 __ Bind(&look_for_foo); 536 __ Bind(&look_for_foo);
537 __ LoadCurrentChar(0, &fail); 537 __ LoadCurrentChar(0, &fail);
538 __ CheckNotCharacter('f', &advance); 538 __ CheckNotCharacter('f', &advance);
539 __ LoadCurrentChar(1, &fail); 539 __ LoadCurrentChar(1, &fail);
540 __ CheckNotCharacter('o', &advance); 540 __ CheckNotCharacter('o', &advance);
541 __ LoadCurrentChar(2, &fail); 541 __ LoadCurrentChar(2, &fail);
542 __ CheckNotCharacter('o', &advance); 542 __ CheckNotCharacter('o', &advance);
543 __ WriteCurrentPositionToRegister(0); 543 __ WriteCurrentPositionToRegister(0);
544 __ WriteCurrentPositionToRegister(1, 2); 544 __ WriteCurrentPositionToRegister(1, 2);
545 __ Succeed(); 545 __ Succeed();
546 __ Bind(&fail); 546 __ Bind(&fail);
547 __ Fail(); 547 __ Fail();
548 548
549 v8::HandleScope scope; 549 v8::HandleScope scope;
550 Handle<ByteArray> array = Factory::NewByteArray(assembler.length()); 550 Handle<ByteArray> array = Factory::NewByteArray(assembler.length());
551 assembler.Copy(array->GetDataStartAddress()); 551 assembler.Copy(array->GetDataStartAddress());
552 int captures[2]; 552 int captures[2];
553 553
554 Handle<String> f1 = 554 Handle<String> f1 =
555 Factory::NewStringFromAscii(CStrVector("Now is the time")); 555 Factory::NewStringFromAscii(CStrVector("Now is the time"));
556 Handle<String> f1_16 = RegExpImpl::StringToTwoByte(f1); 556 Handle<String> f1_16 = RegExpImpl::StringToTwoByte(f1);
557 CHECK(!Re2kInterpreter::Match(array, f1_16, captures, 0)); 557 CHECK(!IrregexpInterpreter::Match(array, f1_16, captures, 0));
558 558
559 Handle<String> f2 = Factory::NewStringFromAscii(CStrVector("foo bar baz")); 559 Handle<String> f2 = Factory::NewStringFromAscii(CStrVector("foo bar baz"));
560 Handle<String> f2_16 = RegExpImpl::StringToTwoByte(f2); 560 Handle<String> f2_16 = RegExpImpl::StringToTwoByte(f2);
561 CHECK(Re2kInterpreter::Match(array, f2_16, captures, 0)); 561 CHECK(IrregexpInterpreter::Match(array, f2_16, captures, 0));
562 CHECK_EQ(0, captures[0]); 562 CHECK_EQ(0, captures[0]);
563 CHECK_EQ(2, captures[1]); 563 CHECK_EQ(2, captures[1]);
564 564
565 Handle<String> f3 = Factory::NewStringFromAscii(CStrVector("tomfoolery")); 565 Handle<String> f3 = Factory::NewStringFromAscii(CStrVector("tomfoolery"));
566 Handle<String> f3_16 = RegExpImpl::StringToTwoByte(f3); 566 Handle<String> f3_16 = RegExpImpl::StringToTwoByte(f3);
567 CHECK(Re2kInterpreter::Match(array, f3_16, captures, 0)); 567 CHECK(IrregexpInterpreter::Match(array, f3_16, captures, 0));
568 CHECK_EQ(3, captures[0]); 568 CHECK_EQ(3, captures[0]);
569 CHECK_EQ(5, captures[1]); 569 CHECK_EQ(5, captures[1]);
570 } 570 }
571 571
572 572
573 TEST(Assembler2) { 573 TEST(Assembler2) {
574 V8::Initialize(NULL); 574 V8::Initialize(NULL);
575 byte codes[1024]; 575 byte codes[1024];
576 Re2kAssembler assembler(Vector<byte>(codes, 1024)); 576 IrregexpAssembler assembler(Vector<byte>(codes, 1024));
577 #define __ assembler. 577 #define __ assembler.
578 // /^.*foo/ 578 // /^.*foo/
579 Label more_dots; 579 Label more_dots;
580 Label unwind_dot; 580 Label unwind_dot;
581 Label failure; 581 Label failure;
582 Label foo; 582 Label foo;
583 Label foo_failed; 583 Label foo_failed;
584 Label dot_match; 584 Label dot_match;
585 // ^ 585 // ^
586 __ PushCurrentPosition(); 586 __ PushCurrentPosition();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 __ Fail(); 622 __ Fail();
623 623
624 v8::HandleScope scope; 624 v8::HandleScope scope;
625 Handle<ByteArray> array = Factory::NewByteArray(assembler.length()); 625 Handle<ByteArray> array = Factory::NewByteArray(assembler.length());
626 assembler.Copy(array->GetDataStartAddress()); 626 assembler.Copy(array->GetDataStartAddress());
627 int captures[2]; 627 int captures[2];
628 628
629 Handle<String> f1 = 629 Handle<String> f1 =
630 Factory::NewStringFromAscii(CStrVector("Now is the time")); 630 Factory::NewStringFromAscii(CStrVector("Now is the time"));
631 Handle<String> f1_16 = RegExpImpl::StringToTwoByte(f1); 631 Handle<String> f1_16 = RegExpImpl::StringToTwoByte(f1);
632 CHECK(!Re2kInterpreter::Match(array, f1_16, captures, 0)); 632 CHECK(!IrregexpInterpreter::Match(array, f1_16, captures, 0));
633 633
634 Handle<String> f2 = Factory::NewStringFromAscii(CStrVector("foo bar baz")); 634 Handle<String> f2 = Factory::NewStringFromAscii(CStrVector("foo bar baz"));
635 Handle<String> f2_16 = RegExpImpl::StringToTwoByte(f2); 635 Handle<String> f2_16 = RegExpImpl::StringToTwoByte(f2);
636 CHECK(Re2kInterpreter::Match(array, f2_16, captures, 0)); 636 CHECK(IrregexpInterpreter::Match(array, f2_16, captures, 0));
637 CHECK_EQ(0, captures[0]); 637 CHECK_EQ(0, captures[0]);
638 CHECK_EQ(2, captures[1]); 638 CHECK_EQ(2, captures[1]);
639 639
640 Handle<String> f3 = Factory::NewStringFromAscii(CStrVector("tomfoolery")); 640 Handle<String> f3 = Factory::NewStringFromAscii(CStrVector("tomfoolery"));
641 Handle<String> f3_16 = RegExpImpl::StringToTwoByte(f3); 641 Handle<String> f3_16 = RegExpImpl::StringToTwoByte(f3);
642 CHECK(Re2kInterpreter::Match(array, f3_16, captures, 0)); 642 CHECK(IrregexpInterpreter::Match(array, f3_16, captures, 0));
643 CHECK_EQ(0, captures[0]); 643 CHECK_EQ(0, captures[0]);
644 CHECK_EQ(5, captures[1]); 644 CHECK_EQ(5, captures[1]);
645 645
646 Handle<String> f4 = 646 Handle<String> f4 =
647 Factory::NewStringFromAscii(CStrVector("football buffoonery")); 647 Factory::NewStringFromAscii(CStrVector("football buffoonery"));
648 Handle<String> f4_16 = RegExpImpl::StringToTwoByte(f4); 648 Handle<String> f4_16 = RegExpImpl::StringToTwoByte(f4);
649 CHECK(Re2kInterpreter::Match(array, f4_16, captures, 0)); 649 CHECK(IrregexpInterpreter::Match(array, f4_16, captures, 0));
650 CHECK_EQ(0, captures[0]); 650 CHECK_EQ(0, captures[0]);
651 CHECK_EQ(14, captures[1]); 651 CHECK_EQ(14, captures[1]);
652 652
653 Handle<String> f5 = 653 Handle<String> f5 =
654 Factory::NewStringFromAscii(CStrVector("walking\nbarefoot")); 654 Factory::NewStringFromAscii(CStrVector("walking\nbarefoot"));
655 Handle<String> f5_16 = RegExpImpl::StringToTwoByte(f5); 655 Handle<String> f5_16 = RegExpImpl::StringToTwoByte(f5);
656 CHECK(!Re2kInterpreter::Match(array, f5_16, captures, 0)); 656 CHECK(!IrregexpInterpreter::Match(array, f5_16, captures, 0));
657 } 657 }
658 658
659 659
660 TEST(MacroAssembler) { 660 TEST(MacroAssembler) {
661 V8::Initialize(NULL); 661 V8::Initialize(NULL);
662 byte codes[1024]; 662 byte codes[1024];
663 Re2kAssembler assembler(Vector<byte>(codes, 1024)); 663 IrregexpAssembler assembler(Vector<byte>(codes, 1024));
664 RegExpMacroAssemblerRe2k m(&assembler); 664 RegExpMacroAssemblerIrregexp m(&assembler);
665 // ^f(o)o. 665 // ^f(o)o.
666 Label fail, fail2, start; 666 Label fail, fail2, start;
667 uc16 foo_chars[3]; 667 uc16 foo_chars[3];
668 foo_chars[0] = 'f'; 668 foo_chars[0] = 'f';
669 foo_chars[1] = 'o'; 669 foo_chars[1] = 'o';
670 foo_chars[2] = 'o'; 670 foo_chars[2] = 'o';
671 Vector<const uc16> foo(foo_chars, 3); 671 Vector<const uc16> foo(foo_chars, 3);
672 m.SetRegister(4, 42); 672 m.SetRegister(4, 42);
673 m.PushRegister(4); 673 m.PushRegister(4);
674 m.AdvanceRegister(4, 42); 674 m.AdvanceRegister(4, 42);
(...skipping 23 matching lines...) Expand all
698 698
699 v8::HandleScope scope; 699 v8::HandleScope scope;
700 700
701 Handle<ByteArray> array = Factory::NewByteArray(assembler.length()); 701 Handle<ByteArray> array = Factory::NewByteArray(assembler.length());
702 assembler.Copy(array->GetDataStartAddress()); 702 assembler.Copy(array->GetDataStartAddress());
703 int captures[5]; 703 int captures[5];
704 704
705 Handle<String> f1 = 705 Handle<String> f1 =
706 Factory::NewStringFromAscii(CStrVector("foobar")); 706 Factory::NewStringFromAscii(CStrVector("foobar"));
707 Handle<String> f1_16 = RegExpImpl::StringToTwoByte(f1); 707 Handle<String> f1_16 = RegExpImpl::StringToTwoByte(f1);
708 CHECK(Re2kInterpreter::Match(array, f1_16, captures, 0)); 708 CHECK(IrregexpInterpreter::Match(array, f1_16, captures, 0));
709 CHECK_EQ(0, captures[0]); 709 CHECK_EQ(0, captures[0]);
710 CHECK_EQ(3, captures[1]); 710 CHECK_EQ(3, captures[1]);
711 CHECK_EQ(1, captures[2]); 711 CHECK_EQ(1, captures[2]);
712 CHECK_EQ(2, captures[3]); 712 CHECK_EQ(2, captures[3]);
713 CHECK_EQ(84, captures[4]); 713 CHECK_EQ(84, captures[4]);
714 714
715 Handle<String> f2 = 715 Handle<String> f2 =
716 Factory::NewStringFromAscii(CStrVector("barfoo")); 716 Factory::NewStringFromAscii(CStrVector("barfoo"));
717 Handle<String> f2_16 = RegExpImpl::StringToTwoByte(f2); 717 Handle<String> f2_16 = RegExpImpl::StringToTwoByte(f2);
718 CHECK(!Re2kInterpreter::Match(array, f2_16, captures, 0)); 718 CHECK(!IrregexpInterpreter::Match(array, f2_16, captures, 0));
719 CHECK_EQ(42, captures[0]); 719 CHECK_EQ(42, captures[0]);
720 } 720 }
721 721
722 722
723 TEST(AddInverseToTable) { 723 TEST(AddInverseToTable) {
724 static const int kLimit = 1000; 724 static const int kLimit = 1000;
725 static const int kRangeCount = 16; 725 static const int kRangeCount = 16;
726 for (int t = 0; t < 10; t++) { 726 for (int t = 0; t < 10; t++) {
727 ZoneScope zone_scope(DELETE_ON_EXIT); 727 ZoneScope zone_scope(DELETE_ON_EXIT);
728 ZoneList<CharacterRange>* ranges = 728 ZoneList<CharacterRange>* ranges =
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 // whole block at a time. 919 // whole block at a time.
920 TestSimpleRangeCaseIndependence(CharacterRange('A', 'k'), 920 TestSimpleRangeCaseIndependence(CharacterRange('A', 'k'),
921 CharacterRange('a', 'z')); 921 CharacterRange('a', 'z'));
922 } 922 }
923 923
924 924
925 TEST(Graph) { 925 TEST(Graph) {
926 V8::Initialize(NULL); 926 V8::Initialize(NULL);
927 Execute("(x)?\\1y", "", true); 927 Execute("(x)?\\1y", "", true);
928 } 928 }
OLDNEW
« src/runtime.cc ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698