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

Side by Side Diff: tests/language/regex/ranges-and-escaped-hyphens_test.dart

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed Ivan's comments. Created 6 years, 2 months 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'util.dart';
6 import 'package:expect/expect.dart';
7
8 void main() {
9 description(
10 'Tests for bug <a href="https:new RegExp(r"/bugs.webkit.org/show_bug.cgi?id=21 232">#21232<")a>, and related range issues described in bug.'
11 );
12
13 // Basic test for ranges - one to three and five are in regexp, four is not, a nd '-' should not match
14 var regexp01 = new RegExp(r"[1-35]+").firstMatch("-12354");
15 shouldBe(regexp01, ["1235"]);
16 // Tests inserting an escape character class into the above pattern - where th e spaces fall within the
17 // range it is no longer a range - hyphens should now match, two should not.
18 var regexp01a = new RegExp(r"[\s1-35]+").firstMatch("-123 54");
19 shouldBe(regexp01a, ["123 5"]);
20
21 // These are invalid ranges, according to ECMA-262, but we allow them.
22 var regexp01b = new RegExp(r"[1\s-35]+").firstMatch("21-3 54");
23 shouldBe(regexp01b, ["1-3 5"]);
24 var regexp01c = new RegExp(r"[1-\s35]+").firstMatch("21-3 54");
25 shouldBe(regexp01c, ["1-3 5"]);
26
27 var regexp01d = new RegExp(r"[1-3\s5]+").firstMatch("-123 54");
28 shouldBe(regexp01d, ["123 5"]);
29 var regexp01e = new RegExp(r"[1-35\s5]+").firstMatch("-123 54");
30 shouldBe(regexp01e, ["123 5"]);
31 // hyphens are normal charaters if a range is not fully specified.
32 var regexp01f = new RegExp(r"[-3]+").firstMatch("2-34");
33 shouldBe(regexp01f, ["-3"]);
34 var regexp01g = new RegExp(r"[2-]+").firstMatch("12-3");
35 shouldBe(regexp01g, ["2-"]);
36
37 // Similar to the above tests, but where the hyphen is escaped this is never a range.
38 var regexp02 = new RegExp(r"[1\-35]+").firstMatch("21-354");
39 shouldBe(regexp02, ["1-35"]);
40 // As above.
41 var regexp02a = new RegExp(r"[\s1\-35]+").firstMatch("21-3 54");
42 shouldBe(regexp02a, ["1-3 5"]);
43 var regexp02b = new RegExp(r"[1\s\-35]+").firstMatch("21-3 54");
44 shouldBe(regexp02b, ["1-3 5"]);
45 var regexp02c = new RegExp(r"[1\-\s35]+").firstMatch("21-3 54");
46 shouldBe(regexp02c, ["1-3 5"]);
47 var regexp02d = new RegExp(r"[1\-3\s5]+").firstMatch("21-3 54");
48 shouldBe(regexp02d, ["1-3 5"]);
49 var regexp02e = new RegExp(r"[1\-35\s5]+").firstMatch("21-3 54");
50 shouldBe(regexp02e, ["1-3 5"]);
51
52 // Test that an escaped hyphen can be used as a bound on a range.
53 var regexp03a = new RegExp(r"[\--0]+").firstMatch(",-.01");
54 shouldBe(regexp03a, ["-.0"]);
55 var regexp03b = new RegExp(r"[+-\-]+").firstMatch("*+,-.");
56 shouldBe(regexp03b, ["+,-"]);
57
58 // The actual bug reported.
59 var bug21232 = (new RegExp(r"^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$")).hasMatch( '@');
60 shouldBeFalse(bug21232);
61 }
OLDNEW
« no previous file with comments | « tests/language/regex/range-out-of-order_test.dart ('k') | tests/language/regex/regexp_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698