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

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

Issue 11203: * Changed string-representation of regexps to handle unprintable chars. (Closed)
Patch Set: Created 12 years, 1 month 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
« regexp2000/src/parser.cc ('K') | « regexp2000/src/parser.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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 CHECK_PARSE_EQ("xyz?", "(: 'xy' (# 0 1 g 'z'))"); 89 CHECK_PARSE_EQ("xyz?", "(: 'xy' (# 0 1 g 'z'))");
90 CHECK_PARSE_EQ("xyz??", "(: 'xy' (# 0 1 n 'z'))"); 90 CHECK_PARSE_EQ("xyz??", "(: 'xy' (# 0 1 n 'z'))");
91 CHECK_PARSE_EQ("xyz{0,1}", "(: 'xy' (# 0 1 g 'z'))"); 91 CHECK_PARSE_EQ("xyz{0,1}", "(: 'xy' (# 0 1 g 'z'))");
92 CHECK_PARSE_EQ("xyz{0,1}?", "(: 'xy' (# 0 1 n 'z'))"); 92 CHECK_PARSE_EQ("xyz{0,1}?", "(: 'xy' (# 0 1 n 'z'))");
93 CHECK_PARSE_EQ("xyz{93}", "(: 'xy' (# 93 93 g 'z'))"); 93 CHECK_PARSE_EQ("xyz{93}", "(: 'xy' (# 93 93 g 'z'))");
94 CHECK_PARSE_EQ("xyz{93}?", "(: 'xy' (# 93 93 n 'z'))"); 94 CHECK_PARSE_EQ("xyz{93}?", "(: 'xy' (# 93 93 n 'z'))");
95 CHECK_PARSE_EQ("xyz{1,32}", "(: 'xy' (# 1 32 g 'z'))"); 95 CHECK_PARSE_EQ("xyz{1,32}", "(: 'xy' (# 1 32 g 'z'))");
96 CHECK_PARSE_EQ("xyz{1,32}?", "(: 'xy' (# 1 32 n 'z'))"); 96 CHECK_PARSE_EQ("xyz{1,32}?", "(: 'xy' (# 1 32 n 'z'))");
97 CHECK_PARSE_EQ("xyz{1,}", "(: 'xy' (# 1 - g 'z'))"); 97 CHECK_PARSE_EQ("xyz{1,}", "(: 'xy' (# 1 - g 'z'))");
98 CHECK_PARSE_EQ("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))"); 98 CHECK_PARSE_EQ("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))");
99 CHECK_PARSE_EQ("a\\fb\\nc\\rd\\te\\vf", "'a\fb\nc\rd\te\vf'"); 99 CHECK_PARSE_EQ("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'");
100 CHECK_PARSE_EQ("a\\nb\\bc", "(: 'a\nb' @b 'c')"); 100 CHECK_PARSE_EQ("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')");
101 CHECK_PARSE_EQ("(?:foo)", "'foo'"); 101 CHECK_PARSE_EQ("(?:foo)", "'foo'");
102 CHECK_PARSE_EQ("(?: foo )", "' foo '"); 102 CHECK_PARSE_EQ("(?: foo )", "' foo '");
103 CHECK_PARSE_EQ("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))"); 103 CHECK_PARSE_EQ("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))");
104 CHECK_PARSE_EQ("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')"); 104 CHECK_PARSE_EQ("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')");
105 CHECK_PARSE_EQ("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')"); 105 CHECK_PARSE_EQ("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')");
106 CHECK_PARSE_EQ("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')"); 106 CHECK_PARSE_EQ("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')");
107 CHECK_PARSE_EQ("()", "(^ %)"); 107 CHECK_PARSE_EQ("()", "(^ %)");
108 CHECK_PARSE_EQ("(?=)", "(-> + %)"); 108 CHECK_PARSE_EQ("(?=)", "(-> + %)");
109 CHECK_PARSE_EQ("[]", "^[\x00-\uffff]"); 109 CHECK_PARSE_EQ("[]", "^[\\x00-\\uffff]"); // Doesn't compile on windows
110 CHECK_PARSE_EQ("[^]", "[\x00-\uffff]"); 110 CHECK_PARSE_EQ("[^]", "[\\x00-\\uffff]"); // \uffff isn't in codepage 1252
111 CHECK_PARSE_EQ("[x]", "[x]"); 111 CHECK_PARSE_EQ("[x]", "[x]");
112 CHECK_PARSE_EQ("[xyz]", "[x y z]"); 112 CHECK_PARSE_EQ("[xyz]", "[x y z]");
113 CHECK_PARSE_EQ("[a-zA-Z0-9]", "[a-z A-Z 0-9]"); 113 CHECK_PARSE_EQ("[a-zA-Z0-9]", "[a-z A-Z 0-9]");
114 CHECK_PARSE_EQ("[-123]", "[- 1 2 3]"); 114 CHECK_PARSE_EQ("[-123]", "[- 1 2 3]");
115 CHECK_PARSE_EQ("[^123]", "^[1 2 3]"); 115 CHECK_PARSE_EQ("[^123]", "^[1 2 3]");
116 CHECK_PARSE_EQ("]", "']'"); 116 CHECK_PARSE_EQ("]", "']'");
117 CHECK_PARSE_EQ("}", "'}'"); 117 CHECK_PARSE_EQ("}", "'}'");
118 CHECK_PARSE_EQ("[a-b-c]", "[a-b - c]"); 118 CHECK_PARSE_EQ("[a-b-c]", "[a-b - c]");
119 CHECK_PARSE_EQ("[\\d]", "[0-9]"); 119 CHECK_PARSE_EQ("[\\d]", "[0-9]");
120 CHECK_PARSE_EQ("[x\\dz]", "[x 0-9 z]"); 120 CHECK_PARSE_EQ("[x\\dz]", "[x 0-9 z]");
121 CHECK_PARSE_EQ("[\\d-z]", "[0-9 - z]"); 121 CHECK_PARSE_EQ("[\\d-z]", "[0-9 - z]");
122 CHECK_PARSE_EQ("[\\d-\\d]", "[0-9 - 0-9]"); 122 CHECK_PARSE_EQ("[\\d-\\d]", "[0-9 - 0-9]");
123 CHECK_PARSE_EQ("\\cj\\cJ\\ci\\cI\\ck\\cK", "'\n\n\t\t\v\v'"); 123 CHECK_PARSE_EQ("\\cj\\cJ\\ci\\cI\\ck\\cK",
124 "'\\x0a\\x0a\\x09\\x09\\x0b\\x0b'");
124 CHECK_PARSE_EQ("\\c!", "'c!'"); 125 CHECK_PARSE_EQ("\\c!", "'c!'");
125 CHECK_PARSE_EQ("\\c_", "'c_'"); 126 CHECK_PARSE_EQ("\\c_", "'c_'");
126 CHECK_PARSE_EQ("\\c~", "'c~'"); 127 CHECK_PARSE_EQ("\\c~", "'c~'");
127 CHECK_PARSE_EQ("[a\\]c]", "[a ] c]"); 128 CHECK_PARSE_EQ("[a\\]c]", "[a ] c]");
128 CHECK_PARSE_EQ("\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ", "'[]{}()%^# '"); 129 CHECK_PARSE_EQ("\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ", "'[]{}()%^# '");
129 CHECK_PARSE_EQ("[\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ]", "[[ ] { } ( ) % ^ # ]"); 130 CHECK_PARSE_EQ("[\\[\\]\\{\\}\\(\\)\\%\\^\\#\\ ]", "[[ ] { } ( ) % ^ # ]");
130 CHECK_PARSE_EQ("\\0", "'\0'"); 131 CHECK_PARSE_EQ("\\0", "'\\x00'");
131 CHECK_PARSE_EQ("\\8", "'8'"); 132 CHECK_PARSE_EQ("\\8", "'8'");
132 CHECK_PARSE_EQ("\\9", "'9'"); 133 CHECK_PARSE_EQ("\\9", "'9'");
133 CHECK_PARSE_EQ("\\11", "'\t'"); 134 CHECK_PARSE_EQ("\\11", "'\\x09'");
134 CHECK_PARSE_EQ("\\11a", "'\ta'"); 135 CHECK_PARSE_EQ("\\11a", "'\\x09a'");
135 CHECK_PARSE_EQ("\\011", "'\t'"); 136 CHECK_PARSE_EQ("\\011", "'\\x09'");
136 CHECK_PARSE_EQ("\\00011", "'\00011'"); 137 CHECK_PARSE_EQ("\\00011", "'\\x0011'");
137 CHECK_PARSE_EQ("\\118", "'\t8'"); 138 CHECK_PARSE_EQ("\\118", "'\\x098'");
138 CHECK_PARSE_EQ("\\111", "'I'"); 139 CHECK_PARSE_EQ("\\111", "'I'");
139 CHECK_PARSE_EQ("\\1111", "'I1'"); 140 CHECK_PARSE_EQ("\\1111", "'I1'");
140 CHECK_PARSE_EQ("(x)(x)(x)\\1", "(: (^ 'x') (^ 'x') (^ 'x') (<- 1))"); 141 CHECK_PARSE_EQ("(x)(x)(x)\\1", "(: (^ 'x') (^ 'x') (^ 'x') (<- 1))");
141 CHECK_PARSE_EQ("(x)(x)(x)\\2", "(: (^ 'x') (^ 'x') (^ 'x') (<- 2))"); 142 CHECK_PARSE_EQ("(x)(x)(x)\\2", "(: (^ 'x') (^ 'x') (^ 'x') (<- 2))");
142 CHECK_PARSE_EQ("(x)(x)(x)\\3", "(: (^ 'x') (^ 'x') (^ 'x') (<- 3))"); 143 CHECK_PARSE_EQ("(x)(x)(x)\\3", "(: (^ 'x') (^ 'x') (^ 'x') (<- 3))");
143 CHECK_PARSE_EQ("(x)(x)(x)\\4", "(: (^ 'x') (^ 'x') (^ 'x') '\x04')"); 144 CHECK_PARSE_EQ("(x)(x)(x)\\4", "(: (^ 'x') (^ 'x') (^ 'x') '\\x04')");
144 CHECK_PARSE_EQ("(x)(x)(x)\\1*", "(: (^ 'x') (^ 'x') (^ 'x')" 145 CHECK_PARSE_EQ("(x)(x)(x)\\1*", "(: (^ 'x') (^ 'x') (^ 'x')"
145 " (# 0 - g (<- 1)))"); 146 " (# 0 - g (<- 1)))");
146 CHECK_PARSE_EQ("(x)(x)(x)\\2*", "(: (^ 'x') (^ 'x') (^ 'x')" 147 CHECK_PARSE_EQ("(x)(x)(x)\\2*", "(: (^ 'x') (^ 'x') (^ 'x')"
147 " (# 0 - g (<- 2)))"); 148 " (# 0 - g (<- 2)))");
148 CHECK_PARSE_EQ("(x)(x)(x)\\3*", "(: (^ 'x') (^ 'x') (^ 'x')" 149 CHECK_PARSE_EQ("(x)(x)(x)\\3*", "(: (^ 'x') (^ 'x') (^ 'x')"
149 " (# 0 - g (<- 3)))"); 150 " (# 0 - g (<- 3)))");
150 CHECK_PARSE_EQ("(x)(x)(x)\\4*", "(: (^ 'x') (^ 'x') (^ 'x')" 151 CHECK_PARSE_EQ("(x)(x)(x)\\4*", "(: (^ 'x') (^ 'x') (^ 'x')"
151 " (# 0 - g '\x04'))"); 152 " (# 0 - g '\\x04'))");
152 CHECK_PARSE_EQ("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10", 153 CHECK_PARSE_EQ("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\10",
153 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" 154 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
154 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))"); 155 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') (<- 10))");
155 CHECK_PARSE_EQ("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11", 156 CHECK_PARSE_EQ("(x)(x)(x)(x)(x)(x)(x)(x)(x)(x)\\11",
156 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')" 157 "(: (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x') (^ 'x')"
157 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\x09')"); 158 " (^ 'x') (^ 'x') (^ 'x') (^ 'x') '\\x09')");
158 CHECK_PARSE_EQ("(a)\\1", "(: (^ 'a') (<- 1))"); 159 CHECK_PARSE_EQ("(a)\\1", "(: (^ 'a') (<- 1))");
159 CHECK_PARSE_EQ("(a\\1)", "(^ 'a')"); 160 CHECK_PARSE_EQ("(a\\1)", "(^ 'a')");
160 CHECK_PARSE_EQ("(\\1a)", "(^ 'a')"); 161 CHECK_PARSE_EQ("(\\1a)", "(^ 'a')");
161 CHECK_PARSE_EQ("\\1(a)", "(: '\x01' (^ 'a'))"); 162 CHECK_PARSE_EQ("\\1(a)", "(: '\\x01' (^ 'a'))");
162 CHECK_PARSE_EQ("(?!(a))\\1", "(-> - (^ 'a'))"); 163 CHECK_PARSE_EQ("(?!(a))\\1", "(-> - (^ 'a'))");
163 CHECK_PARSE_EQ("(?!\\1(a\\1)\\1)\\1", "(-> - (: '\x01' (^ 'a') (<- 1)))"); 164 CHECK_PARSE_EQ("(?!\\1(a\\1)\\1)\\1", "(-> - (: '\\x01' (^ 'a') (<- 1)))");
164 CHECK_PARSE_EQ("[\\0]", "[\0]"); 165 CHECK_PARSE_EQ("[\\0]", "[\\x00]");
165 CHECK_PARSE_EQ("[\\11]", "[\t]"); 166 CHECK_PARSE_EQ("[\\11]", "[\\x09]");
166 CHECK_PARSE_EQ("[\\11a]", "[\t a]"); 167 CHECK_PARSE_EQ("[\\11a]", "[\\x09 a]");
167 CHECK_PARSE_EQ("[\\011]", "[\t]"); 168 CHECK_PARSE_EQ("[\\011]", "[\\x09]");
168 CHECK_PARSE_EQ("[\\00011]", "[\000 1 1]"); 169 CHECK_PARSE_EQ("[\\00011]", "[\\x00 1 1]");
169 CHECK_PARSE_EQ("[\\118]", "[\t 8]"); 170 CHECK_PARSE_EQ("[\\118]", "[\\x09 8]");
170 CHECK_PARSE_EQ("[\\111]", "[I]"); 171 CHECK_PARSE_EQ("[\\111]", "[I]");
171 CHECK_PARSE_EQ("[\\1111]", "[I 1]"); 172 CHECK_PARSE_EQ("[\\1111]", "[I 1]");
172 CHECK_PARSE_EQ("\\x34", "'\x34'"); 173 CHECK_PARSE_EQ("\\x34", "'\x34'");
173 CHECK_PARSE_EQ("\\x60", "'\x60'"); 174 CHECK_PARSE_EQ("\\x60", "'\x60'");
174 CHECK_PARSE_EQ("\\x3z", "'x3z'"); 175 CHECK_PARSE_EQ("\\x3z", "'x3z'");
175 CHECK_PARSE_EQ("\\u0034", "'\x34'"); 176 CHECK_PARSE_EQ("\\u0034", "'\x34'");
176 CHECK_PARSE_EQ("\\u003z", "'u003z'"); 177 CHECK_PARSE_EQ("\\u003z", "'u003z'");
177 CHECK_PARSE_EQ("foo[z]*", "(: 'foo' (# 0 - g [z]))"); 178 CHECK_PARSE_EQ("foo[z]*", "(: 'foo' (# 0 - g [z]))");
178 179
179 CHECK_ESCAPES("a", false); 180 CHECK_ESCAPES("a", false);
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 cons.set_choice_index(0); 704 cons.set_choice_index(0);
704 cons.AddInverse(ranges); 705 cons.AddInverse(ranges);
705 CHECK(!table.Get(0xFFFE)->Get(0)); 706 CHECK(!table.Get(0xFFFE)->Get(0));
706 CHECK(table.Get(0xFFFF)->Get(0)); 707 CHECK(table.Get(0xFFFF)->Get(0));
707 } 708 }
708 709
709 710
710 TEST(Graph) { 711 TEST(Graph) {
711 Execute("fo[ob]ar|[ba]z|x[yz]*", "", true); 712 Execute("fo[ob]ar|[ba]z|x[yz]*", "", true);
712 } 713 }
OLDNEW
« regexp2000/src/parser.cc ('K') | « regexp2000/src/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698