OLD | NEW |
(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 shouldBeTrue(new RegExp(r"ΣΤΙΓΜΑΣ", caseSensitive: false).hasMatch("στιγμας"))
; |
| 10 shouldBeTrue(new RegExp(r"ΔΣΔ", caseSensitive: false).hasMatch("δςδ")); |
| 11 shouldBeTrue(new RegExp(r"ς", caseSensitive: false).hasMatch("σ")); |
| 12 shouldBeTrue(new RegExp(r"σ", caseSensitive: false).hasMatch("ς")); |
| 13 |
| 14 // Simple case, has no canonical equivalents |
| 15 shouldBeTrue(new RegExp(r"\u1f16", caseSensitive: false).hasMatch("\u1f16")); |
| 16 |
| 17 // Test the sets of USC2 code points that have more than one canonically equiv
alent value. |
| 18 dynamic ucs2CodePoint(x) => new String.fromCharCode(x); |
| 19 dynamic testSet(s) |
| 20 { |
| 21 for (var i in s) { |
| 22 for (var j in s) { |
| 23 shouldBeTrue(new RegExp(ucs2CodePoint(i), caseSensitive: false).ha
sMatch(ucs2CodePoint(j))); |
| 24 shouldBeTrue(new RegExp("[${ucs2CodePoint(i - 1)}-${ucs2CodePoint(
i + 1)}]", caseSensitive: false).hasMatch(ucs2CodePoint(j))); |
| 25 } |
| 26 } |
| 27 } |
| 28 testSet([ 0x01c4, 0x01c5, 0x01c6 ]); |
| 29 testSet([ 0x01c7, 0x01c8, 0x01c9 ]); |
| 30 testSet([ 0x01ca, 0x01cb, 0x01cc ]); |
| 31 testSet([ 0x01f1, 0x01f2, 0x01f3 ]); |
| 32 testSet([ 0x0392, 0x03b2, 0x03d0 ]); |
| 33 testSet([ 0x0395, 0x03b5, 0x03f5 ]); |
| 34 testSet([ 0x0398, 0x03b8, 0x03d1 ]); |
| 35 testSet([ 0x0345, 0x0399, 0x03b9, 0x1fbe ]); |
| 36 testSet([ 0x039a, 0x03ba, 0x03f0 ]); |
| 37 testSet([ 0x00b5, 0x039c, 0x03bc ]); |
| 38 testSet([ 0x03a0, 0x03c0, 0x03d6 ]); |
| 39 testSet([ 0x03a1, 0x03c1, 0x03f1 ]); |
| 40 testSet([ 0x03a3, 0x03c2, 0x03c3 ]); |
| 41 testSet([ 0x03a6, 0x03c6, 0x03d5 ]); |
| 42 testSet([ 0x1e60, 0x1e61, 0x1e9b ]); |
| 43 |
| 44 // Test a couple of lo/hi pairs |
| 45 shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03cf")); |
| 46 shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03cf")); |
| 47 shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03d7")); |
| 48 shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03d7")); |
| 49 shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f11")); |
| 50 shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f11")); |
| 51 shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f19")); |
| 52 shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f19")); |
| 53 |
| 54 // Test an aligned alternating capitalization pair. |
| 55 shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048a")); |
| 56 shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048a")); |
| 57 shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048a")); |
| 58 shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048a")); |
| 59 shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048b")); |
| 60 shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048b")); |
| 61 shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048b")); |
| 62 shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048b")); |
| 63 shouldBeTrue(new RegExp(r"[\u0489-\u048a]", caseSensitive: false).hasMatch("\u
048b")); |
| 64 shouldBeTrue(new RegExp(r"[\u048b-\u048c]", caseSensitive: false).hasMatch("\u
048a")); |
| 65 |
| 66 // Test an unaligned alternating capitalization pair. |
| 67 shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c5")); |
| 68 shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c5")); |
| 69 shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c5")); |
| 70 shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c5")); |
| 71 shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c6")); |
| 72 shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c6")); |
| 73 shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c6")); |
| 74 shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c6")); |
| 75 shouldBeTrue(new RegExp(r"[\u04c4-\u04c5]", caseSensitive: false).hasMatch("\u
04c6")); |
| 76 shouldBeTrue(new RegExp(r"[\u04c6-\u04c7]", caseSensitive: false).hasMatch("\u
04c5")); |
| 77 |
| 78 var successfullyParsed = true; |
| 79 } |
OLD | NEW |