OLD | NEW |
---|---|
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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
829 m.WriteCurrentPositionToRegister(1, 0); | 829 m.WriteCurrentPositionToRegister(1, 0); |
830 m.Succeed(); | 830 m.Succeed(); |
831 m.Bind(&fail); | 831 m.Bind(&fail); |
832 m.Fail(); | 832 m.Fail(); |
833 | 833 |
834 Handle<String> source = factory->NewStringFromAscii(CStrVector("^foo")); | 834 Handle<String> source = factory->NewStringFromAscii(CStrVector("^foo")); |
835 Handle<Object> code_object = m.GetCode(source); | 835 Handle<Object> code_object = m.GetCode(source); |
836 Handle<Code> code = Handle<Code>::cast(code_object); | 836 Handle<Code> code = Handle<Code>::cast(code_object); |
837 | 837 |
838 int captures[4] = {42, 37, 87, 117}; | 838 int captures[4] = {42, 37, 87, 117}; |
839 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', '\xa0'}; | 839 const uc16 input_data[6] = {'f', 'o', 'o', 'f', 'o', |
840 const_cast<uc16>('\xa0')}; | |
Vyacheslav Egorov (Chromium)
2011/12/12 18:06:17
Why do you need const_cast here? const_cast is for
Tobias Burnus
2011/12/12 21:54:00
True, a static_cast should be sufficient. (In the
| |
840 Handle<String> input = | 841 Handle<String> input = |
841 factory->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); | 842 factory->NewStringFromTwoByte(Vector<const uc16>(input_data, 6)); |
842 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); | 843 Handle<SeqTwoByteString> seq_input = Handle<SeqTwoByteString>::cast(input); |
843 Address start_adr = seq_input->GetCharsAddress(); | 844 Address start_adr = seq_input->GetCharsAddress(); |
844 | 845 |
845 NativeRegExpMacroAssembler::Result result = | 846 NativeRegExpMacroAssembler::Result result = |
846 Execute(*code, | 847 Execute(*code, |
847 *input, | 848 *input, |
848 0, | 849 0, |
849 start_adr, | 850 start_adr, |
850 start_adr + input->length(), | 851 start_adr + input->length(), |
851 captures); | 852 captures); |
852 | 853 |
853 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); | 854 CHECK_EQ(NativeRegExpMacroAssembler::SUCCESS, result); |
854 CHECK_EQ(0, captures[0]); | 855 CHECK_EQ(0, captures[0]); |
855 CHECK_EQ(3, captures[1]); | 856 CHECK_EQ(3, captures[1]); |
856 CHECK_EQ(-1, captures[2]); | 857 CHECK_EQ(-1, captures[2]); |
857 CHECK_EQ(-1, captures[3]); | 858 CHECK_EQ(-1, captures[3]); |
858 | 859 |
859 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', '\xa0'}; | 860 const uc16 input_data2[9] = {'b', 'a', 'r', 'b', 'a', 'r', 'b', 'a', |
861 const_cast<uc16>('\xa0')}; | |
Vyacheslav Egorov (Chromium)
2011/12/12 18:06:17
Ditto.
| |
860 input = factory->NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); | 862 input = factory->NewStringFromTwoByte(Vector<const uc16>(input_data2, 9)); |
861 seq_input = Handle<SeqTwoByteString>::cast(input); | 863 seq_input = Handle<SeqTwoByteString>::cast(input); |
862 start_adr = seq_input->GetCharsAddress(); | 864 start_adr = seq_input->GetCharsAddress(); |
863 | 865 |
864 result = Execute(*code, | 866 result = Execute(*code, |
865 *input, | 867 *input, |
866 0, | 868 0, |
867 start_adr, | 869 start_adr, |
868 start_adr + input->length() * 2, | 870 start_adr + input->length() * 2, |
869 captures); | 871 captures); |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1823 bool in_second = CharacterInSet(&l2, i); | 1825 bool in_second = CharacterInSet(&l2, i); |
1824 CHECK((in_first || in_second) == CharacterInSet(&all, i)); | 1826 CHECK((in_first || in_second) == CharacterInSet(&all, i)); |
1825 } | 1827 } |
1826 } | 1828 } |
1827 | 1829 |
1828 | 1830 |
1829 TEST(Graph) { | 1831 TEST(Graph) { |
1830 V8::Initialize(NULL); | 1832 V8::Initialize(NULL); |
1831 Execute("\\b\\w+\\b", false, true, true); | 1833 Execute("\\b\\w+\\b", false, true, true); |
1832 } | 1834 } |
OLD | NEW |