OLD | NEW |
| (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( | |
30 new RegExp(r"ΣΤΙΓΜΑΣ", caseSensitive: false).hasMatch("στιγμας")); | |
31 shouldBeTrue(new RegExp(r"ΔΣΔ", caseSensitive: false).hasMatch("δςδ")); | |
32 shouldBeTrue(new RegExp(r"ς", caseSensitive: false).hasMatch("σ")); | |
33 shouldBeTrue(new RegExp(r"σ", caseSensitive: false).hasMatch("ς")); | |
34 | |
35 // Simple case, has no canonical equivalents | |
36 shouldBeTrue(new RegExp(r"\u1f16", caseSensitive: false).hasMatch("\u1f16")); | |
37 | |
38 // Test the sets of USC2 code points that have more than one canonically equiv
alent value. | |
39 dynamic ucs2CodePoint(x) => new String.fromCharCode(x); | |
40 dynamic testSet(s) { | |
41 for (var i in s) { | |
42 for (var j in s) { | |
43 shouldBeTrue(new RegExp(ucs2CodePoint(i), caseSensitive: false) | |
44 .hasMatch(ucs2CodePoint(j))); | |
45 shouldBeTrue(new RegExp( | |
46 "[${ucs2CodePoint(i - 1)}-${ucs2CodePoint(i + 1)}]", | |
47 caseSensitive: false) | |
48 .hasMatch(ucs2CodePoint(j))); | |
49 } | |
50 } | |
51 } | |
52 | |
53 testSet([0x01c4, 0x01c5, 0x01c6]); | |
54 testSet([0x01c7, 0x01c8, 0x01c9]); | |
55 testSet([0x01ca, 0x01cb, 0x01cc]); | |
56 testSet([0x01f1, 0x01f2, 0x01f3]); | |
57 testSet([0x0392, 0x03b2, 0x03d0]); | |
58 testSet([0x0395, 0x03b5, 0x03f5]); | |
59 testSet([0x0398, 0x03b8, 0x03d1]); | |
60 testSet([0x0345, 0x0399, 0x03b9, 0x1fbe]); | |
61 testSet([0x039a, 0x03ba, 0x03f0]); | |
62 testSet([0x00b5, 0x039c, 0x03bc]); | |
63 testSet([0x03a0, 0x03c0, 0x03d6]); | |
64 testSet([0x03a1, 0x03c1, 0x03f1]); | |
65 testSet([0x03a3, 0x03c2, 0x03c3]); | |
66 testSet([0x03a6, 0x03c6, 0x03d5]); | |
67 testSet([0x1e60, 0x1e61, 0x1e9b]); | |
68 | |
69 // Test a couple of lo/hi pairs | |
70 shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03cf")); | |
71 shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03cf")); | |
72 shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03d7")); | |
73 shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03d7")); | |
74 shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f11")); | |
75 shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f11")); | |
76 shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f19")); | |
77 shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f19")); | |
78 | |
79 // Test an aligned alternating capitalization pair. | |
80 shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048a")); | |
81 shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048a")); | |
82 shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048a")); | |
83 shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048a")); | |
84 shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048b")); | |
85 shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048b")); | |
86 shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048b")); | |
87 shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048b")); | |
88 shouldBeTrue( | |
89 new RegExp(r"[\u0489-\u048a]", caseSensitive: false).hasMatch("\u048b")); | |
90 shouldBeTrue( | |
91 new RegExp(r"[\u048b-\u048c]", caseSensitive: false).hasMatch("\u048a")); | |
92 | |
93 // Test an unaligned alternating capitalization pair. | |
94 shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c5")); | |
95 shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c5")); | |
96 shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c5")); | |
97 shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c5")); | |
98 shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c6")); | |
99 shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c6")); | |
100 shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c6")); | |
101 shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c6")); | |
102 shouldBeTrue( | |
103 new RegExp(r"[\u04c4-\u04c5]", caseSensitive: false).hasMatch("\u04c6")); | |
104 shouldBeTrue( | |
105 new RegExp(r"[\u04c6-\u04c7]", caseSensitive: false).hasMatch("\u04c5")); | |
106 | |
107 var successfullyParsed = true; | |
108 } | |
OLD | NEW |