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

Side by Side Diff: tests/language/regex/standalones_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
« no previous file with comments | « tests/language/regex/stack-overflow_test.dart ('k') | tests/language/regex/toString_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /* Many of the Mozilla regexp tests used 'toSource' to test their
10 * results. Since we don't currently support toSource, those tests
11 * are disabled and standalone versions are included here.
12 */
13
14 // Tests from ecma_3/RegExp/regress-78156.js
15 var string = 'aaa\n789\r\nccc\r\n345';
16 var pattern = new RegExp(r"^\d", multiLine: true);
17 var result = pattern.allMatches(string).toList();
18 assertEquals(2, result.length, "1");
19 assertEquals('7', result[0].group(0), "2");
20 assertEquals('3', result[1].group(0), "3");
21
22 pattern = new RegExp(r"\d$", multiLine: true);
23 result = pattern.allMatches(string).toList();
24 assertEquals(2, result.length, "4");
25 assertEquals('9', result[0].group(0), "5");
26 assertEquals('5', result[1].group(0), "6");
27
28 string = 'aaa\n789\r\nccc\r\nddd';
29 pattern = new RegExp(r"^\d", multiLine: true);
30 result = pattern.allMatches(string).toList();
31 assertEquals(1, result.length, "7");
32 assertEquals('7', result[0].group(0), "8");
33
34 pattern = new RegExp(r"\d$", multiLine: true);
35 result = pattern.allMatches(string).toList();
36 assertEquals(1, result.length, "9");
37 assertEquals('9', result[0].group(0), "10");
38
39 // Tests from ecma_3/RegExp/regress-72964.js
40 pattern = new RegExp(r"[\S]+");
41 string = '\u00BF\u00CD\u00BB\u00A7';
42 result = pattern.firstMatch(string);
43 assertEquals(1, result.groupCount + 1, "11");
44 assertEquals(string, result.group(0), "12");
45
46 string = '\u00BF\u00CD \u00BB\u00A7';
47 result = pattern.firstMatch(string);
48 assertEquals(1, result.groupCount + 1, "13");
49 assertEquals('\u00BF\u00CD', result.group(0), "14");
50
51 string = '\u4e00\uac00\u4e03\u4e00';
52 result = pattern.firstMatch(string);
53 assertEquals(1, result.groupCount + 1, "15");
54 assertEquals(string, result.group(0), "16");
55
56 string = '\u4e00\uac00 \u4e03\u4e00';
57 result = pattern.firstMatch(string);
58 assertEquals(1, result.groupCount + 1, "17");
59 assertEquals('\u4e00\uac00', result.group(0), "18");
60 }
OLDNEW
« no previous file with comments | « tests/language/regex/stack-overflow_test.dart ('k') | tests/language/regex/toString_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698