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

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

Issue 12944: * Implemented case-insensitive back-reference matching in irregexp-ia32. (Closed)
Patch Set: Review comments addressed 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
« no previous file with comments | « src/regexp-macro-assembler-ia32.cc ('k') | test/mjsunit/regexp.js » ('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 2008 the V8 project authors. All rights reserved. 1 // Copyright 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 output, 810 output,
811 true); 811 true);
812 812
813 CHECK(success); 813 CHECK(success);
814 CHECK_EQ(0, output[0]); 814 CHECK_EQ(0, output[0]);
815 CHECK_EQ(2, output[1]); 815 CHECK_EQ(2, output[1]);
816 CHECK_EQ(6, output[2]); 816 CHECK_EQ(6, output[2]);
817 } 817 }
818 818
819 819
820
821 TEST(MacroAssemblerIA32AtStart) { 820 TEST(MacroAssemblerIA32AtStart) {
822 V8::Initialize(NULL); 821 V8::Initialize(NULL);
823 822
824 // regexp-macro-assembler-ia32 needs a handle scope to allocate 823 // regexp-macro-assembler-ia32 needs a handle scope to allocate
825 // byte-arrays for constants. 824 // byte-arrays for constants.
826 v8::HandleScope scope; 825 v8::HandleScope scope;
827 826
828 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0); 827 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 0);
829 828
830 uc16 foo_chars[3] = {'f', 'o', 'o'}; 829 uc16 foo_chars[3] = {'f', 'o', 'o'};
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 start_offset, 874 start_offset,
876 end_offset, 875 end_offset,
877 NULL, 876 NULL,
878 false); 877 false);
879 878
880 CHECK(success); 879 CHECK(success);
881 } 880 }
882 881
883 882
884 883
884
885 TEST(MacroAssemblerIA32BackRefNoCase) {
886 V8::Initialize(NULL);
887
888 // regexp-macro-assembler-ia32 needs a handle scope to allocate
889 // byte-arrays for constants.
890 v8::HandleScope scope;
891
892 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 4);
893
894 Label fail, succ;
895
896 m.WriteCurrentPositionToRegister(0);
897 m.WriteCurrentPositionToRegister(2);
898 m.AdvanceCurrentPosition(3);
899 m.WriteCurrentPositionToRegister(3);
900 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "AbC".
901 m.CheckNotBackReferenceIgnoreCase(2, &fail); // Match "ABC".
902 Label expected_fail;
903 m.CheckNotBackReferenceIgnoreCase(2, &expected_fail);
904 m.Bind(&fail);
905 m.Fail();
906
907 m.Bind(&expected_fail);
908 m.AdvanceCurrentPosition(3); // Skip "xYz"
909 m.CheckNotBackReferenceIgnoreCase(2, &succ);
910 m.Fail();
911
912 m.Bind(&succ);
913 m.WriteCurrentPositionToRegister(1);
914 m.Succeed();
915
916 Handle<Object> code_object = m.GetCode();
917 Handle<Code> code = Handle<Code>::cast(code_object);
918
919 Handle<String> input =
920 Factory::NewStringFromAscii(CStrVector("aBcAbCABCxYzab"));
921 Handle<SeqAsciiString> seq_input = Handle<SeqAsciiString>::cast(input);
922 Address start_adr = seq_input->GetCharsAddress();
923 int start_offset = start_adr - reinterpret_cast<Address>(*seq_input);
924 int end_offset = start_offset + seq_input->length();
925
926 int output[4];
927 bool success = RegExpMacroAssemblerIA32::Execute(*code,
928 seq_input.location(),
929 start_offset,
930 end_offset,
931 output,
932 true);
933
934 CHECK(success);
935 CHECK_EQ(0, output[0]);
936 CHECK_EQ(12, output[1]);
937 CHECK_EQ(0, output[2]);
938 CHECK_EQ(3, output[3]);
939 }
940
941
942
885 TEST(MacroAssemblerIA32Registers) { 943 TEST(MacroAssemblerIA32Registers) {
886 V8::Initialize(NULL); 944 V8::Initialize(NULL);
887 945
888 // regexp-macro-assembler-ia32 needs a handle scope to allocate 946 // regexp-macro-assembler-ia32 needs a handle scope to allocate
889 // byte-arrays for constants. 947 // byte-arrays for constants.
890 v8::HandleScope scope; 948 v8::HandleScope scope;
891 949
892 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 5); 950 RegExpMacroAssemblerIA32 m(RegExpMacroAssemblerIA32::ASCII, 5);
893 951
894 uc16 foo_chars[3] = {'f', 'o', 'o'}; 952 uc16 foo_chars[3] = {'f', 'o', 'o'};
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 CHECK(!InClass(i, excluded)); 1286 CHECK(!InClass(i, excluded));
1229 } 1287 }
1230 } 1288 }
1231 } 1289 }
1232 1290
1233 1291
1234 TEST(Graph) { 1292 TEST(Graph) {
1235 V8::Initialize(NULL); 1293 V8::Initialize(NULL);
1236 Execute("\\b\\w", false, true); 1294 Execute("\\b\\w", false, true);
1237 } 1295 }
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-ia32.cc ('k') | test/mjsunit/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698