OLD | NEW |
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 CheckParseEq("xyz{0,1}", "(: 'xy' (# 0 1 g 'z'))"); | 192 CheckParseEq("xyz{0,1}", "(: 'xy' (# 0 1 g 'z'))"); |
193 CheckParseEq("xyz{0,1}?", "(: 'xy' (# 0 1 n 'z'))"); | 193 CheckParseEq("xyz{0,1}?", "(: 'xy' (# 0 1 n 'z'))"); |
194 CheckParseEq("xyz{93}", "(: 'xy' (# 93 93 g 'z'))"); | 194 CheckParseEq("xyz{93}", "(: 'xy' (# 93 93 g 'z'))"); |
195 CheckParseEq("xyz{93}?", "(: 'xy' (# 93 93 n 'z'))"); | 195 CheckParseEq("xyz{93}?", "(: 'xy' (# 93 93 n 'z'))"); |
196 CheckParseEq("xyz{1,32}", "(: 'xy' (# 1 32 g 'z'))"); | 196 CheckParseEq("xyz{1,32}", "(: 'xy' (# 1 32 g 'z'))"); |
197 CheckParseEq("xyz{1,32}?", "(: 'xy' (# 1 32 n 'z'))"); | 197 CheckParseEq("xyz{1,32}?", "(: 'xy' (# 1 32 n 'z'))"); |
198 CheckParseEq("xyz{1,}", "(: 'xy' (# 1 - g 'z'))"); | 198 CheckParseEq("xyz{1,}", "(: 'xy' (# 1 - g 'z'))"); |
199 CheckParseEq("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))"); | 199 CheckParseEq("xyz{1,}?", "(: 'xy' (# 1 - n 'z'))"); |
200 CheckParseEq("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'"); | 200 CheckParseEq("a\\fb\\nc\\rd\\te\\vf", "'a\\x0cb\\x0ac\\x0dd\\x09e\\x0bf'"); |
201 CheckParseEq("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')"); | 201 CheckParseEq("a\\nb\\bc", "(: 'a\\x0ab' @b 'c')"); |
202 CheckParseEq("(?:foo)", "'foo'"); | 202 CheckParseEq("(?:foo)", "(?: 'foo')"); |
203 CheckParseEq("(?: foo )", "' foo '"); | 203 CheckParseEq("(?: foo )", "(?: ' foo ')"); |
204 CheckParseEq("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))"); | 204 CheckParseEq("(foo|bar|baz)", "(^ (| 'foo' 'bar' 'baz'))"); |
205 CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')"); | 205 CheckParseEq("foo|(bar|baz)|quux", "(| 'foo' (^ (| 'bar' 'baz')) 'quux')"); |
206 CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')"); | 206 CheckParseEq("foo(?=bar)baz", "(: 'foo' (-> + 'bar') 'baz')"); |
207 CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')"); | 207 CheckParseEq("foo(?!bar)baz", "(: 'foo' (-> - 'bar') 'baz')"); |
208 if (lookbehind) { | 208 if (lookbehind) { |
209 CheckParseEq("foo(?<=bar)baz", "(: 'foo' (<- + 'bar') 'baz')"); | 209 CheckParseEq("foo(?<=bar)baz", "(: 'foo' (<- + 'bar') 'baz')"); |
210 CheckParseEq("foo(?<!bar)baz", "(: 'foo' (<- - 'bar') 'baz')"); | 210 CheckParseEq("foo(?<!bar)baz", "(: 'foo' (<- - 'bar') 'baz')"); |
211 } else { | 211 } else { |
212 CHECK_PARSE_ERROR("foo(?<=bar)baz"); | 212 CHECK_PARSE_ERROR("foo(?<=bar)baz"); |
213 CHECK_PARSE_ERROR("foo(?<!bar)baz"); | 213 CHECK_PARSE_ERROR("foo(?<!bar)baz"); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 CheckParseEq("(?=a)?a", "'a'"); | 287 CheckParseEq("(?=a)?a", "'a'"); |
288 CheckParseEq("(?=a){0,10}a", "'a'"); | 288 CheckParseEq("(?=a){0,10}a", "'a'"); |
289 CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')"); | 289 CheckParseEq("(?=a){1,10}a", "(: (-> + 'a') 'a')"); |
290 CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')"); | 290 CheckParseEq("(?=a){9,10}a", "(: (-> + 'a') 'a')"); |
291 CheckParseEq("(?!a)?a", "'a'"); | 291 CheckParseEq("(?!a)?a", "'a'"); |
292 CheckParseEq("\\1(a)", "(: (<- 1) (^ 'a'))"); | 292 CheckParseEq("\\1(a)", "(: (<- 1) (^ 'a'))"); |
293 CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))"); | 293 CheckParseEq("(?!(a))\\1", "(: (-> - (^ 'a')) (<- 1))"); |
294 CheckParseEq("(?!\\1(a\\1)\\1)\\1", | 294 CheckParseEq("(?!\\1(a\\1)\\1)\\1", |
295 "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))"); | 295 "(: (-> - (: (<- 1) (^ 'a') (<- 1))) (<- 1))"); |
296 CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1", | 296 CheckParseEq("\\1\\2(a(?:\\1(b\\1\\2))\\2)\\1", |
297 "(: (<- 1) (<- 2) (^ (: 'a' (^ 'b') (<- 2))) (<- 1))"); | 297 "(: (<- 1) (<- 2) (^ (: 'a' (?: (^ 'b')) (<- 2))) (<- 1))"); |
298 if (lookbehind) { | 298 if (lookbehind) { |
299 CheckParseEq("\\1\\2(a(?<=\\1(b\\1\\2))\\2)\\1", | 299 CheckParseEq("\\1\\2(a(?<=\\1(b\\1\\2))\\2)\\1", |
300 "(: (<- 1) (<- 2) (^ (: 'a' (<- + (^ 'b')) (<- 2))) (<- 1))"); | 300 "(: (<- 1) (<- 2) (^ (: 'a' (<- + (^ 'b')) (<- 2))) (<- 1))"); |
301 } | 301 } |
302 CheckParseEq("[\\0]", "[\\x00]"); | 302 CheckParseEq("[\\0]", "[\\x00]"); |
303 CheckParseEq("[\\11]", "[\\x09]"); | 303 CheckParseEq("[\\11]", "[\\x09]"); |
304 CheckParseEq("[\\11a]", "[\\x09 a]"); | 304 CheckParseEq("[\\11a]", "[\\x09 a]"); |
305 CheckParseEq("[\\011]", "[\\x09]"); | 305 CheckParseEq("[\\011]", "[\\x09]"); |
306 CheckParseEq("[\\00011]", "[\\x00 1 1]"); | 306 CheckParseEq("[\\00011]", "[\\x00 1 1]"); |
307 CheckParseEq("[\\118]", "[\\x09 8]"); | 307 CheckParseEq("[\\118]", "[\\x09 8]"); |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 v8::Local<v8::String> external = | 2025 v8::Local<v8::String> external = |
2026 v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) | 2026 v8::String::NewExternalOneByte(isolate, new UncachedExternalString()) |
2027 .ToLocalChecked(); | 2027 .ToLocalChecked(); |
2028 CHECK(v8::Utils::OpenHandle(*external)->map() == | 2028 CHECK(v8::Utils::OpenHandle(*external)->map() == |
2029 CcTest::i_isolate()->heap()->short_external_one_byte_string_map()); | 2029 CcTest::i_isolate()->heap()->short_external_one_byte_string_map()); |
2030 v8::Local<v8::Object> global = env->Global(); | 2030 v8::Local<v8::Object> global = env->Global(); |
2031 global->Set(env.local(), v8_str("external"), external).FromJust(); | 2031 global->Set(env.local(), v8_str("external"), external).FromJust(); |
2032 CompileRun("var re = /y(.)/; re.test('ab');"); | 2032 CompileRun("var re = /y(.)/; re.test('ab');"); |
2033 ExpectString("external.substring(1).match(re)[1]", "z"); | 2033 ExpectString("external.substring(1).match(re)[1]", "z"); |
2034 } | 2034 } |
OLD | NEW |