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

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

Issue 691473002: Reapply "Port regexp tests from V8 to Dart." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: RC and rebase 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
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. All rights reserved.
2 // Copyright 2013 the V8 project authors. All rights reserved.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions
7 // are met:
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
18 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
21 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25 import 'v8_regexp_utils.dart';
26 import 'package:expect/expect.dart';
27
28 void main() {
29 shouldBeTrue(new RegExp(r"ΣΤΙΓΜΑΣ", caseSensitive: false).hasMatch("στιγμας")) ;
30 shouldBeTrue(new RegExp(r"ΔΣΔ", caseSensitive: false).hasMatch("δςδ"));
31 shouldBeTrue(new RegExp(r"ς", caseSensitive: false).hasMatch("σ"));
32 shouldBeTrue(new RegExp(r"σ", caseSensitive: false).hasMatch("ς"));
33
34 // Simple case, has no canonical equivalents
35 shouldBeTrue(new RegExp(r"\u1f16", caseSensitive: false).hasMatch("\u1f16"));
36
37 // Test the sets of USC2 code points that have more than one canonically equiv alent value.
38 dynamic ucs2CodePoint(x) => new String.fromCharCode(x);
39 dynamic testSet(s)
40 {
41 for (var i in s) {
42 for (var j in s) {
43 shouldBeTrue(new RegExp(ucs2CodePoint(i), caseSensitive: false).ha sMatch(ucs2CodePoint(j)));
44 shouldBeTrue(new RegExp("[${ucs2CodePoint(i - 1)}-${ucs2CodePoint( i + 1)}]", caseSensitive: false).hasMatch(ucs2CodePoint(j)));
45 }
46 }
47 }
48 testSet([ 0x01c4, 0x01c5, 0x01c6 ]);
49 testSet([ 0x01c7, 0x01c8, 0x01c9 ]);
50 testSet([ 0x01ca, 0x01cb, 0x01cc ]);
51 testSet([ 0x01f1, 0x01f2, 0x01f3 ]);
52 testSet([ 0x0392, 0x03b2, 0x03d0 ]);
53 testSet([ 0x0395, 0x03b5, 0x03f5 ]);
54 testSet([ 0x0398, 0x03b8, 0x03d1 ]);
55 testSet([ 0x0345, 0x0399, 0x03b9, 0x1fbe ]);
56 testSet([ 0x039a, 0x03ba, 0x03f0 ]);
57 testSet([ 0x00b5, 0x039c, 0x03bc ]);
58 testSet([ 0x03a0, 0x03c0, 0x03d6 ]);
59 testSet([ 0x03a1, 0x03c1, 0x03f1 ]);
60 testSet([ 0x03a3, 0x03c2, 0x03c3 ]);
61 testSet([ 0x03a6, 0x03c6, 0x03d5 ]);
62 testSet([ 0x1e60, 0x1e61, 0x1e9b ]);
63
64 // Test a couple of lo/hi pairs
65 shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03cf"));
66 shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03cf"));
67 shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03d7"));
68 shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03d7"));
69 shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f11"));
70 shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f11"));
71 shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f19"));
72 shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f19"));
73
74 // Test an aligned alternating capitalization pair.
75 shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048a"));
76 shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048a"));
77 shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048a"));
78 shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048a"));
79 shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048b"));
80 shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048b"));
81 shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048b"));
82 shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048b"));
83 shouldBeTrue(new RegExp(r"[\u0489-\u048a]", caseSensitive: false).hasMatch("\u 048b"));
84 shouldBeTrue(new RegExp(r"[\u048b-\u048c]", caseSensitive: false).hasMatch("\u 048a"));
85
86 // Test an unaligned alternating capitalization pair.
87 shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c5"));
88 shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c5"));
89 shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c5"));
90 shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c5"));
91 shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c6"));
92 shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c6"));
93 shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c6"));
94 shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c6"));
95 shouldBeTrue(new RegExp(r"[\u04c4-\u04c5]", caseSensitive: false).hasMatch("\u 04c6"));
96 shouldBeTrue(new RegExp(r"[\u04c6-\u04c7]", caseSensitive: false).hasMatch("\u 04c5"));
97
98 var successfullyParsed = true;
99 }
OLDNEW
« no previous file with comments | « tests/corelib/regexp/unicode-handling_test.dart ('k') | tests/corelib/regexp/v8_regexp_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698