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

Side by Side Diff: tests/corelib/regexp/standalones_test.dart

Issue 667043003: Port regexp tests from V8 to Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: dart authors copyright Created 6 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 | Annotate | Revision Log
« no previous file with comments | « tests/corelib/regexp/stack-overflow_test.dart ('k') | tests/corelib/regexp/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. All rights reserved.
2 // Copyright 2008 the V8 project authors. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following
11 // disclaimer in the documentation and/or other materials provided
12 // with the distribution.
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived
15 // from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 import 'v8_regexp_utils.dart';
30 import 'package:expect/expect.dart';
31
32 void main() {
33 /* Many of the Mozilla regexp tests used 'toSource' to test their
34 * results. Since we don't currently support toSource, those tests
35 * are disabled and standalone versions are included here.
36 */
37
38 // Tests from ecma_3/RegExp/regress-78156.js
39 var string = 'aaa\n789\r\nccc\r\n345';
40 var pattern = new RegExp(r"^\d", multiLine: true);
41 var result = pattern.allMatches(string).toList();
42 assertEquals(2, result.length, "1");
43 assertEquals('7', result[0].group(0), "2");
44 assertEquals('3', result[1].group(0), "3");
45
46 pattern = new RegExp(r"\d$", multiLine: true);
47 result = pattern.allMatches(string).toList();
48 assertEquals(2, result.length, "4");
49 assertEquals('9', result[0].group(0), "5");
50 assertEquals('5', result[1].group(0), "6");
51
52 string = 'aaa\n789\r\nccc\r\nddd';
53 pattern = new RegExp(r"^\d", multiLine: true);
54 result = pattern.allMatches(string).toList();
55 assertEquals(1, result.length, "7");
56 assertEquals('7', result[0].group(0), "8");
57
58 pattern = new RegExp(r"\d$", multiLine: true);
59 result = pattern.allMatches(string).toList();
60 assertEquals(1, result.length, "9");
61 assertEquals('9', result[0].group(0), "10");
62
63 // Tests from ecma_3/RegExp/regress-72964.js
64 pattern = new RegExp(r"[\S]+");
65 string = '\u00BF\u00CD\u00BB\u00A7';
66 result = pattern.firstMatch(string);
67 assertEquals(1, result.groupCount + 1, "11");
68 assertEquals(string, result.group(0), "12");
69
70 string = '\u00BF\u00CD \u00BB\u00A7';
71 result = pattern.firstMatch(string);
72 assertEquals(1, result.groupCount + 1, "13");
73 assertEquals('\u00BF\u00CD', result.group(0), "14");
74
75 string = '\u4e00\uac00\u4e03\u4e00';
76 result = pattern.firstMatch(string);
77 assertEquals(1, result.groupCount + 1, "15");
78 assertEquals(string, result.group(0), "16");
79
80 string = '\u4e00\uac00 \u4e03\u4e00';
81 result = pattern.firstMatch(string);
82 assertEquals(1, result.groupCount + 1, "17");
83 assertEquals('\u4e00\uac00', result.group(0), "18");
84 }
OLDNEW
« no previous file with comments | « tests/corelib/regexp/stack-overflow_test.dart ('k') | tests/corelib/regexp/toString_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698