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

Side by Side Diff: tests/language/regex/negative-special-characters_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/multiline_test.dart ('k') | tests/language/regex/no-extensions_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 description(
10 "This test checks Unicode in negative RegExp character classes."
11 );
12
13 dynamic testPassed(str) { }
14 dynamic testFailed(str) => Expect.fail(str);
15
16 dynamic test(pattern, str, expected_length) {
17 var result = str.replaceAll(new RegExp(pattern, caseSensitive: false, multiL ine: true), '');
18
19 if (result.length == expected_length)
20 testPassed('"' + pattern + '", ' + '"' + str + '".');
21 else
22 testFailed('"' + pattern + '", ' + '"' + str + '". Was "' + result + '".') ;
23 }
24
25
26 test("\\s", " \t\f\v\r\n", 0); // ASCII whitespace.
27 test("\\S", "Проверка", 0); // Cyrillic letters are non-whitespace...
28 test("\\s", "Проверка", 8); // ...and they aren't whitespace.
29 test("[\\s]", "Проверка", 8);
30 test("[\\S]", "Проверка", 0);
31 test("[^\\s]", "Проверка", 0);
32 test("[^\\S]", "Проверка", 8);
33 test("[\\s\\S]*", "\\u2002Проверка\\r\\n\\u00a0", 0);
34 test("\\S\\S", "уф", 0);
35 test("\\S{2}", "уф", 0);
36
37 test("\\w", "Проверка", 8); // Alas, only ASCII characters count as word ones in JS.
38 test("\\W", "Проверка", 0);
39 test("[\\w]", "Проверка", 8);
40 test("[\\W]", "Проверка", 0);
41 test("[^\\w]", "Проверка", 0);
42 test("[^\\W]", "Проверка", 8);
43 test("\\W\\W", "уф", 0);
44 test("\\W{2}", "уф", 0);
45
46 test("\\d", "Проверка", 8); // Digit and non-digit.
47 test("\\D", "Проверка", 0);
48 test("[\\d]", "Проверка", 8);
49 test("[\\D]", "Проверка", 0);
50 test("[^\\d]", "Проверка", 0);
51 test("[^\\D]", "Проверка", 8);
52 test("\\D\\D", "уф", 0);
53 test("\\D{2}", "уф", 0);
54
55 test("[\\S\\d]", "Проверка123", 0);
56 test("[\\d\\S]", "Проверка123", 0);
57 test("[^\\S\\d]", "Проверка123", 11);
58 test("[^\\d\\S]", "Проверка123", 11);
59
60 test("[ \\S]", " Проверка ", 0);
61 test("[\\S ]", " Проверка ", 0);
62 test("[ф \\S]", " Проверка ", 0);
63 test("[\\Sф ]", " Проверка ", 0);
64
65 test("[^р\\S]", " Проверка ", 8);
66 test("[^\\Sр]", " Проверка ", 8);
67 test("[^р\\s]", " Проверка ", 4);
68 test("[^\\sр]", " Проверка ", 4);
69
70 test("[ф \\s\\S]", "Проверка \\r\\n", 0);
71 test("[\\S\\sф ]", "Проверка \\r\\n", 0);
72
73 test("[^z]", "Проверка \\r\\n", 0);
74 test("[^ф]", "Проверка \\r\\n", 0);
75 }
OLDNEW
« no previous file with comments | « tests/language/regex/multiline_test.dart ('k') | tests/language/regex/no-extensions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698